Skip to content

Commit 21e8607

Browse files
authored
Merge pull request #11 from OSInside/move_to_poetry
Move to poetry
2 parents 126c79b + d3a1892 commit 21e8607

14 files changed

+174
-267
lines changed

.bumpversion.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ current_version = 1.0.10
33
commit = True
44
tag = True
55

6+
[bumpversion:file:pyproject.toml]
7+
68
[bumpversion:file:kiwi_stackbuild_plugin/version.py]
79

810
[bumpversion:file:doc/source/conf.py]

.github/workflows/ci-publish-to-pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
- name: Install
2929
run: |
3030
python -m pip install --upgrade pip
31-
python -m pip install tox
31+
python -m pip install poetry
3232
- name: Prepare
3333
run: |
34-
tox -e doc,release
34+
make prepare_for_pypi
3535
- name: Publish
3636
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/ci-testing.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1616

1717
steps:
1818
- uses: actions/checkout@v3
1919
- name: Python${{ matrix.python-version }}
2020
uses: actions/setup-python@v4
2121
with:
2222
python-version: ${{ matrix.python-version }}
23-
- name: Install
23+
- name: Install Poetry
2424
run: |
2525
python -m pip install --upgrade pip
26-
python -m pip install tox
27-
- name: Tox
26+
python -m pip install poetry
27+
- name: Run unit and type tests
2828
run: |
29-
tox
29+
make check test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# Poetry
132+
poetry.lock

.virtualenv.dev-requirements.txt

Lines changed: 0 additions & 34 deletions
This file was deleted.

.virtualenv.requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

MANIFEST.in

Lines changed: 0 additions & 18 deletions
This file was deleted.

Makefile

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,45 @@ version := $(shell \
99
'from kiwi_stackbuild_plugin.version import __version__; print(__version__)'\
1010
)
1111

12-
tox:
13-
tox
14-
1512
install:
1613
# install plugin manual page and license/readme
1714
# NOTE: this file is not handled through pip because on system level
1815
install -d -m 755 ${buildroot}usr/share/man/man8
1916
gzip -f doc/build/man/kiwi::system::stackbuild.8
17+
gzip -f doc/build/man/kiwi::system::stash.8
2018
install -m 644 doc/build/man/kiwi::system::stackbuild.8.gz \
2119
${buildroot}usr/share/man/man8
20+
install -m 644 doc/build/man/kiwi::system::stash.8.gz \
21+
${buildroot}usr/share/man/man8
2222
install -d -m 755 ${buildroot}${docdir}/python-kiwi_stackbuild_plugin
2323
install -m 644 LICENSE \
2424
${buildroot}${docdir}/python-kiwi_stackbuild_plugin/LICENSE
2525
install -m 644 README.rst \
2626
${buildroot}${docdir}/python-kiwi_stackbuild_plugin/README
2727

28-
build: clean tox
29-
# create setup.py variant for rpm build.
30-
# delete module versions from setup.py for building an rpm
31-
# the dependencies to the python module rpm packages is
32-
# managed in the spec file
33-
sed -ie "s@>=[0-9.]*'@'@g" setup.py
28+
setup:
29+
poetry install --all-extras
30+
31+
docs: setup
32+
poetry run make -C doc man
33+
34+
check: setup
35+
# python flake tests
36+
poetry run flake8 --statistics -j auto --count kiwi_stackbuild_plugin
37+
poetry run flake8 --statistics -j auto --count test/unit
38+
39+
test: setup
40+
# python static code checks
41+
poetry run mypy kiwi_stackbuild_plugin
42+
# unit tests
43+
poetry run bash -c 'pushd test/unit && pytest -n 5 \
44+
--doctest-modules --no-cov-on-fail --cov=kiwi_stackbuild_plugin \
45+
--cov-report=term-missing --cov-fail-under=100 \
46+
--cov-config .coveragerc'
47+
48+
build: clean check test
3449
# build the sdist source tarball
35-
$(python) setup.py sdist
36-
# restore original setup.py backed up from sed
37-
mv setup.pye setup.py
50+
poetry build --format=sdist
3851
# provide rpm source tarball
3952
mv dist/kiwi_stackbuild_plugin-${version}.tar.gz \
4053
dist/python-kiwi-stackbuild-plugin.tar.gz
@@ -52,10 +65,12 @@ build: clean tox
5265
# provide rpm rpmlintrc
5366
cp package/python-kiwi_stackbuild_plugin-rpmlintrc dist
5467

55-
pypi: clean tox
56-
$(python) setup.py sdist upload
68+
prepare_for_pypi: clean setup
69+
# sdist tarball, the actual publishing happens via the
70+
# ci-publish-to-pypi.yml github action
71+
poetry build --format=sdist
5772

