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 authored and schaefi committed Mar 6, 2024
1 parent 896a19e commit 7125211
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 263 deletions.
2 changes: 2 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ current_version = 10.0.0
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:kiwi/version.py]

[bumpversion:file:doc/source/conf.py]
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ var/
.installed.cfg
*.egg

# Poetry
poetry.lock

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
4 changes: 2 additions & 2 deletions .virtualenv.dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

-r .virtualenv.requirements.txt

# setuptools for pypi upload
setuptools
# poetry for building/installing/upload
poetry

# virtualenv-based automation of test activities
tox
Expand Down
15 changes: 10 additions & 5 deletions .virtualenv.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

# Shell interface for docopt, the command-line interface description language
docopt
docopt-ng

# Powerful and Pythonic XML processing library
lxml
Expand All @@ -14,17 +14,22 @@ PyYAML
# TOML file parsing
toml

# Python wrapper for extended filesystem attributes
xattr==0.9.3

# Network request/response library
requests

# markup support
anymarkup-core
xmltodict

# provides pkg_resources
setuptools

# json support that also knows about tuples
simplejson

typing_extensions; python_version < '3.8'
# TOML file parsing
toml

# markup support
anymarkup-core
xmltodict
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
12 changes: 9 additions & 3 deletions package/python-kiwi-pkgbuild-template
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@ pkgrel=0
pkgdesc="KIWI - Appliance Builder Next Generation"
url="https://github.com/SUSE/kiwi/tarball/master"
license=('GPL3')
makedepends=(python-setuptools gcc shadow grep)
makedepends=(make gcc python-build python-docopt python-installer python-lxml python-poetry-core python-requests python-setuptools python-simplejson python-sphinx python-sphinx_rtd_theme python-wheel python-yaml shadow grep)
provides=(kiwi-ng kiwi)
source=("${pkgname}.tar.gz")
changelog="${pkgname}.changes"
md5sums=('%%MD5SUM')


build() {
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
cd kiwi-${pkgver}
python setup.py build
# Temporarily switch things back to docopt
# FIXME: Drop this hack as soon as we can...
sed -e "s/docopt-ng/docopt/" -i pyproject.toml
make -C doc man
python3 -m build --no-isolation --wheel
}

package_python-kiwi(){
depends=(python-docopt python-simplejson python-lxml python-requests python-setuptools python-yaml grub qemu squashfs-tools gptfdisk pacman e2fsprogs xfsprogs btrfs-progs libisoburn lvm2 mtools parted multipath-tools rsync tar shadow screen kiwi-man-pages)
optdepends=('gnupg: keyring creation for APT package manager')
cd kiwi-${pkgver}
python setup.py install --root="${pkgdir}/" --optimize=1 --skip-build
python3 -m installer --destdir "${pkgdir}/" dist/*.whl
ln -sr "${pkgdir}/usr/bin/kiwi-ng" "${pkgdir}/usr/bin/kiwi"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
Expand Down
Loading

0 comments on commit 7125211

Please sign in to comment.