Skip to content

Commit

Permalink
Switch to Poetry and use pyproject.toml definitions
Browse files Browse the repository at this point in the history
This allows kiwi to be built, developed, tested, and installed
through Poetry. This also raises the minimum Python version to 3.9.
  • Loading branch information
Conan-Kudo committed Mar 4, 2024
1 parent 63c5e0f commit c03d1b0
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 242 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-units-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .virtualenv.dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-r .virtualenv.requirements.txt

# setuptools for pypi upload
setuptools
poetry

# virtualenv-based automation of test activities
tox
Expand Down
47 changes: 0 additions & 47 deletions MANIFEST.in

This file was deleted.

15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,8 @@ clean_git_attributes:
git checkout kiwi/version.py

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
# 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-${version}.tar.gz dist/python-kiwi.tar.gz
# update rpm changelog using reference file
Expand All @@ -118,9 +111,11 @@ build: clean tox
cp package/python-kiwi-rpmlintrc dist

pypi: clean tox
$(python) setup.py sdist upload
poetry build --format=sdist
poetry publish --repository=pypi


clean: clean_git_attributes
$(python) setup.py clean
rm -rf dist
rm -rf doc/build
rm -rf doc/dist
40 changes: 5 additions & 35 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,19 @@ environment for Python 3:
{kiwi} uses tox to create a devel environment and to run
tests, linters and other tasks in the tox generated environment.
A tox version >= 3.3 is required for this setup process. On your
host a python version >= 3.7 is required for tox to work.
host a python version >= 3.9 is required for tox to work.

.. code:: shell-session
$ tox -e devel
$ source .tox/devel/bin/activate
$ poetry install
The commands above automatically creates the application script
The command above automatically creates the application script
called :command:`kiwi-ng`, which allows you to run {kiwi} from the
Python sources inside the virtual environment:
Python sources inside the virtual environment using Poetry:

.. code:: shell-session
$ kiwi-ng --help
.. warning::

The virtualenv's `$PATH` will not be taken into account when calling
{kiwi} via :command:`sudo`! Use the absolute path to the {kiwi} executable
to run an actual build using your local changes:

.. code:: shell-session
$ sudo $PWD/.tox/devel/bin/kiwi-ng system build ...
To leave the development mode, run:

.. code:: shell-session
$ deactivate
To resume your work, :command:`cd` into your local Git repository and call:

.. code:: shell-session
$ source .tox/devel/bin/activate
Alternatively, you can launch single commands inside the virtualenv without
sourcing it directly:

.. code:: shell-session
$ tox -e devel -- kiwi-ng --version
$ poetry run kiwi-ng --help
Running the Unit Tests
Expand Down
45 changes: 30 additions & 15 deletions package/python-kiwi-spec-template
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ Group: %{pygroup}
Source: %{name}.tar.gz
Source1: %{name}-rpmlintrc
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: gcc
BuildRequires: python%{python3_pkgversion}-%{develsuffix} >= 3.6
BuildRequires: python%{python3_pkgversion}-setuptools
%if 0%{?fedora} || 0%{?suse_version}
BuildRequires: fdupes
%endif
Expand All @@ -69,6 +66,25 @@ BuildRequires: shadow
%if 0%{?debian} || 0%{?ubuntu}
BuildRequires: passwd
%endif
# Main build requirements
BuildRequires: python%{python3_pkgversion}-%{develsuffix} >= 3.9
BuildRequires: python%{python3_pkgversion}-build
BuildRequires: python%{python3_pkgversion}-installer
BuildRequires: python%{python3_pkgversion}-poetry-core
BuildRequires: python%{python3_pkgversion}-wheel
# doc build requirements
BuildRequires: python%{python3_pkgversion}-docopt >= 0.6.2
BuildRequires: python%{python3_pkgversion}-lxml
BuildRequires: python%{python3_pkgversion}-requests
BuildRequires: python%{python3_pkgversion}-simplejson
BuildRequires: python%{python3_pkgversion}-sphinx
%if 0%{?debian} || 0%{?ubuntu}
BuildRequires: python%{python3_pkgversion}-sphinx-rtd-theme
BuildRequires: python%{python3_pkgversion}-yaml
%else
BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme
BuildRequires: python%{python3_pkgversion}-PyYAML
%endif

