diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 8f48e7b..5ef4607 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -3,6 +3,8 @@ current_version = 1.0.10 commit = True tag = True +[bumpversion:file:pyproject.toml] + [bumpversion:file:kiwi_stackbuild_plugin/version.py] [bumpversion:file:doc/source/conf.py] diff --git a/.github/workflows/ci-publish-to-pypi.yml b/.github/workflows/ci-publish-to-pypi.yml index ec8966c..3d65de1 100644 --- a/.github/workflows/ci-publish-to-pypi.yml +++ b/.github/workflows/ci-publish-to-pypi.yml @@ -28,9 +28,9 @@ jobs: - name: Install run: | python -m pip install --upgrade pip - python -m pip install tox + python -m pip install poetry - name: Prepare run: | - tox -e doc,release + make prepare_for_pypi - name: Publish uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index cef3f33..c2833f3 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v3 @@ -20,10 +20,10 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Install + - name: Install Poetry run: | python -m pip install --upgrade pip - python -m pip install tox - - name: Tox + python -m pip install poetry + - name: Run unit and type tests run: | - tox + make check test diff --git a/.gitignore b/.gitignore index b6e4761..2bf19bc 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,6 @@ dmypy.json # Pyre type checker .pyre/ + +# Poetry +poetry.lock diff --git a/.virtualenv.dev-requirements.txt b/.virtualenv.dev-requirements.txt deleted file mode 100644 index d68e681..0000000 --- a/.virtualenv.dev-requirements.txt +++ /dev/null @@ -1,34 +0,0 @@ -# After activation of the env, install it with: -# $ pip install -r dev-requirements.txt - --r .virtualenv.requirements.txt - -# setuptools for pypi upload -setuptools - -# virtualenv-based automation of test activities -tox - -# python unit testing framework -pytest -pytest-cov -pytest-xdist - -# Version-bump your software with a single command! -bumpversion - -# A built-package format for Python -wheel - -# Python style guide checker -flake8 - -# for building documentation -sphinx>=5.0.0 -sphinx_rtd_theme - -# for release -twine - -# static type checking -mypy diff --git a/.virtualenv.requirements.txt b/.virtualenv.requirements.txt deleted file mode 100644 index 9bbc311..0000000 --- a/.virtualenv.requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -# After activation of the env, install it with: -# $ pip install -r requirements.txt - -# Shell interface for docopt, the command-line interface description language -docopt - -# kiwi -kiwi diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 1fe13a7..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,18 +0,0 @@ -# Manifest describing source package contents - -graft kiwi_stackbuild_plugin/tasks -graft package - -include Makefile -include README.rst -include LICENSE -include tox.ini -include .bumpversion.cfg -include .virtualenv.requirements.txt -include .virtualenv.dev-requirements.txt - -include .coverage* - -recursive-include doc/build/man * - -global-exclude *.py[cod] __pycache__ diff --git a/Makefile b/Makefile index 19ca58a..a66e76d 100644 --- a/Makefile +++ b/Makefile @@ -9,32 +9,45 @@ version := $(shell \ 'from kiwi_stackbuild_plugin.version import __version__; print(__version__)'\ ) -tox: - tox - install: # install plugin manual page and license/readme # NOTE: this file is not handled through pip because on system level install -d -m 755 ${buildroot}usr/share/man/man8 gzip -f doc/build/man/kiwi::system::stackbuild.8 + gzip -f doc/build/man/kiwi::system::stash.8 install -m 644 doc/build/man/kiwi::system::stackbuild.8.gz \ ${buildroot}usr/share/man/man8 + install -m 644 doc/build/man/kiwi::system::stash.8.gz \ + ${buildroot}usr/share/man/man8 install -d -m 755 ${buildroot}${docdir}/python-kiwi_stackbuild_plugin install -m 644 LICENSE \ ${buildroot}${docdir}/python-kiwi_stackbuild_plugin/LICENSE install -m 644 README.rst \ ${buildroot}${docdir}/python-kiwi_stackbuild_plugin/README -build: clean tox - # create setup.py variant for rpm build. - # delete module versions from setup.py for building an rpm - # the dependencies to the python module rpm packages is - # managed in the spec file - sed -ie "s@>=[0-9.]*'@'@g" setup.py +setup: + poetry install --all-extras + +docs: setup + poetry run make -C doc man + +check: setup + # python flake tests + poetry run flake8 --statistics -j auto --count kiwi_stackbuild_plugin + poetry run flake8 --statistics -j auto --count test/unit + +test: setup + # python static code checks + poetry run mypy kiwi_stackbuild_plugin + # unit tests + poetry run bash -c 'pushd test/unit && pytest -n 5 \ + --doctest-modules --no-cov-on-fail --cov=kiwi_stackbuild_plugin \ + --cov-report=term-missing --cov-fail-under=100 \ + --cov-config .coveragerc' + +build: clean check test # build the sdist source tarball - $(python) setup.py sdist - # restore original setup.py backed up from sed - mv setup.pye setup.py + poetry build --format=sdist # provide rpm source tarball mv dist/kiwi_stackbuild_plugin-${version}.tar.gz \ dist/python-kiwi-stackbuild-plugin.tar.gz @@ -52,10 +65,12 @@ build: clean tox # provide rpm rpmlintrc cp package/python-kiwi_stackbuild_plugin-rpmlintrc dist -pypi: clean tox - $(python) setup.py sdist upload +prepare_for_pypi: clean setup + # sdist tarball, the actual publishing happens via the + # ci-publish-to-pypi.yml github action + poetry build --format=sdist clean: - $(python) setup.py clean + rm -rf dist rm -rf doc/build - rm -rf dist/* + rm -rf doc/dist diff --git a/doc/source/conf.py b/doc/source/conf.py index 7cc2062..507be25 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -20,7 +20,6 @@ extensions = [ 'sphinx.ext.extlinks', 'sphinx.ext.viewcode', - 'sphinx.ext.intersphinx' ] # Add any paths that contain templates here, relative to this directory. diff --git a/package/python-kiwi_stackbuild_plugin-spec-template b/package/python-kiwi_stackbuild_plugin-spec-template index 5cfc195..d85463a 100644 --- a/package/python-kiwi_stackbuild_plugin-spec-template +++ b/package/python-kiwi_stackbuild_plugin-spec-template @@ -59,15 +59,36 @@ Summary: KIWI - Stack Build Plugin License: GPL-3.0-or-later %if "%{_vendor}" == "debbuild" # Needed to set Maintainer in output debs -Packager: Marcus Schaefer +Packager: Marcus Schaefer %endif Group: %{pygroup} Source: python-kiwi-stackbuild-plugin.tar.gz Source1: %{name}-rpmlintrc BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: python%{python3_pkgversion}-%{develsuffix} -BuildRequires: python%{python3_pkgversion}-setuptools +BuildRequires: python%{python3_pkgversion}-build +BuildRequires: python%{python3_pkgversion}-installer +BuildRequires: python%{python3_pkgversion}-poetry-core >= 1.2.0 +BuildRequires: python%{python3_pkgversion}-wheel +# doc build requirements +%if ! (0%{?fedora} >= 41 || 0%{?rhel} >= 10) +BuildRequires: python%{python3_pkgversion}-docopt >= 0.6.2 +%else +BuildRequires: python%{python3_pkgversion}-docopt-ng +%endif +%if 0%{?suse_version} +BuildRequires: python%{python3_pkgversion}-Sphinx +%else +BuildRequires: python%{python3_pkgversion}-sphinx +%endif +%if 0%{?debian} || 0%{?ubuntu} +BuildRequires: python%{python3_pkgversion}-sphinx-rtd-theme +%else +BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme +%endif +%if 0%{?fedora} || 0%{?suse_version} BuildRequires: fdupes +%endif BuildArch: noarch %description @@ -79,9 +100,9 @@ image root directory %package -n python%{python3_pkgversion}-kiwi_stackbuild_plugin Summary: KIWI - Stack Build Plugin Group: Development/Languages/Python +Requires: python%{python3_pkgversion} >= 3.9 Requires: python%{python3_pkgversion}-docopt Requires: python%{python3_pkgversion}-kiwi >= 9.21.21 -Requires: python%{python3_pkgversion}-setuptools %description -n python%{python3_pkgversion}-kiwi_stackbuild_plugin KIWI plugin to build images using a container layer as the rootfs @@ -91,13 +112,27 @@ image root directory %prep %setup -q -n kiwi_stackbuild_plugin-%{version} -%build -# Build Python 3 version -%{__python3} setup.py build +# Temporarily switch things back to docopt for everything but Fedora 41+ +# FIXME: Drop this hack as soon as we can... +%if ! (0%{?fedora} >= 41 || 0%{?rhel} >= 10) +sed -e 's/docopt-ng.*/docopt = ">=0.6.2"/' -i pyproject.toml +%endif + +# Build documentation +make -C doc man + +# Build application wheel +%{__python3} -m build --no-isolation --wheel %install -# Install Python 3 version -%{__python3} setup.py install --prefix=%{_prefix} --root=%{buildroot} %{?is_deb:--install-layout=deb} +# Install plugin +%{__python3} -m installer --destdir %{buildroot} %{?is_deb:--no-compile-bytecode} dist/*.whl + +%if 0%{?is_deb} +# Fix where files were installed +mv %{buildroot}%{_prefix}/local/* %{buildroot}%{_prefix} +mv %{buildroot}%{_prefix}/lib/python3* %{buildroot}%{_prefix}/lib/python3 +%endif # Install man pages and package documentation make buildroot=%{buildroot}/ docdir=%{_defaultdocdir}/ install diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c584311 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,87 @@ +[tool.poetry] +name = "kiwi_stackbuild_plugin" +version = "1.0.10" +description = "KIWI - Stack Build Plugin" +license = "GPL-3.0-or-later" +readme = "README.rst" +homepage = "https://osinside.github.io/kiwi/" +documentation = "https://osinside.github.io/kiwi/plugins/stackbuild.html" +repository = "https://github.com/OSInside/kiwi-stackbuild-plugin" + +authors = [ + "Marcus Schäfer ", + "David Cassany Viladomat ", +] +maintainers = [ + "Marcus Schäfer ", + "David Cassany Viladomat ", + "Neal Gompa ", +] + +packages = [ + { include = "kiwi_stackbuild_plugin"}, +] + +include = [ + { path = ".bumpversion.cfg", format = "sdist" }, + { path = ".coverage*", format = "sdist" }, + { path = "setup.cfg", format = "sdist" }, + { path = "doc/source", format = "sdist" }, + { path = "doc/Makefile", format = "sdist" }, + { path = "helper", format = "sdist" }, + { path = "Makefile", format = "sdist" }, + { path = "package", format = "sdist" }, + { path = "test", format = "sdist" }, +] + +classifiers = [ + # classifier: http://pypi.python.org/pypi?%3Aaction=list_classifiers + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Operating System :: POSIX :: Linux", + "Topic :: System :: Operating System", +] + +[tool.poetry.urls] +"Bug Tracker" = "https://github.com/OSInside/kiwi-stackbuild-plugin/issues" + +[tool.poetry.dependencies] +python = "^3.9" +kiwi = ">=9.21.21" +docopt-ng = ">=0.9.0" + +[tool.poetry.plugins] +[tool.poetry.plugins."kiwi.tasks"] +system_stackbuild = "kiwi_stackbuild_plugin.tasks.system_stackbuild" +system_stash = "kiwi_stackbuild_plugin.tasks.system_stash" + +[tool.poetry.group.test] +[tool.poetry.group.test.dependencies] +# python unit testing framework +pytest = ">=6.2.0" +pytest-cov = "*" +pytest-xdist = "*" +# type checking +mypy = ">=0.971" + +[tool.poetry.group.style] +[tool.poetry.group.style.dependencies] +flake8 = ">=4.0.0" + +[tool.poetry.group.docs] +[tool.poetry.group.docs.dependencies] +sphinx = ">=5.0.0" +sphinx_rtd_theme = "*" +sphinxcontrib-spelling = "*" +pyenchant = "*" +travis-sphinx = "*" +ghp-import = "*" + +[tool.poetry.group.development] +[tool.poetry.group.development.dependencies] +python-dateutil = "*" +bumpversion = "*" + +[build-system] +requires = ["poetry-core>=1.2.0"] +build-backend = "poetry.core.masonry.api" diff --git a/setup.cfg b/setup.cfg index b4083f0..3cbe831 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [sdist] -# Used by setup.py sdist +# Used by sdist formats=gztar [tool:pytest] diff --git a/setup.py b/setup.py deleted file mode 100755 index 8df9d75..0000000 --- a/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -from os import path -from setuptools import setup - -from kiwi_stackbuild_plugin.version import __version__ - -here = path.abspath(path.dirname(__file__)) -with open(path.join(here, 'README.rst'), encoding='utf-8') as readme: - long_description = readme.read() - -config = { - 'name': 'kiwi_stackbuild_plugin', - 'long_description': long_description, - 'description': 'KIWI - Stack Build Plugin', - 'author': 'David Cassany', - 'author': 'Marcus Schaefer', - 'url': 'https://github.com/OSInside/kiwi-stackbuild-plugin', - 'download_url': - 'https://download.opensuse.org/repositories/' - 'Virtualization:/Appliances:/Builder', - 'author_email': 'dcassany@suse.com', - 'author_email': 'ms@suse.com', - 'version': __version__, - 'license' : 'GPLv3+', - 'install_requires': [ - 'docopt', - 'kiwi>=9.23.0' - ], - 'packages': ['kiwi_stackbuild_plugin'], - 'entry_points': { - 'kiwi.tasks': [ - 'system_stackbuild=kiwi_stackbuild_plugin.tasks.system_stackbuild', - 'system_stash=kiwi_stackbuild_plugin.tasks.system_stash' - ] - }, - 'include_package_data': True, - 'zip_safe': False, - 'classifiers': [ - # classifier: http://pypi.python.org/pypi?%3Aaction=list_classifiers - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: ' - 'GNU General Public License v3 or later (GPLv3+)', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.8', - 'Topic :: System :: Operating System', - ] -} - -setup(**config) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 971e49f..0000000 --- a/tox.ini +++ /dev/null @@ -1,121 +0,0 @@ -# Tox configuration file -# -# For more information, see https://tox.readthedocs.org -# -# Run it with -# a) all targets -# $ tox -# -# b) with specific targets (build only documentation): -# $ tox -e doc -# -[tox] -minversion = 3.3.0 -isolated_build = True -skip_missing_interpreters = True -skipsdist = True -envlist = - check, - unit_py3_11, - unit_py3_10, - doc - - -[testenv] -description = - {unit_py3_10,unit_py3_11}: Unit Test run with basepython set to {basepython} -allowlist_externals = - bash - travis-sphinx - cp - make - rm - mv - flake8 - python - pytest -basepython = - {check,devel,doc}: python3 - unit_py3_11: python3.11 - unit_py3_10: python3.10 - release: python3.10 -passenv = - * -usedevelop = True -deps = - -r.virtualenv.dev-requirements.txt - - -# Unit Test run with basepython set to 3.10 -[testenv:unit_py3_10] -setenv = - PYTHONPATH={toxinidir}/test -changedir=test/unit -commands = - {[testenv:unit]commands} - - -# Unit Test run with basepython set to 3.11 -[testenv:unit_py3_11] -setenv = - PYTHONPATH={toxinidir}/test -changedir=test/unit -commands = - {[testenv:unit]commands} - - -[testenv:unit] -description = Unit Test Base -skip_install = True -usedevelop = True -setenv = - PYTHONUNBUFFERED=yes - WITH_COVERAGE=yes -passenv = - * -deps = {[testenv]deps} -changedir=test/unit -commands = - bash -c 'cd ../../ && ./setup.py develop' - bash -c 'cd ../../ && mypy --install-types --non-interactive kiwi_stackbuild_plugin' - pytest --doctest-modules --no-cov-on-fail --cov=kiwi_stackbuild_plugin \ - --cov-report=term-missing --cov-fail-under=100 \ - --cov-config .coveragerc {posargs} - - -# Documentation build suitable for local review -[testenv:doc] -skip_install = True -usedevelop = True -deps = {[testenv]deps} -changedir=doc -commands = - {[testenv:doc.man]commands} - - -# Documentation build man pages -[testenv:doc.man] -skip_install = True -deps = {[testenv:doc]deps} -changedir=doc -commands = - make man - - -# Source code quality/integrity check -[testenv:check] -deps = {[testenv]deps} -skip_install = True -usedevelop = True -commands = - flake8 --statistics -j auto --count {toxinidir}/kiwi_stackbuild_plugin - flake8 --statistics -j auto --count {toxinidir}/test/unit - - -# PyPi upload -[testenv:release] -deps = {[testenv]deps} -skip_install = True -usedevelop = True -commands = - python setup.py sdist