Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to poetry #82

Merged
merged 3 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 0.2.45
commit = True
tag = True

[bumpversion:file:pyproject.toml]

[bumpversion:file:kiwi_boxed_plugin/version.py]

[bumpversion:file:doc/source/conf.py]
4 changes: 2 additions & 2 deletions .github/workflows/ci-publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ 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
- name: Python${{ matrix.python-version }}
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ doc/xml/

# VSC
.vscode/

# Poetry
poetry.lock
38 changes: 0 additions & 38 deletions .virtualenv.dev-requirements.txt

This file was deleted.

21 changes: 0 additions & 21 deletions .virtualenv.requirements.txt

This file was deleted.

20 changes: 0 additions & 20 deletions MANIFEST.in

This file was deleted.

44 changes: 28 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ version := $(shell \
'from kiwi_boxed_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
Expand All @@ -25,16 +22,29 @@ install:
install -m 644 README.rst \
${buildroot}${docdir}/python-kiwi_boxed_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_boxed_plugin
poetry run flake8 --statistics -j auto --count test/unit

test: setup
# python static code checks
poetry run mypy kiwi_boxed_plugin
# unit tests
poetry run bash -c 'pushd test/unit && pytest -n 5 \
--doctest-modules --no-cov-on-fail --cov=kiwi_boxed_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_boxed_plugin-${version}.tar.gz \
dist/python-kiwi-boxed-plugin.tar.gz
Expand All @@ -52,10 +62,12 @@ build: clean tox
# provide rpm rpmlintrc
cp package/python-kiwi_boxed_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
7 changes: 6 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
# -- General configuration ------------------------------------------------

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.extlinks',
'sphinx.ext.todo',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx'
'sphinx.ext.autodoc',
'sphinx_rtd_theme'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
4 changes: 2 additions & 2 deletions kiwi_boxed_plugin/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def get_plugin_config_file() -> str:
config_name = "kiwi_boxed_plugin.yml"

# 1.
config_path_env: str | None = os.environ.get("KIWI_BOXED_PLUGIN_CFG")
if config_path_env is not None and os.path.exists(config_path_env):
config_path_env: str = os.environ.get("KIWI_BOXED_PLUGIN_CFG") or ''
if config_path_env and os.path.exists(config_path_env):
return config_path_env

# 2.
Expand Down
57 changes: 48 additions & 9 deletions package/python-kiwi_boxed_plugin-spec-template
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,40 @@ Summary: KIWI - Boxed Build Plugin
License: GPL-3.0-or-later
%if "%{_vendor}" == "debbuild"
# Needed to set Maintainer in output debs
Packager: Marcus Schaefer <ms@suse.de>
Packager: Marcus Schaefer <marcus.schaefer@suse.com>
%endif
Group: %{pygroup}
Source: python-kiwi-boxed-plugin.tar.gz
Source1: %{name}-rpmlintrc
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Main build requirements
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
BuildRequires: python%{python3_pkgversion}-requests
%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
BuildRequires: python%{python3_pkgversion}-yaml
%else
BuildRequires: python%{python3_pkgversion}-sphinx_rtd_theme
BuildRequires: python%{python3_pkgversion}-PyYAML
%endif
%if 0%{?fedora} || 0%{?suse_version}
BuildRequires: fdupes
%endif
BuildArch: noarch

%description
Expand All @@ -77,11 +102,11 @@ of images based on fast booting VM images
# python3-kiwi_boxed_plugin
%package -n python%{python3_pkgversion}-kiwi_boxed_plugin
Summary: KIWI - Boxed Build Plugin
Group: Development/Languages/Python
Group: %{pygroup}
Requires: python%{python3_pkgversion} >= 3.9
Requires: python%{python3_pkgversion}-docopt
Requires: python%{python3_pkgversion}-kiwi >= 9.21.21
Requires: python%{python3_pkgversion}-requests
Requires: python%{python3_pkgversion}-setuptools
Requires: python%{python3_pkgversion}-progressbar2
%if 0%{?ubuntu} || 0%{?debian}
Requires: python%{python3_pkgversion}-yaml
Expand All @@ -104,13 +129,27 @@ of images based on fast booting VM images
%prep
%setup -q -n kiwi_boxed_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
schaefi marked this conversation as resolved.
Show resolved Hide resolved

%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
Expand Down
Loading
Loading