From: Joerg Behrmann Date: Fri, 30 Jun 2023 12:30:36 +0000 (+0200) Subject: Remove setup.py and use setuptools build backend in pyproject.toml X-Git-Tag: v15~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92c4e55ce1cac6e40cc914e86b5b2104d68b13b2;p=thirdparty%2Fmkosi.git Remove setup.py and use setuptools build backend in pyproject.toml Also remove setup.cfg, since we don't use flake8 and everything else can be handled by pyproject.toml --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5381279b4..426ef6f95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: run: | sudo apt-get update sudo apt-get install pandoc + python3 -m pip install --upgrade setuptools wheel pip python3 -m pip install pytest mypy types-cryptography isort pyflakes npm install -g pyright @@ -48,33 +49,21 @@ jobs: - name: Test execution from current working directory (sudo call) run: sudo python3 -m mkosi -h - - name: Test user installation - run: | - python3 -m pip install --user . - $HOME/.local/bin/mkosi -h - python3 -m pip uninstall --yes mkosi - - - name: Test editable user installation - run: | - python3 -m pip install --user --no-use-pep517 --editable . - $HOME/.local/bin/mkosi -h - python3 -m pip uninstall --yes mkosi - - name: Test venv installation run: | python3 -m venv testvenv + testvenv/bin/python3 -m pip install --upgrade setuptools wheel pip testvenv/bin/python3 -m pip install . testvenv/bin/mkosi -h + rm -rf testenv - - name: Test venv installation (sudo call) + - name: Test editable venv installation run: | - sudo testvenv/bin/mkosi -h - - - name: Test system installation - run: | - sudo python3 -m pip install . - sudo mkosi -h - sudo python3 -m pip uninstall --yes mkosi + python3 -m venv testvenv + testvenv/bin/python3 -m pip install --upgrade setuptools wheel pip + testvenv/bin/python3 -m pip install --editable . + testvenv/bin/mkosi -h + rm -rf testenv - name: Test zipapp creation run: | @@ -118,12 +107,10 @@ jobs: - uses: actions/checkout@v3 - uses: ./ - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install --no-install-recommends python3-pexpect python3-pytest - - # Do a manual install so we have the latest changes from the pull request available. + # Make sure the latest changes from the pull request are used. - name: Install - run: sudo python3 -m pip install .. + run: sudo ln -svf $PWD/bin/mkosi /usr/bin/mkosi + working-directory: ./ - name: Configure ${{ matrix.distro }}/${{ matrix.format }} run: | @@ -136,7 +123,7 @@ jobs: EOF - name: Build ${{ matrix.distro }}/${{ matrix.format }} - run: python3 -m mkosi --debug build + run: mkosi --debug build # systemd-resolved is enabled by default in Arch/Debian/Ubuntu (systemd default preset) but fails to # start in a systemd-nspawn container with --private-users so we mask it out here to avoid CI failures. @@ -147,8 +134,8 @@ jobs: - name: Boot ${{ matrix.distro }}/${{ matrix.format }} systemd-nspawn if: matrix.format == 'disk' || matrix.format == 'directory' - run: sudo python3 -m mkosi --debug boot + run: sudo mkosi --debug boot - name: Boot ${{ matrix.distro }}/${{ matrix.format }} UEFI if: matrix.format == 'disk' - run: timeout -k 30 10m python3 -m mkosi --debug qemu + run: timeout -k 30 10m mkosi --debug qemu diff --git a/README b/README deleted file mode 120000 index 42061c01a..000000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -README.md \ No newline at end of file diff --git a/action.yaml b/action.yaml index 3b0395018..252869328 100644 --- a/action.yaml +++ b/action.yaml @@ -92,4 +92,4 @@ runs: - name: Install shell: bash - run: sudo python3 -m pip install ${{ github.action_path }} + run: sudo ln -svf ${{ github.action_path }}/bin/mkosi /usr/bin/mkosi diff --git a/pyproject.toml b/pyproject.toml index 5c4beea08..4530d8387 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,30 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "mkosi" +authors = [ + {name = "mkosi contributors", email = "systemd-devel@lists.freedesktop.org"}, +] +version = "14" +description = "Build Bespoke OS Images" +readme = "README.md" +requires-python = ">=3.9" +license = {file = "LICENSE"} + +[project.scripts] +mkosi = "mkosi.__main__:main" + +[tool.setuptools] +packages = ["mkosi"] + +[tool.setuptools.package-data] +"*" = ["*.sh", "*.hook", "*.conf", "*.install"] + [tool.isort] profile = "black" +include_trailing_comma = true multi_line_output = 3 py_version = "39" @@ -8,3 +33,31 @@ pythonVersion = "3.9" [tool.pytest.ini_options] asyncio_mode = "auto" + +[tool.mypy] +python_version = 3.9 +# belonging to --strict +warn_unused_configs = true +disallow_any_generics = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_untyped_decorators = true +disallow_incomplete_defs = true +check_untyped_defs = true +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = false +warn_return_any = true +no_implicit_reexport = true +# extra options not in --strict +pretty = true +show_error_codes = true +show_column_numbers = true +warn_unreachable = true +allow_redefinition = true +strict_equality = true + +[[tool.mypy.overrides]] +module = ["argcomplete"] +ignore_missing_imports = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 93e00d7ed..000000000 --- a/setup.cfg +++ /dev/null @@ -1,30 +0,0 @@ -[flake8] -max-line-length = 119 -[isort] -multi_line_output = 3 -include_trailing_comma = True -[mypy] -python_version = 3.9 -# belonging to --strict -warn_unused_configs = True -disallow_any_generics = True -disallow_subclassing_any = True -disallow_untyped_calls = True -disallow_untyped_defs = True -disallow_untyped_decorators = True -disallow_incomplete_defs = True -check_untyped_defs = True -no_implicit_optional = True -warn_redundant_casts = True -warn_unused_ignores = False -warn_return_any = True -no_implicit_reexport = True -# extra options not in --strict -pretty = True -show_error_codes = True -show_column_numbers = True -warn_unreachable = True -allow_redefinition = True -strict_equality = True -[mypy-argcomplete] -ignore_missing_imports = True diff --git a/setup.py b/setup.py deleted file mode 100755 index a455d2851..000000000 --- a/setup.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/python3 -# SPDX-License-Identifier: LGPL-2.1+ - -from setuptools import setup, find_packages -from setuptools.command.install import install - - -class InstallCommand(install): - def run(self): - self.spawn(['pandoc', '-t', 'man', '-s', '-o', 'mkosi.1', 'mkosi.md']) - install.run(self) - - -setup( - name="mkosi", - version="14", - description="Build Bespoke OS Images", - url="https://github.com/systemd/mkosi", - maintainer="mkosi contributors", - maintainer_email="systemd-devel@lists.freedesktop.org", - license="LGPLv2+", - python_requires=">=3.9", - packages = find_packages(".", exclude=["tests"]), - package_data = {"": ["*.sh", "*.hook", "*.conf", "*.install"]}, - include_package_data = True, - entry_points = { "console_scripts": ["mkosi = mkosi.__main__:main"] }, - cmdclass = { "install": InstallCommand }, - data_files = [('share/man/man1', ["mkosi.1"])], -)