5873
clean:
59-
$(python) setup.py clean
74+
rm -rf dist
6075
rm -rf doc/build
61-
rm -rf dist/*
76+
rm -rf doc/dist

doc/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
extensions = [
2121
'sphinx.ext.extlinks',
2222
'sphinx.ext.viewcode',
23-
'sphinx.ext.intersphinx'
2423
]
2524

2625
# Add any paths that contain templates here, relative to this directory.

package/python-kiwi_stackbuild_plugin-spec-template

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,36 @@ Summary: KIWI - Stack Build Plugin
5959
License: GPL-3.0-or-later
6060
%if "%{_vendor}" == "debbuild"
6161
# Needed to set Maintainer in output debs
62-
Packager: Marcus Schaefer <ms@suse.de>
62+
Packager: Marcus Schaefer <marcus.schaefer@suse.de>
6363
%endif
6464
Group: %{pygroup}
6565
Source: python-kiwi-stackbuild-plugin.tar.gz
6666
Source1: %{name}-rpmlintrc
6767
BuildRoot: %{_tmppath}/%{name}-%{version}-build
6868
BuildRequires: python%{python3_pkgversion}-%{develsuffix}
69-
BuildRequires: python%{python3_pkgversion}-setuptools
69+
BuildRequires: python%{python3_pkgversion}-build
70+
BuildRequires: python%{python3_pkgversion}-installer
71+
BuildRequires: python%{python3_pkgversion}-poetry-core >= 1.2.0
72+
BuildRequires: python%{python3_pkgversion}-wheel
73+
# doc build requirements
74+
%if ! (0%{?fedora} >= 41 || 0%{?rhel} >= 10)
75+
BuildRequires: python%{python3_pkgversion}-docopt >= 0.6.2
76+
%else
77+
BuildRequires: python%{python3_pkgversion}-docopt-ng
78+
%endif
79+
%if 0%{?suse_version}
80+
BuildRequires: python%{python3_pkgversion}-Sphinx
81+
%else
82+
BuildRequires: python%{python3_pkgversion}-sphinx
83+
%endif
84+
%if 0%{?debian} || 0%{?ubuntu}
85+
BuildRequires: python%{python3_pkgversion}-sphinx-rtd-theme
86+
%else
87+
BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme
88+
%endif
89+
%if 0%{?fedora} || 0%{?suse_version}
7090
BuildRequires: fdupes
91+
%endif
7192
BuildArch: noarch
7293

7394
%description
@@ -79,9 +100,9 @@ image root directory
79100
%package -n python%{python3_pkgversion}-kiwi_stackbuild_plugin
80101
Summary: KIWI - Stack Build Plugin
81102
Group: Development/Languages/Python
103+
Requires: python%{python3_pkgversion} >= 3.9
82104
Requires: python%{python3_pkgversion}-docopt
83105
Requires: python%{python3_pkgversion}-kiwi >= 9.21.21
84-
Requires: python%{python3_pkgversion}-setuptools
85106

86107
%description -n python%{python3_pkgversion}-kiwi_stackbuild_plugin
87108
KIWI plugin to build images using a container layer as the rootfs
@@ -91,13 +112,27 @@ image root directory
91112
%prep
92113
%setup -q -n kiwi_stackbuild_plugin-%{version}
93114

94-
%build
95-
# Build Python 3 version
96-
%{__python3} setup.py build
115+
# Temporarily switch things back to docopt for everything but Fedora 41+
116+
# FIXME: Drop this hack as soon as we can...
117+
%if ! (0%{?fedora} >= 41 || 0%{?rhel} >= 10)
118+
sed -e 's/docopt-ng.*/docopt = ">=0.6.2"/' -i pyproject.toml
119+
%endif
120+
121+
# Build documentation
122+
make -C doc man
123+
124+
# Build application wheel
125+
%{__python3} -m build --no-isolation --wheel
97126

98127
%install
99-
# Install Python 3 version
100-
%{__python3} setup.py install --prefix=%{_prefix} --root=%{buildroot} %{?is_deb:--install-layout=deb}
128+
# Install plugin
129+
%{__python3} -m installer --destdir %{buildroot} %{?is_deb:--no-compile-bytecode} dist/*.whl
130+
131+
%if 0%{?is_deb}
132+
# Fix where files were installed
133+
mv %{buildroot}%{_prefix}/local/* %{buildroot}%{_prefix}
134+
mv %{buildroot}%{_prefix}/lib/python3* %{buildroot}%{_prefix}/lib/python3
135+
%endif
101136

102137
# Install man pages and package documentation
103138
make buildroot=%{buildroot}/ docdir=%{_defaultdocdir}/ install

0 commit comments

Comments
 (0)