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

Switch to pyproject.toml #2413

Closed
wants to merge 1 commit into from
Closed
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 @@ -6,3 +6,5 @@ tag = True
[bumpversion:file:kiwi/version.py]

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

[bumpversion:file:kiwi/pyproject.toml]
2 changes: 2 additions & 0 deletions .virtualenv.dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# setuptools for pypi upload
setuptools
build
installer

# virtualenv-based automation of test activities
tox
Expand Down
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ include tox.ini
include kiwi.yml

recursive-include doc/build/man *
recursive-include *.gz *.iso *.kiwi *.pf2 *.py *.txt *.xml *.xz

include .bumpversion.cfg
include .coverage*

include .virtualenv.requirements.txt
include .virtualenv.dev-requirements.txt

global-exclude *.py[cod] __pycache__
global-exclude */__pycache__/*
30 changes: 8 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,13 @@ valid:
fi \
done

git_attributes:
build: clean tox
# remove wheel from tox run
rm -f dist/*.whl
# the following is required to update the $Format:%H$ git attribute
# for details on when this target is called see setup.py
git archive HEAD kiwi/version.py | tar -x

clean_git_attributes:
# cleanup version.py to origin state
# for details on when this target is called see setup.py
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
$(python) -m build --sdist
# provide rpm source tarball
mv dist/kiwi-${version}.tar.gz dist/python-kiwi.tar.gz
# append PDF documentation to tarball
Expand All @@ -131,12 +118,11 @@ build: clean tox
-e s"@%%MD5SUM@$${md5sums}@" > dist/PKGBUILD
# provide rpm rpmlintrc
cp package/python-kiwi-rpmlintrc dist
# restore local changes
git checkout kiwi/version.py

pypi: clean tox
$(python) setup.py sdist upload

clean: clean_git_attributes
$(python) setup.py clean
clean:
rm -rf dist
rm -rf doc/build
rm -rf doc/dist
${MAKE} -C tools clean
30 changes: 28 additions & 2 deletions package/python-kiwi-spec-template
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ 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} >= 1650 || 0%{?debian} || 0%{?ubuntu}
BuildRequires: python%{python3_pkgversion}-installer
BuildRequires: python%{python3_pkgversion}-build
BuildRequires: python%{python3_pkgversion}-wheel
%endif
%if 0%{?fedora} || 0%{?suse_version}
BuildRequires: fdupes
%endif
Expand All @@ -69,6 +74,23 @@ BuildRequires: shadow
%if 0%{?debian} || 0%{?ubuntu}
BuildRequires: passwd
%endif
%if 0%{?ubuntu} || 0%{?debian}
BuildRequires: python%{python3_pkgversion}-yaml
BuildRequires: python%{python3_pkgversion}-typing-extensions
%else
BuildRequires: python%{python3_pkgversion}-PyYAML
%endif
BuildRequires: python%{python3_pkgversion}-simplejson
BuildRequires: python%{python3_pkgversion}-docopt
BuildRequires: python%{python3_pkgversion}-lxml
BuildRequires: python%{python3_pkgversion}-requests
BuildRequires: python%{python3_pkgversion}-setuptools
%if 0%{?rhel} || 0%{?fedora}
BuildRequires: (python%{python3_pkgversion}-typing-extensions if python%{python3_pkgversion} < 3.8)
%endif
%if 0%{?suse_version}
BuildRequires: (python%{python3_pkgversion}-typing_extensions if python%{python3_pkgversion} < 3.8)
%endif

%description
The KIWI Image System provides an operating system image builder
Expand Down Expand Up @@ -625,9 +647,13 @@ sed -e "s|#!/usr/bin/env python||" -i kiwi/xml_parse.py
# Build C-Tools
make CFLAGS="${RPM_OPT_FLAGS}" tools

# Build wheel, skip on failure
python3 -m build --no-isolation --wheel || true

%install
# Install Python 3 version
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot} %{?is_deb:--install-layout=deb}
# Install Python 3 version from wheel, use setup.py as fallback
python3 -m installer --destdir %{buildroot} dist/*.whl || \
python3 setup.py install --prefix=%{_prefix} --root=%{buildroot} %{?is_deb:--install-layout=deb}

# Install C-Tools, man-pages, completion and kiwi default configuration
make buildroot=%{buildroot}/ install
Expand Down
37 changes: 37 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[project]
name = "kiwi"
version = "9.25.21"
authors = [
{ name="Marcus Schäfer", email="[email protected]" },
]
description = "KIWI - Appliance Builder"
readme = "README.rst"
requires-python = ">=3.7"
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',
'Topic :: System :: Operating System',
]
dynamic = [
"license",
"entry-points",
"scripts"
]
[build-system]
requires = [
"docopt",
"lxml",
"requests",
"PyYAML",
"simplejson",
'typing_extensions; python_version<"3.8"',
"setuptools"
]
[project.urls]
"Homepage" = "https://osinside.github.io/kiwi"
"Bug Tracker" = "https://github.com/OSInside/kiwi/issues"
108 changes: 35 additions & 73 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,51 @@

from os import path
from setuptools import setup
from setuptools.command import sdist as setuptools_sdist

import distutils
import subprocess

from kiwi.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()


class sdist(setuptools_sdist.sdist):
"""
Custom sdist command
Host requirements: git
"""
def run(self):
"""
Run first the git commit format update $Format:%H$
and after that the usual Python sdist
"""
# git attributes
command = ['make', 'git_attributes']
self.announce(
'Running make git_attributes target: %s' % str(command),
level=distutils.log.INFO
)
self.announce(
subprocess.check_output(command).decode(),
level=distutils.log.INFO
)

# standard sdist process
setuptools_sdist.sdist.run(self)

# cleanup attributes
command = ['make', 'clean_git_attributes']
self.announce(
subprocess.check_output(command).decode(),
level=distutils.log.INFO
)


config = {
'name': 'kiwi',
'long_description': long_description,
'long_description_content_type': 'text/x-rst',
'python_requires': '>=3.6',
'description': 'KIWI - Appliance Builder (next generation)',
'author': 'Marcus Schaefer',
'url': 'https://osinside.github.io/kiwi',
'download_url':
'https://download.opensuse.org/repositories/'
'Virtualization:/Appliances:/Builder',
'author_email': '[email protected]',
'version': __version__,
'license' : 'GPLv3+',
'install_requires': [
'docopt>=0.6.2',
'lxml',
'requests',
'PyYAML',
'simplejson',
'typing_extensions; python_version < "3.8"',
'packages': [
'kiwi',
'kiwi.boot',
'kiwi.utils',
'kiwi.container.setup',
'kiwi.markup',
'kiwi.archive',
'kiwi.bootloader',
'kiwi.boot.image',
'kiwi.bootloader.template',
'kiwi.bootloader.install',
'kiwi.bootloader.config',
'kiwi.builder',
'kiwi.container',
'kiwi.filesystem',
'kiwi.package_manager',
'kiwi.partitioner',
'kiwi.repository',
'kiwi.repository.template',
'kiwi.schema',
'kiwi.storage',
'kiwi.storage.subformat',
'kiwi.storage.subformat.template',
'kiwi.system',
'kiwi.system.root_import',
'kiwi.volume_manager',
'kiwi.xsl',
'kiwi.schema',
'kiwi.config',
'kiwi.tasks',
'kiwi.solver',
'kiwi.solver.repository',
'kiwi.iso_tools',
'kiwi.oci_tools'
],
'packages': ['kiwi'],
'cmdclass': {
'sdist': sdist
},
'entry_points': {
'kiwi.tasks': [
'image_info=kiwi.tasks.image_info',
Expand All @@ -88,20 +63,7 @@ def run(self):
'kiwi-ng=kiwi.kiwi:main',
'kiwicompat=kiwi.kiwi_compat:main'
]
},
'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.7',
'Topic :: System :: Operating System',
]
}
}

setup(**config)
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ passenv =
deps = {[testenv]deps}
changedir=test/unit
commands =
bash -c 'cd ../../ && ./setup.py develop'
bash -c 'cd ../../ && test -e dist/*.whl || python -m build --wheel'
bash -c 'cd ../../ && test -e $VIRTUAL_ENV/bin/kiwi-ng || python -m installer dist/*.whl'
bash -c 'cd ../../ && mypy kiwi'
pytest --doctest-modules --no-cov-on-fail --cov=kiwi \
--cov-report=term-missing --cov-fail-under=100 \
Expand Down Expand Up @@ -214,7 +215,7 @@ deps = {[testenv]deps}
skip_install = True
usedevelop = True
commands =
python setup.py sdist
python -m build


[testenv:scripts]
Expand Down
Loading