%description
The KIWI Image System provides an operating system image builder
Expand Down Expand Up @@ -359,10 +375,9 @@ Obsoletes: python2-kiwi
Conflicts: python2-kiwi
Conflicts: kiwi-man-pages < %{version}
Requires: screen
Requires: python%{python3_pkgversion} >= 3.6
Requires: python%{python3_pkgversion} >= 3.9
%if 0%{?ubuntu} || 0%{?debian}
Requires: python%{python3_pkgversion}-yaml
Requires: python%{python3_pkgversion}-typing-extensions
%else
Requires: python%{python3_pkgversion}-PyYAML
%endif
Expand All @@ -372,12 +387,6 @@ Requires: python%{python3_pkgversion}-lxml
Requires: python%{python3_pkgversion}-requests
Requires: python%{python3_pkgversion}-setuptools
Requires: python%{python3_pkgversion}-xmltodict
%if 0%{?rhel} || 0%{?fedora}
Requires: (python%{python3_pkgversion}-typing-extensions if python%{python3_pkgversion} < 3.8)
%endif
%if 0%{?suse_version}
Requires: (python%{python3_pkgversion}-typing_extensions if python%{python3_pkgversion} < 3.8)
%endif
%if ! (0%{?rhel} && 0%{?rhel} < 8)
Recommends: kiwi-man-pages
%endif
Expand Down Expand Up @@ -601,17 +610,23 @@ Group: %{sysgroup}
Provides manual pages to describe the kiwi commands

%prep
%setup -q -n kiwi-%{version}
%autosetup -n kiwi-%{version}

# Drop shebang for kiwi/xml_parse.py, as we don't intend to use it
# as an independent script
sed -e "s|#!/usr/bin/env python||" -i kiwi/xml_parse.py

# 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 application
python3 -m installer --destdir %{buildroot} %{?is_deb:--no-compile-bytecode} dist/*.whl

# Install C-Tools, man-pages, completion and kiwi default configuration
# Install man-pages, completion and kiwi default configuration
make buildroot=%{buildroot}/ install

# Install dracut modules
Expand Down
109 changes: 109 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[tool.poetry]
name = "kiwi"
version = "10.0.0"
description = "KIWI - Appliance Builder"
license = "GPL-3.0-or-later"
readme = "README.rst"
homepage = "https://osinside.github.io/kiwi/"
documentation = "https://osinside.github.io/kiwi/"
repository = "https://github.com/OSInside/kiwi"

authors = [
"Marcus Schäfer <marcus.schaefer@suse.com>",
]
maintainers = [
"Marcus Schäfer <marcus.schaefer@suse.com>",
"David Cassany Viladomat <dcassany@suse.com>",
"Neal Gompa <neal@gompa.dev>",
"Dan Čermák <dcermak@suse.com>",
]

packages = [
{ include = "kiwi"},
]

include = [
{ path = ".bumpversion.cfg", format = "sdist" },
{ path = ".coverage*", format = "sdist" },
{ path = ".virtualenv.requirements*.txt", format = "sdist" },
{ path = "doc/source", format = "sdist" },
{ path = "doc/Makefile", format = "sdist" },
{ path = "dracut", format = "sdist" },
{ path = "helper", format = "sdist" },
{ path = "kiwi.yml", format = "sdist" },
{ path = "Makefile", format = "sdist" },
{ path = "package", format = "sdist" },
{ path = "test", format = "sdist" },
{ path = "tox.ini", 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/issues"

[tool.poetry.dependencies]
python = "^3.9"
docopt = ">=0.6.2"
lxml = ">=4.6.0"
requests = ">=2.25.0"
PyYAML = ">=5.4.0"
setuptools = ">=50"
simplejson = ">=3.17.0"

# Optional dependencies for markup extra
anymarkup-core = { version = ">=0.8.0", optional = true }
xmltodict = { version = ">=0.12.0", optional = true }

[tool.poetry.extras]
markup = [ "anymarkup-core", "xmltodict" ]

[tool.poetry.plugins]
[tool.poetry.plugins."kiwi.tasks"]
image_info = "kiwi.tasks.image_info"
image_resize = "kiwi.tasks.image_resize"
result_bundle = "kiwi.tasks.result_bundle"
result_list = "kiwi.tasks.result_list"
system_build = "kiwi.tasks.system_build"
system_create = "kiwi.tasks.system_create"
system_prepare = "kiwi.tasks.system_prepare"
system_update = "kiwi.tasks.system_update"

[tool.poetry.scripts]
kiwi-ng = "kiwi.kiwi:main"

[tool.poetry.group.test]
[tool.poetry.group.test.dependencies]
# python unit testing framework
pytest = ">=6.2.0"
pytest-cov = "*"
pytest-xdist = "*"
pytest-container = "*"
# type checking
mypy = ">=0.971"
types-pkg_resources = "*"
types-requests = "*"
types-PyYAML = "*"
types-mock = "*"
types-simplejson = "*"

[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 = "*"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Loading

0 comments on commit c03d1b0

Please sign in to comment.