Compare commits

..

No commits in common. "c9-beta" and "c9s" have entirely different histories.
c9-beta ... c9s

55 changed files with 2119 additions and 0 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
__pycache__/

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -0,0 +1,8 @@
# this dependency is on purpose
addFilter(r'devel-dependency python3-devel')
# RPM macros, this is expected
addFilter(r'only-non-binary-in-usr-lib')
# spelling errors
addFilter(r'spelling-error .* en_US (toml|setuptools) ')

7
rpminspect.yaml Normal file
View File

@ -0,0 +1,7 @@
# completely disabled inspections:
inspections:
# there is no upstream and we regularly change all files
addedfiles: off
changedfiles: off
filesize: off
upstream: off

0
sources Normal file
View File

View File

@ -0,0 +1,50 @@
Name: config-settings-test
Version: 1.0.0
Release: 1%{?dist}
Summary: Test config_settings support
License: MIT
URL: ...
Source0: config_settings_test_backend.py
%description
%{summary}.
%prep
%autosetup -cT
cp -p %{sources} .
cat <<'EOF' >config_settings.py
"""
This is a test package
"""
EOF
cat <<'EOF' >pyproject.toml
[build-system]
build-backend = "config_settings_test_backend"
backend-path = ["."]
requires = ["flit-core", "packaging", "pip"]
[project]
name = "config_settings"
version = "%{version}"
dynamic = ["description"]
EOF
%generate_buildrequires
%pyproject_buildrequires -C abc=123 -C xyz=456 -C--option-with-dashes=1 -C--option-with-dashes=2
%{!?el9:%pyproject_buildrequires -C abc=123 -C xyz=456 -C--option-with-dashes=1 -C--option-with-dashes=2 -w}
%build
%{!?el9:%pyproject_wheel -C abc=123 -C xyz=456 -C--option-with-dashes=1 -C--option-with-dashes=2}
%changelog
* Fri May 19 2023 Maxwell G <maxwell@gtmx.me>
- Initial package

View File

@ -0,0 +1,40 @@
"""
This is a test backend for pyproject-rpm-macros' integration tests
It is not compliant with PEP 517 and omits some required hooks.
"""
from flit_core import buildapi
from packaging.version import parse
from pip import __version__ as pip_version
EXPECTED_CONFIG_SETTINGS = [{"abc": "123", "xyz": "456", "--option-with-dashes": ["1", "2"]}]
# Older pip did not accept multiple values,
# but we might backport that later,
# hence we accept it both ways with older pips
if parse(pip_version) < parse("23.1"):
EXPECTED_CONFIG_SETTINGS.append(
EXPECTED_CONFIG_SETTINGS[0] | {"--option-with-dashes": "2"}
)
def _verify_config_settings(config_settings):
print(f"config_settings={config_settings}")
if config_settings not in EXPECTED_CONFIG_SETTINGS:
raise ValueError(
f"{config_settings!r} does not match expected {EXPECTED_CONFIG_SETTINGS!r}"
)
def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
_verify_config_settings(config_settings)
return buildapi.build_wheel(wheel_directory, None, metadata_directory)
def get_requires_for_build_wheel(config_settings=None):
_verify_config_settings(config_settings)
return buildapi.get_requires_for_build_wheel(None)
def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
_verify_config_settings(config_settings)
return buildapi.prepare_metadata_for_build_wheel(metadata_directory, None)

71
tests/double-install.spec Normal file
View File

@ -0,0 +1,71 @@
Name: double-install
Version: 0
Release: 0%{?dist}
Summary: Install 2 wheels
License: BSD and MIT
%global markupsafe_version 2.0.1
%global tldr_version 0.4.4
Source1: https://github.com/pallets/markupsafe/archive/%{markupsafe_version}/MarkupSafe-%{markupsafe_version}.tar.gz
Source2: %{pypi_source tldr %{tldr_version}}
BuildRequires: gcc
BuildRequires: python3-devel
%description
This package tests that we can build and install 2 wheels at once.
One of them is "noarch" and one has an extension module.
%prep
%setup -Tc
tar xf %{SOURCE1}
tar xf %{SOURCE2}
%generate_buildrequires
cd markupsafe-%{markupsafe_version}
%pyproject_buildrequires -R
cd ../tldr-%{tldr_version}
%pyproject_buildrequires -R
cd ..
%build
cd markupsafe-%{markupsafe_version}
%pyproject_wheel
cd ../tldr-%{tldr_version}
%pyproject_wheel
cd ..
%install
# This should install both the wheels:
%pyproject_install
#pyproject_save_files is not possible with 2 dist-infos
%check
# Internal check for the value of %%{pyproject_build_lib}
%if 0%{?rhel} == 9
for dir in . markupsafe-%{markupsafe_version} tldr-%{tldr_version}; do
(cd $dir && test "%{pyproject_build_lib}" == "$(echo %{_pyproject_builddir}/pip-req-build-*/build/lib.%{python3_platform}-%{python3_version}):$(echo %{_pyproject_builddir}/pip-req-build-*/build/lib)")
done
%else
cd markupsafe-%{markupsafe_version}
%if 0%{?fedora} == 36
test "%{pyproject_build_lib}" == "%{_builddir}/%{buildsubdir}/markupsafe-%{markupsafe_version}/build/lib.%{python3_platform}-%{python3_version}"
%else
test "%{pyproject_build_lib}" == "%{_builddir}/%{buildsubdir}/markupsafe-%{markupsafe_version}/build/lib.%{python3_platform}-cpython-%{python3_version_nodots}"
%endif
cd ../tldr-%{tldr_version}
test "%{pyproject_build_lib}" == "%{_builddir}/%{buildsubdir}/tldr-%{tldr_version}/build/lib"
cd ..
%endif
%files
%{_bindir}/tldr*
%pycached %{python3_sitelib}/tldr.py
%{python3_sitelib}/tldr-%{tldr_version}.dist-info/
%{python3_sitearch}/MarkupSafe-%{markupsafe_version}.dist-info/
%{python3_sitearch}/markupsafe/

View File

@ -0,0 +1,65 @@
Name: escape_percentages
Version: 0.1
Release: 0
Summary: ...
License: MIT
BuildArch: noarch
%description
This spec file verifies that escaping percentage signs in paths is possible via
exactly 2 (or 8) percentage signs in a filelist and directly in the %%files section.
It serves as a regression test for pyproject_save_files:escape_rpm_path().
When this breaks, the function needs to be adapted.
%prep
cat > pyproject.toml << EOF
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
EOF
cat > setup.cfg << EOF
[metadata]
name = escape_percentages
version = 0.1
[options]
packages =
escape_percentages
[options.package_data]
escape_percentages =
*
EOF
mkdir -p escape_percentages
touch escape_percentages/__init__.py
# the paths on disk will have 1 percentage sign if we type 2 in the spec
# we use the word 'version' after the sign, as that is a known existing macro
touch 'escape_percentages/one%%version'
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -L escape_percentages
touch '%{buildroot}/two%%version'
%check
grep '/escape_percentages/one' %{pyproject_files}
%files -f %{pyproject_files}
%if v"0%{?rpmversion}" >= v"4.18.90"
/two%%version
%else
/two%%%%%%%%version
%endif

View File

@ -0,0 +1,30 @@
Name: fake-requirements
Version: 0
Release: 0%{?dist}
Summary: ...
License: MIT
BuildRequires: pyproject-rpm-macros
%description
Fake spec file to test %%pyproject_buildrequires -N works as expected
%prep
cat > requirements.txt <<EOF
click!=5.0.0,>=4.1 # comment to increase test complexity
toml>=0.10.0
EOF
%generate_buildrequires
%pyproject_buildrequires requirements.txt -N
%check
pip show toml click
%if 0%{?fedora} || 0%{?rhel} > 9
# On RHEL 9, python3-devel requires (python3-setuptools if rpm-build)
pip show setuptools && exit 1 || true
%endif
pip show wheel && exit 1 || true

79
tests/mocktest.sh Executable file
View File

@ -0,0 +1,79 @@
#!/usr/bin/bash -eux
if [ -z "${VERSION_ID-}" ] && [ -z "${NAME-}" ]; then
. /etc/os-release
fi
version=$(echo "${VERSION_ID}" | cut -d. -f1)
arch="x86_64"
case $NAME in
"Fedora Linux"|"Fedora")
mock="fedora-${version}-${arch}"
repos="local"
;;
"CentOS Stream"|"Red Hat Enterprise Linux")
mock="centos-stream+epel-next-${version}-${arch}"
repos="local,local-centos-stream"
;;
*)
echo "Not supported OS" >&2
exit 1
;;
esac
pkgname=${1}
shift
config="/tmp/${mock}-ci.cfg"
# create mock config if not present
# this makes sure tested version of pyproject-rpm-macros is available
# TODO: check if it has precedence if the release was not bumped in tested PR
if [ ! -f $config ]; then
original="/etc/mock/${mock}.cfg"
cp $original $config
echo -e '\n\n' >> $config
echo -e 'config_opts["package_manager"] = "dnf"' >> $config
echo -e 'config_opts["package_manager_max_attempts"] = 10' >> $config
echo -e 'config_opts["package_manager_attempt_delay"] = 60' >> $config
echo -e '\n\nconfig_opts[f"{config_opts.package_manager}.conf"] += """' >> $config
# The zuul CI has zuul-build.repo
# The Jenkins CI has test-<pkgname>.repo
# We run this code from various packages, so we support any <pkgname>
if [ -f /etc/yum.repos.d/zuul-build.repo ]; then
cat /etc/yum.repos.d/zuul-build.repo >> $config
else
cat /etc/yum.repos.d/test-*.repo >> $config
fi
echo -e '\n"""\n' >> $config
fi
# prepare the rpmbuild folders, make sure nothing relevant is there
mkdir -p ~/rpmbuild/SRPMS
rm -f ~/rpmbuild/SRPMS/${pkgname}-*.src.rpm
# download the sources and create SRPM
spectool -g ${pkgname}.spec
rpmbuild -bs --define '_sourcedir .' ${pkgname}.spec
# build the SRPM in mock
res=0
mock --verbose --isolation=simple -r $config --enablerepo="$repos" init
mock --verbose --isolation=simple -r $config --enablerepo="$repos" "$@" ~/rpmbuild/SRPMS/${pkgname}-*.src.rpm || res=$?
# move the results to the artifacts directory, so we can examine them
artifacts=${TEST_ARTIFACTS:-/tmp/artifacts}
# on Fedora Rawhide, the directory contains "rawhide" instead of the actual version
pushd /var/lib/mock/${mock}/result || pushd /var/lib/mock/${mock/${version}/rawhide}/result
mv *.rpm ${artifacts}/ || :
for log in *.log; do
mv ${log} ${artifacts}/${pkgname}-${log}
done
popd
exit $res

54
tests/printrun.spec Normal file
View File

@ -0,0 +1,54 @@
Name: printrun
Version: 2.0.0~rc6
%global upstream_version 2.0.0rc6
Release: 0%{?dist}
Summary: RepRap printer interface and tools
License: GPLv3+ and FSFAP
URL: https://github.com/kliment/Printrun
Source0: https://github.com/kliment/Printrun/archive/%{name}-%{upstream_version}.tar.gz
# fix locale location
Patch0: https://github.com/kliment/Printrun/pull/1101.patch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
BuildRequires: gcc
%description
This package contains lang files outside of printrun module.
Building this tests that lang files are marked with %%lang in filelist.
%prep
%autosetup -p1 -n Printrun-printrun-%{upstream_version}
%generate_buildrequires
%pyproject_buildrequires -R
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l printrun +auto
%check
# Internal check if generated lang entries are same as
# the ones generated using %%find_lang
%find_lang pronterface
%find_lang plater
grep '^%%lang' %{pyproject_files} | sort > tested.lang
sort pronterface.lang plater.lang > expected.lang
diff tested.lang expected.lang
# Internal check that generated files contain nested __pycache__ directories
grep -E '/printrun/__pycache__$' %{pyproject_files}
%files -f %{pyproject_files}
%doc README*

60
tests/python-clikit.spec Normal file
View File

@ -0,0 +1,60 @@
%global pypi_name clikit
Name: python-%{pypi_name}
Version: 0.3.1
Release: 1%{?dist}
Summary: Builds beautiful and testable command line interfaces
License: MIT
URL: https://github.com/sdispater/clikit
Source0: %{pypi_source}
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
%description
Tests building with the poetry build backend.
%package -n python3-%{pypi_name}
Summary: %{summary}
%description -n python3-%{pypi_name}
%{summary}.
%prep
%autosetup -p1 -n %{pypi_name}-%{version}
%generate_buildrequires
# this runtime-requires pastel<0.2 which is no longer available in Fedora
%pyproject_buildrequires -R
%build
%pyproject_wheel
%install
# Internal check that $TMPDIR is not changed
TPMDIR_original="$TMPDIR"
%pyproject_install
# Internal check that $TMPDIR is not changed
test "$TMPDIR" == "$TPMDIR_original"
%check
# Internal check that the RECORD and REQUESTED files are
# always removed in %%pyproject_wheel
test ! $(find %{buildroot}%{python3_sitelib}/ | grep -E "\.dist-info/RECORD$")
test ! $(find %{buildroot}%{python3_sitelib}/ | grep -E "\.dist-info/REQUESTED$")
%files -n python3-%{pypi_name}
%doc README.md
%license LICENSE
%{python3_sitelib}/%{pypi_name}/
%{python3_sitelib}/%{pypi_name}-%{version}.dist-info/

View File

@ -0,0 +1,54 @@
Name: python-distroinfo
Version: 0.3.2
Release: 0%{?dist}
Summary: Parsing and querying distribution metadata stored in text/YAML files
License: ASL 2.0
URL: https://github.com/softwarefactory-project/distroinfo
Source0: %{pypi_source distroinfo}
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
BuildRequires: python3-pytest
BuildRequires: git-core
%description
This package uses setuptools and pbr.
It has setup_requires and tests that %%pyproject_buildrequires correctly
handles that including runtime requirements.
Run %%pyproject_check_import with top-level modules filtering.
%package -n python3-distroinfo
Summary: %{summary}
%description -n python3-distroinfo
...
%prep
%autosetup -p1 -n distroinfo-%{version}
# we don't need pytest-runner
sed -Ei "s/(, )?'pytest-runner'//" setup.py
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l distroinfo
%check
%pytest
%pyproject_check_import -t
%files -n python3-distroinfo -f %{pyproject_files}
%doc README.rst AUTHORS

60
tests/python-django.spec Normal file
View File

@ -0,0 +1,60 @@
Name: python-django
Version: 3.0.7
Release: 0%{?dist}
Summary: A high-level Python Web framework
License: BSD
URL: https://www.djangoproject.com/
Source0: %{pypi_source Django}
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
%description
This package contains lang files.
Building this tests that lang files are marked with %%lang in filelist.
%package -n python3-django
Summary: %{summary}
%description -n python3-django
...
%prep
%autosetup -p1 -n Django-%{version}
%py3_shebang_fix django/conf/project_template/manage.py-tpl django/bin/django-admin.py
%generate_buildrequires
%pyproject_buildrequires -R
%build
# remove .po files (in ideal world, we would rebuild the .mo files first)
find -name "*.po" | xargs rm -f
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l django
%check
# Internal check if generated lang entries are same as
# the ones generated using %%find_lang
%find_lang django
%find_lang djangojs
grep '^%%lang' %{pyproject_files} | sort > tested.lang
sort django.lang djangojs.lang > expected.lang
diff tested.lang expected.lang
%files -n python3-django -f %{pyproject_files}
%doc README.rst
%{_bindir}/django-admin
%{_bindir}/django-admin.py

View File

@ -0,0 +1,71 @@
Name: python-dns-lexicon
Version: 3.8.1
Release: 0%{?dist}
Summary: Manipulate DNS records on various DNS providers in a standardized/agnostic way
License: MIT
URL: https://github.com/AnalogJ/lexicon
Source0: %{url}/archive/v%{version}/lexicon-%{version}.tar.gz
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
# Upstream does not declare this dependency
# They dropped it later: https://github.com/AnalogJ/lexicon/issues/1240
BuildRequires: python3-pkg_resources
%description
This package has extras specified in tox configuration,
we test that the extras are installed when -e is used.
This package also uses a custom toxenv and creates several extras subpackages.
%package -n python3-dns-lexicon
Summary: %{summary}
%description -n python3-dns-lexicon
...
%pyproject_extras_subpackage -n python3-dns-lexicon plesk route53
%prep
%autosetup -n lexicon-%{version}
# The tox configuration lists a [dev] extra, but that installs nothing (is missing).
# The test requirements are only specified via poetry.dev-dependencies.
# Here we amend the data a bit so we can test more things, adding the tests deps to the dev extra:
sed -i \
's/\[tool.poetry.extras\]/'\
'pytest = {version = ">3", optional = true}\n'\
'vcrpy = {version = ">1", optional = true}\n\n'\
'[tool.poetry.extras]\n'\
'dev = ["pytest", "vcrpy"]/' pyproject.toml
%generate_buildrequires
# We use the "light" toxenv because the default one installs the [full] extra and we don't have all the deps.
# Note that [full] contains [plesk] and [route53] but we specify them manually instead:
%pyproject_buildrequires -e light -x plesk -x route53
%build
%pyproject_wheel
%install
%pyproject_install
# the license is not marked as License-File by poetry-core, hence -L
%pyproject_save_files -L lexicon
%check
# we cannot use %%tox here, because the configured commands call poetry directly :/
# we use %%pytest instead, running a subset of tests not to waste CI time
%pytest -k "test_route53 or test_plesk"
%files -n python3-dns-lexicon -f %{pyproject_files}
%license LICENSE
%doc README.rst
%{_bindir}/lexicon

View File

@ -0,0 +1,54 @@
%global pypi_name entrypoints
Name: python-%{pypi_name}
Version: 0.3
Release: 0%{?dist}
Summary: Discover and load entry points from installed packages
License: MIT
URL: https://entrypoints.readthedocs.io/
Source0: %{pypi_source}
BuildArch: noarch
%description
This package contains one .py module
Building this tests the flit build backend.
This package also has no explicit BuildRequires for python or the macros,
testing the minimal implementation of %%pyproject_buildrequires
from pyproject-srpm-macros.
%package -n python3-%{pypi_name}
Summary: %{summary}
%description -n python3-%{pypi_name}
%{summary}.
%prep
%autosetup -p1 -n %{pypi_name}-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
# the license is not marked as License-File, hence -L
%pyproject_save_files entrypoints -L
%check
# Internal check: Top level __pycache__ is never owned
grep -E '/__pycache__$' %{pyproject_files} && exit 1 || true
grep -E '/__pycache__/$' %{pyproject_files} && exit 1 || true
grep -F '/__pycache__/' %{pyproject_files}
%files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.rst
%license LICENSE

View File

@ -0,0 +1,54 @@
Name: python-flit-core
Version: 3.0.0
Release: 0%{?dist}
Summary: Distribution-building parts of Flit
License: BSD
URL: https://pypi.org/project/flit-core/
Source0: https://github.com/takluyver/flit/archive/%{version}/flit-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%description
Test a wheel built from a subdirectory.
Test a build with pyproject.toml backend-path = .
flit-core builds with flit-core.
%package -n python3-flit-core
Summary: %{summary}
%description -n python3-flit-core
...
%prep
%autosetup -p1 -n flit-%{version}
%generate_buildrequires
cd flit_core
# this runtime-requires pytoml which is no longer available in Fedora
%pyproject_buildrequires -R
cd ..
%build
cd flit_core
%pyproject_wheel
cd ..
%install
%pyproject_install
# there is no license file marked as License-File, hence not using -l
%pyproject_save_files flit_core
%check
# internal check for our macros, we assume there is no license
grep -F %%license %{pyproject_files} && exit 1 || true
%files -n python3-flit-core -f %{pyproject_files}

79
tests/python-getmac.spec Normal file
View File

@ -0,0 +1,79 @@
Name: python-getmac
Version: 0.8.3
Release: 0%{?dist}
Summary: Get MAC addresses of remote hosts and local interfaces
License: MIT
URL: https://github.com/GhostofGoes/getmac
Source0: %{pypi_source getmac}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%global _description %{expand:
Test that manpages are correctly processed by %%%%%%%%pyproject_save_files '*' +auto.
Run %%%%%%%%_pyproject_check_import_allow_no_modules twice
- exclude all modules and test the check still passes thanks to -M option
- regression test: test that check imports all modules even if -M option is set}
%description %_description
%package -n python3-getmac
Summary: %{summary}
%description -n python3-getmac %_description
%prep
%autosetup -p1 -n getmac-%{version}
%generate_buildrequires
%pyproject_buildrequires -r
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l '*' +auto
%check
# Internal check for our macros, assert the behavior of the import check macros
# Both of the macros should succeed
%pyproject_check_import
%_pyproject_check_import_allow_no_modules
(%{pyproject_check_import}) 2>pyproject_check_import.stderr
(%{_pyproject_check_import_allow_no_modules}) 2>_pyproject_check_import_allow_no_modules.stderr
# Modules were found, stderrs should include getmac.getmac
grep '^Check import: getmac\.getmac$' pyproject_check_import.stderr
grep '^Check import: getmac\.getmac$' _pyproject_check_import_allow_no_modules.stderr
# Now let's pretend no modules were found at all
echo -e '' > %{_pyproject_modules}
# This should fail
(%{pyproject_check_import}) && exit 1 || true
# This should succeed and say something about no modules found
%{_pyproject_check_import_allow_no_modules}
(%{_pyproject_check_import_allow_no_modules}) 2>_pyproject_check_import_allow_no_modules.stderr
grep '\bNo modules to check found\b' _pyproject_check_import_allow_no_modules.stderr
# We want to ensure the rest of the %%check section is still executed
# (To avoid a temptation to call `exit 0` from %%_pyproject_check_import_allow_no_modules)
# We'll touch a marker file here and assert its presence in %%files
touch %{buildroot}/check-completed-entirely
# Internal check for our macros, assert there is a manpage:
test -f %{buildroot}%{_mandir}/man1/getmac.1*
%files -n python3-getmac -f %{pyproject_files}
/check-completed-entirely

77
tests/python-httpbin.spec Normal file
View File

@ -0,0 +1,77 @@
Name: python-httpbin
Version: 0.7.0
Release: 0%{?dist}
Summary: HTTP Request & Response Service, written in Python + Flask
License: MIT
URL: https://github.com/Runscope/httpbin
Source0: %{url}/archive/v%{version}/httpbin-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%if 0%{?fedora} >= 37 || 0%{?rhel} >= 10
# Wekrzeug in Fedora 37 isn't compatible with our httpbin
Patch: https://src.fedoraproject.org/rpms/python-httpbin/raw/0e4a7e2812/f/0001-Fix-disabling-of-location-header-autocorrect-for-wer.patch
%endif
# no flask, itsdangerous, raven, werkzeug packaged for EPEL 9 yet
# cannot run tests on EPEL and also cannot BuildRequire runtime deps
%if 0%{?fedora}
%bcond_without tests
%else
%bcond_with tests
%endif
%description
This package buildrequires a package with extra: raven[flask].
%package -n python3-httpbin
Summary: %{summary}
%description -n python3-httpbin
%{summary}.
%prep
%autosetup -n httpbin-%{version} -p1
# brotlipy wrapper is not packaged, httpbin works fine with brotli
sed -i s/brotlipy/brotli/ setup.py
# update test_httpbin.py to reflect new behavior of werkzeug
sed -i /Content-Length/d test_httpbin.py
# https://github.com/postmanlabs/httpbin/issues/647
sed -Ei 's/\bdef (test_(relative_)?redirect_(to_post|n_(equals_to|higher_than)_1))/def no\1/' test_httpbin.py
%generate_buildrequires
%pyproject_buildrequires %{?with_tests:-t}%{?!with_tests:-R}
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l httpbin
%if %{with tests}
%check
%if 0%{?fedora} < 40 && 0%{?rhel} < 10
# this version of httpbin is not compatible with werkzeug 3+
%tox
%endif
# Internal check for our macros
# The runtime dependencies contain raven[flask], we assert we got them.
# The %%tox above also dies without it, but this makes it more explicit
%{python3} -c 'import blinker, flask' # transitive deps
%endif
%files -n python3-httpbin -f %{pyproject_files}
%doc README*

View File

@ -0,0 +1,56 @@
Name: python-ipykernel
Version: 6.11.0
Release: 0%{?dist}
Summary: IPython Kernel for Jupyter
License: BSD
URL: https://github.com/ipython/ipykernel
Source0: https://github.com/ipython/ipykernel/archive/v%{version}/ipykernel-%{version}.tar.gz
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
# some of the nested modules import from this, but upstream does not declare the dependency
BuildRequires: python3-ipyparallel
%description
This package contains data files.
Building this tests that data files are not listed when +auto is not used
with %%pyproject_save_files.
Run %%pyproject_check_import on installed package and exclude unwanted modules
(if they're not excluded, build fails).
- We don't want to pull test dependencies just to check import
- The others fail to find `gi` and `matplotlib` which weren't declared
in the upstream metadata
%package -n python3-ipykernel
Summary: %{summary}
%description -n python3-ipykernel
...
%prep
%autosetup -p1 -n ipykernel-%{version}
# Remove the dependency on debugpy.
# See https://github.com/ipython/ipykernel/pull/767
sed -i '/"debugpy/d' pyproject.toml setup.py
%generate_buildrequires
%pyproject_buildrequires -r
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l 'ipykernel*' +auto
%check
%pyproject_check_import -e '*.test*' -e 'ipykernel.gui*' -e 'ipykernel.pylab.*' -e 'ipykernel.trio*'
%files -n python3-ipykernel -f %{pyproject_files}
%doc README.md

125
tests/python-isort.spec Normal file
View File

@ -0,0 +1,125 @@
%global modname isort
Name: python-%{modname}
Version: 4.3.21
Release: 7%{?dist}
Summary: Python utility / library to sort Python imports
License: MIT
URL: https://github.com/timothycrosley/%{modname}
Source0: %{url}/archive/%{version}-2/%{modname}-%{version}-2.tar.gz
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
%description
This package contains executables.
Building this tests that executables are not listed when +auto is not used
with %%pyproject_save_files.
This package also uses %%{python3_pkgversion} in name and has a very limited
set of dependencies -- allows to set a different value for it repeatedly.
%package -n python%{python3_pkgversion}-%{modname}
Summary: %{summary}
%description -n python%{python3_pkgversion}-%{modname}
%{summary}.
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%package -n python%{python3_pkgversion}-%{modname}
Summary: %{summary}
%description -n python%{python3_pkgversion}-%{modname}
%{summary}.
%global python3_pkgversion 3.12
%package -n python%{python3_pkgversion}-%{modname}
Summary: %{summary}
%description -n python%{python3_pkgversion}-%{modname}
%{summary}.
%global python3_pkgversion 3
%endif
%prep
%autosetup -n %{modname}-%{version}-2
%generate_buildrequires
%pyproject_buildrequires
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%pyproject_buildrequires
%global python3_pkgversion 3.12
%pyproject_buildrequires
%global python3_pkgversion 3
%endif
%build
%pyproject_wheel
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%pyproject_wheel
%global python3_pkgversion 3.12
%pyproject_wheel
%global python3_pkgversion 3
%endif
%install
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%pyproject_install
%pyproject_save_files -l isort
%global python3_pkgversion 3.12
%pyproject_install
%pyproject_save_files -l isort
%global python3_pkgversion 3
%endif
# we keep this one last so /usr/bin/isort is installed with python3 shebang
%pyproject_install
%pyproject_save_files -l isort
%check
# Internal check if the instalation outputs expected result
test -d %{buildroot}%{python3_sitelib}/%{modname}/
test -d %{buildroot}%{python3_sitelib}/%{modname}-%{version}.dist-info/
# Internal check that executables are not present when +auto was not used with %%pyproject_save_files
grep -F %{_bindir}/%{modname} %{pyproject_files} && exit 1 || true
%if 0%{?rhel} == 9
# Internal check that correct versions are in correct %%{pyproject_files}s
diff %{pyproject_files} <(grep -F python3.9/site-packages %{pyproject_files})
%global python3_pkgversion 3.11
test -d %{buildroot}%{_usr}/lib/python3.11/site-packages/%{modname}/
test -d %{buildroot}%{_usr}/lib/python3.11/site-packages/%{modname}-%{version}.dist-info/
diff %{pyproject_files} <(grep -F python3.11/site-packages %{pyproject_files})
%global python3_pkgversion 3.12
test -d %{buildroot}%{_usr}/lib/python3.12/site-packages/%{modname}/
test -d %{buildroot}%{_usr}/lib/python3.12/site-packages/%{modname}-%{version}.dist-info/
diff %{pyproject_files} <(grep -F python3.12/site-packages %{pyproject_files})
%global python3_pkgversion 3
%endif
%files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}
%doc README.rst *.md
%{_bindir}/%{modname}
%if 0%{?rhel} == 9
%global python3_pkgversion 3.11
%files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}
%doc README.rst *.md
%global python3_pkgversion 3.12
%files -n python%{python3_pkgversion}-%{modname} -f %{pyproject_files}
%doc README.rst *.md
%global python3_pkgversion 3
%endif

110
tests/python-ldap.spec Normal file
View File

@ -0,0 +1,110 @@
Name: python-ldap
Version: 3.3.0
Release: 0%{?dist}
License: Python
Summary: An object-oriented API to access LDAP directory servers
Source0: %{pypi_source}
# OpenLDAP 2.5+ is not yet supported by python-ldap
# https://github.com/python-ldap/python-ldap/issues/432
# Fedora has this patch to make it build, but the tests will fail anyway
Patch0: https://src.fedoraproject.org/rpms/python-ldap/raw/a237d9b212bd1581e07f4f1a8f54c26a7190843c/f/python-ldap-always-use-ldap-library.patch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
BuildRequires: cyrus-sasl-devel
BuildRequires: gcc
BuildRequires: openldap-clients
BuildRequires: openldap-devel
BuildRequires: openldap-servers
BuildRequires: openssl-devel
%description
This package contains extension modules. Does not contain pyproject.toml.
Has multiple files and directories.
Building this tests:
- the proper files are installed in the proper places
- module glob in %%pyproject_save_files (some modules are included, some not)
- combined manual and generated Buildrequires
- building an extension module via %%pyproject_buildrequires -w
%package -n python3-ldap
Summary: %{summary}
%description -n python3-ldap
%{summary}
%prep
%autosetup
# Hack: We remove tests that are broken by OpenLDAP 2.5+
# Don't do this in the regular Fedora package, please
rm Tests/t_ldapobject.py Tests/t_cext.py Tests/t_edit.py Tests/t_ldap_sasl.py Tests/t_ldap_syncrepl.py Tests/t_slapdobject.py Tests/t_bind.py Tests/t_ldap_options.py Tests/t_ldap_schema_subentry.py
%generate_buildrequires
# -w is not required with this package, but we test that we can use it anyway
%pyproject_buildrequires -t -w
%build
#%%pyproject_wheel -- this is done via %%pyproject_buildrequires -w
# Internal check that we can import the built extension modules from %%{pyproject_build_lib}
%{python3} -c 'import _ldap' && exit 1 || true
PYTHONPATH=%{pyproject_build_lib} %{python3} -c 'import _ldap'
%install
%pyproject_install
# We can pass multiple globs
%pyproject_save_files -l 'ldap*' '*ldap'
%check
%tox
# Internal check if the instalation outputs expected files
test -d %{buildroot}%{python3_sitearch}/__pycache__/
test -d %{buildroot}%{python3_sitearch}/python_ldap-%{version}.dist-info/
test -d %{buildroot}%{python3_sitearch}/ldap/
test -f %{buildroot}%{python3_sitearch}/ldapurl.py
test -f %{buildroot}%{python3_sitearch}/ldif.py
test -d %{buildroot}%{python3_sitearch}/slapdtest/
test -f %{buildroot}%{python3_sitearch}/_ldap.cpython-*.so
# Internal check: Unmatched modules are not supposed to be listed in %%{pyproject_files}
# We'll list them explicitly
grep -F %{python3_sitearch}/ldif.py %{pyproject_files} && exit 1 || true
grep -F %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.pyc %{pyproject_files} && exit 1 || true
grep -F %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.opt-1.pyc %{pyproject_files} && exit 1 || true
grep -F %{python3_sitearch}/slapdtest %{pyproject_files} && exit 1 || true
# Internal check: Unmatched modules are not supposed to be listed in %%{_pyproject_modules}
grep -F slapdtest %{_pyproject_modules} && exit 1 || true
grep -F ldif %{_pyproject_modules} && exit 1 || true
# Let's check that at least one module is listed in %%{_pyproject_modules}
grep -F ldapurl %{_pyproject_modules}
# Internal check: Top level __pycache__ is never owned
grep -E '/site-packages/__pycache__$' %{pyproject_files} && exit 1 || true
grep -E '/site-packages/__pycache__/$' %{pyproject_files} && exit 1 || true
# Internal check for the value of %%{pyproject_build_lib} in an archful package
%if 0%{?rhel} == 9
test "%{pyproject_build_lib}" == "$(echo %{_pyproject_builddir}/pip-req-build-*/build/lib.%{python3_platform}-%{python3_version})"
%elif 0%{?fedora} == 36
test "%{pyproject_build_lib}" == "%{_builddir}/%{buildsubdir}/build/lib.%{python3_platform}-%{python3_version}"
%else
test "%{pyproject_build_lib}" == "%{_builddir}/%{buildsubdir}/build/lib.%{python3_platform}-cpython-%{python3_version_nodots}"
%endif
%files -n python3-ldap -f %{pyproject_files}
%doc CHANGES README TODO Demo
# Explicitly listed files can be combined with automation
%pycached %{python3_sitearch}/ldif.py
%{python3_sitearch}/slapdtest/

View File

@ -0,0 +1,61 @@
Name: python-markupsafe
Version: 2.0.1
Release: 0%{?dist}
Summary: Implements a XML/HTML/XHTML Markup safe string for Python
License: BSD
URL: https://github.com/pallets/markupsafe
Source0: %{url}/archive/%{version}/MarkupSafe-%{version}.tar.gz
BuildRequires: gcc
BuildRequires: make
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%description
This package installs test- and docs-requirements from files
and uses them to run tests and build documentation.
It also has a less common order of the %%files section.
%package -n python3-markupsafe
Summary: %{summary}
%description -n python3-markupsafe
...
# In this spec, we put %%files early to test it still works
%files -n python3-markupsafe -f %{pyproject_files}
%doc CHANGES.rst README.rst
%prep
%autosetup -n markupsafe-%{version}
# we don't have pip-tools packaged in Fedora yet
sed -i /pip-tools/d requirements/dev.in
# help the macros understand the URL in requirements/docs.in
sed -Ei 's/sphinx\.git@([0-9a-f]+)/sphinx.git@\1#egg=sphinx/' requirements/docs.in
%generate_buildrequires
# requirements/dev.in recursively includes tests.in and docs.in
# we also list tests.in manually to verify we can pass multiple arguments,
# but it should be redundant if this was a real package
%pyproject_buildrequires requirements/dev.in requirements/tests.in
%build
%pyproject_wheel
%make_build -C docs html SPHINXOPTS='-n %{?_smp_mflags}'
%install
%pyproject_install
%pyproject_save_files -l markupsafe
%check
%pytest

63
tests/python-mistune.spec Normal file
View File

@ -0,0 +1,63 @@
Name: python-mistune
Version: 0.8.3
Release: 11%{?dist}
Summary: Markdown parser for Python
License: BSD
URL: https://github.com/lepture/mistune
Source0: %{url}/archive/v%{version}.tar.gz
BuildRequires: gcc
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: pyproject-rpm-macros
# optional dependency, listed explicitly to have the extension module:
BuildRequires: python%{python3_pkgversion}-Cython
%description
This package contains an extension module. Does not contain pyproject.toml.
Has a script (.py) and extension (.so) with identical name.
Building this tests:
- installing both a script and an extension with the same name
- default build backend without pyproject.toml
Check %%pyproject_check_import basic functionality.
This package also uses %%{python3_pkgversion} in name and has a very limited
set of dependencies -- allows to set a different value for it in the CI.
%package -n python%{python3_pkgversion}-mistune
Summary: %summary
%description -n python%{python3_pkgversion}-mistune
%{summary}
%prep
%autosetup -n mistune-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l mistune
%check
%pyproject_check_import
# Internal check for our macros
# making sure that pyproject_install outputs these files so that we can test behaviour of %%pyproject_save_files
# when a package has multiple files with the same name (here script and extension)
test -f %{buildroot}%{python3_sitearch}/mistune.py
test -f %{buildroot}%{python3_sitearch}/mistune.cpython-*.so
%files -n python%{python3_pkgversion}-mistune -f %{pyproject_files}
%doc README.rst

View File

@ -0,0 +1,56 @@
%global pypi_name openqa_client
Name: python-%{pypi_name}
Version: 4.0.0
Release: 1%{?dist}
Summary: Python client library for openQA API
License: GPLv2+
URL: https://github.com/os-autoinst/openQA-python-client
Source0: %{pypi_source}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%description
This package uses tox.ini file with recursive deps (via the -r option).
%package -n python3-%{pypi_name}
Summary: %{summary}
%description -n python3-%{pypi_name}
%{summary}.
%prep
%autosetup -p1 -n %{pypi_name}-%{version}
# setuptools-git is needed to build the source distribution, but not
# for packaging, which *starts* from the source distribution
# we sed it out to save ourselves a dependency, but that is not strictly required
sed -i -e 's., "setuptools-git"..g' pyproject.toml
# the tests don't actually need mock, they use unittest.mock
# https://github.com/os-autoinst/openQA-python-client/pull/21
sed -i '/mock/d' tests.requires
%generate_buildrequires
%pyproject_buildrequires -t
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l %{pypi_name}
%check
%tox
%files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.*

54
tests/python-pluggy.spec Normal file
View File

@ -0,0 +1,54 @@
%global pypi_name pluggy
Name: python-%{pypi_name}
Version: 0.13.0
Release: 1%{?dist}
Summary: The plugin manager stripped of pytest specific details
License: MIT
URL: https://github.com/pytest-dev/pluggy
Source0: %{pypi_source}
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
# we don't BR python3-devel here just for test purposes, but we recommend you do it
%description
A pure Python library. The package contains tox.ini. Does not contain executables.
Building this tests:
- generating runtime and testing dependencies
- running tests with %%tox
- the %%pyproject_save_files +auto option works without actual executables
- pyproject.toml with the setuptools backend and setuptools-scm
%package -n python3-%{pypi_name}
Summary: %{summary}
%description -n python3-%{pypi_name}
%{summary}.
%prep
%autosetup -p1 -n %{pypi_name}-%{version}
%generate_buildrequires
%pyproject_buildrequires -t
%build
%pyproject_wheel
%install
%pyproject_install
# There are no executables, but we are allowed to pass +auto anyway
%pyproject_save_files pluggy +auto -l
%check
%tox
%files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.rst

View File

@ -0,0 +1,48 @@
Name: python-poetry-core
Version: 1.1.0
Release: 0%{?dist}
Summary: Poetry PEP 517 Build Backend
License: MIT
URL: https://pypi.org/project/poetry-core/
Source0: %{pypi_source poetry-core}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%description
Test a build with pyproject.toml backend-path = [.]
poetry-core builds with poetry-core.
%package -n python3-poetry-core
Summary: %{summary}
%description -n python3-poetry-core
...
%prep
%autosetup -p1 -n poetry-core-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
# the license is not marked as License-File by poetry-core, hence -L
%pyproject_save_files -L poetry
# internal check for our macros, -l must fail:
%pyproject_save_files -l poetry && exit 1 || true
%files -n python3-poetry-core -f %{pyproject_files}
%doc README.md
%license LICENSE

72
tests/python-pytest.spec Normal file
View File

@ -0,0 +1,72 @@
%global pypi_name pytest
Name: python-%{pypi_name}
Version: 7.1.3
Release: 0%{?dist}
Summary: Simple powerful testing with Python
License: MIT
URL: https://pytest.org
Source0: %{pypi_source}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
# no xmlschema packaged for EPEL 9 yet, cannot run tests on EPEL
%if 0%{?fedora}
%bcond_without tests
%else
%bcond_with tests
%endif
%description
This is a pure Python package with executables. It has a test suite in tox.ini
and test dependencies specified via the [test] extra.
Building this tests:
- generating runtime and test dependencies by both tox.ini and extras
- pyproject.toml with the setuptools backend and setuptools-scm
- passing arguments into %%tox
%package -n python3-%{pypi_name}
Summary: %{summary}
%description -n python3-%{pypi_name}
%{summary}.
%prep
%autosetup -p1 -n %{pypi_name}-%{version}
# remove optional test dependencies we don't like to pull in
sed -E -i '/mock|nose/d' setup.cfg
# internal check for our macros: insert a subprocess echo to setup.py
# to ensure it's not generated as BuildRequires
echo 'import os; os.system("echo if-this-is-generated-the-build-will-fail")' >> setup.py
# make this build in EPEL 9
sed -i 's/setuptools-scm\[toml\]>=6.2.3/setuptools-scm[toml]>=5/' pyproject.toml
%generate_buildrequires
%pyproject_buildrequires %{?with_tests:-x testing -t}
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l '*pytest' +auto
%check
%if %{with tests}
# Only run one test (which uses a test-only dependency, hypothesis)
# See how to pass options trough the macro to tox, trough tox to pytest
%tox -- -- -k "metafunc and not test_parametrize_" -Wdefault
%else
%pyproject_check_import
%endif
%files -n python3-%{pypi_name} -f %{pyproject_files}
%doc README.rst
%doc CHANGELOG.rst

View File

@ -0,0 +1,110 @@
Name: python-setuptools
# on the CI we test different version of setuptools on different Fedora versions
# don't package software like this in Fedora please
%if 0%{?fedora} || 0%{?rhel} >= 10
Version: 67.7.2
%else
Version: 59.6.0
%endif
Release: 0%{?dist}
Summary: Easily build and distribute Python packages
# see the real Fedora package for explanation:
License: MIT and (BSD or ASL 2.0)
URL: https://pypi.python.org/pypi/setuptools
Source: %{pypi_source setuptools %{version}}
# Patch from Fedora proper
%if 0%{?fedora} || 0%{?rhel} >= 10
Patch: https://src.fedoraproject.org/rpms/python-setuptools/raw/8ae9b2a777c/f/Remove-optional-or-unpackaged-test-deps.patch
%else
Patch: https://src.fedoraproject.org/rpms/python-setuptools/raw/6fc093d6b3d/f/0001-Remove-optional-or-unpackaged-test-deps.patch
%endif
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
BuildRequires: gcc
# too many missing tests deps in EPEL 9
%if 0%{?fedora}
%bcond_without tests
%else
%bcond_with tests
%endif
%description
This package tests 2 things:
- %%{_pyproject_builddir} does not leak to pytest collection (rhzb#1935212)
- TODO %%{pyproject_files} has escaped spaces (rhzb#1976363)
%package -n python3-setuptools
Summary: %{summary}
# For users who might see ModuleNotFoundError: No module named 'pkg_resoureces'
%py_provides python3-pkg_resources
%py_provides python3-pkg-resources
%description -n python3-setuptools
...
%prep
%autosetup -p1 -n setuptools-%{version}
%if 0%{?rhel} && 0%{?rhel} < 10
# The following test deps are optional and either not desired or not available in Fedora:
sed -Ei setup.cfg -e '/\bpytest-(checkdocs|black|cov|mypy|enabler)\b/d' \
-e '/\bflake8\b/d' \
-e '/\bpaver\b/d'
# Strip pytest options from the above
sed -i pytest.ini -e 's/ --flake8//' \
-e 's/ --cov//'
%endif
%generate_buildrequires
%pyproject_buildrequires -r %{?with_tests:-x testing}
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files setuptools pkg_resources _distutils_hack -l
# https://github.com/pypa/setuptools/issues/2709
rm -rf %{buildroot}%{python3_sitelib}/pkg_resources/tests/
sed -i '/tests/d' %{pyproject_files}
%check
# https://github.com/pypa/setuptools/discussions/2607
rm pyproject.toml
%if %{with tests}
# We only run a subset of tests to speed things up and be less fragile
PRE_BUILT_SETUPTOOLS_WHEEL=%{_pyproject_wheeldir}/setuptools-%{version}-py3-none-any.whl \
PYTHONPATH=$(pwd) %pytest --ignore=pavement.py \
--ignore=setuptools/tests/test_develop.py \
--ignore=setuptools/tests/test_editable_install.py \
--ignore=setuptools/tests/config/test_apply_pyprojecttoml.py \
-k "sdist" -n %{_smp_build_ncpus}
%else
%pyproject_check_import
%endif
# Internal check that license file was recognized correctly
grep '^%%license' %{pyproject_files} > tested.license
echo '%%license %{python3_sitelib}/setuptools-%{version}.dist-info/LICENSE' > expected.license
diff tested.license expected.license
%files -n python3-setuptools -f %{pyproject_files}
%doc docs/* CHANGES.rst README.rst
%{python3_sitelib}/distutils-precedence.pth

View File

@ -0,0 +1,75 @@
Name: python-setuptools_scm
Version: 6.0.1
Release: 0%{?dist}
Summary: The blessed package to manage your versions by SCM tags
License: MIT
URL: https://github.com/pypa/setuptools_scm/
Source0: %{pypi_source setuptools_scm}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
BuildRequires: /usr/bin/git
# flake8 is still missing tests deps in EPEL 9
%if 0%{?fedora}
%bcond_without flake8
%else
%bcond_with flake8
%endif
%description
Here we test that %%pyproject_extras_subpkg works and generates
setuptools_scm[toml] extra subpackage.
We also check passing multiple -e flags to %%pyproject_buildrequires.
The tox environments also have a dependency on an extra ("toml").
%package -n python3-setuptools_scm
Summary: %{summary}
%description -n python3-setuptools_scm
...
%pyproject_extras_subpkg -n python3-setuptools_scm toml
%prep
%autosetup -p1 -n setuptools_scm-%{version}
%generate_buildrequires
# Note that you should not run flake8-like linters in Fedora spec files,
# here we do it solely to check the *ability* to use multiple toxenvs.
%pyproject_buildrequires -e %{default_toxenv}-test %{?with_flake8:-e flake8}
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l setuptools_scm
%check
# This tox should run all the toxenvs specified via -e in %%pyproject_buildrequires
# We only run some of the tests (running all of them requires network connection and is slow)
%tox -- -- -k test_version -Wdefault | tee toxlog
# Internal check for our macros: Assert both toxenvs were executed.
grep -E 'py%{python3_version_nodots}-test: (OK|commands succeeded)' toxlog
grep -E 'flake8: (OK|commands succeeded)' toxlog %{?!with_flake8:&& exit 1 || true}
# Internal check for our macros
# making sure that %%{_pyproject_ghost_distinfo} has the right content
test -f %{_pyproject_ghost_distinfo}
test "$(cat %{_pyproject_ghost_distinfo})" == "%ghost %{python3_sitelib}/setuptools_scm-%{version}.dist-info"
%files -n python3-setuptools_scm -f %{pyproject_files}
%doc README.rst
%doc CHANGELOG.rst

View File

@ -0,0 +1,61 @@
Name: python-userpath
Version: 1.8.0
Release: 1%{?dist}
Summary: Cross-platform tool for adding locations to the user PATH
License: MIT
URL: https://github.com/ofek/userpath
Source: %{pypi_source userpath}
BuildArch: noarch
BuildRequires: python3-devel
%description
This package uses hatchling as build backend.
This package is tested because:
- the prepare_metadata_for_build_wheel hook does not exist,
%%pyproject_buildrequires -w is used
https://github.com/ofek/hatch/issues/128
- the licenses are stored in a dist-info subdirectory
https://bugzilla.redhat.com/1985340
(as of hatchling 0.22.0, not yet marked as License-File)
%package -n python3-userpath
Summary: %{summary}
%description -n python3-userpath
...
%prep
%autosetup -p1 -n userpath-%{version}
sed -Ei '/^(coverage)$/d' requirements-dev.txt
%generate_buildrequires
%pyproject_buildrequires requirements-dev.txt -w
## %%pyproject_buildrequires -w makes this redundant:
# %%build
# %%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l userpath
%check
%pytest
%if 0%{?fedora} || 0%{?rhel} > 9
# Internal check that license file was recognized correctly with hatchling 1.9.0+
grep '^%%license' %{pyproject_files} > tested.license
echo '%%license %{python3_sitelib}/userpath-%{version}.dist-info/licenses/LICENSE.txt' > expected.license
diff tested.license expected.license
%endif
%files -n python3-userpath -f %{pyproject_files}
%{_bindir}/userpath

View File

@ -0,0 +1,71 @@
Name: python-virtualenv
Version: 20.19.0
Release: 0%{?dist}
Summary: Tool to create isolated Python environments
License: MIT
URL: http://pypi.python.org/pypi/virtualenv
Source: %{pypi_source virtualenv}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-flaky
BuildRequires: python3-pytest
%description
This specfile was added as a regression test to
https://src.fedoraproject.org/rpms/pyproject-rpm-macros/pull-request/363
It uses hatchling without %%pyproject_buildrequires -w.
%package -n python3-virtualenv
Summary: %{summary}
%description -n python3-virtualenv
...
%prep
%autosetup -p1 -n virtualenv-%{version}
# Relax the upper bounds of some dependencies to their known available versions in EL 9
sed -i -e 's/distlib<1,>=0.3.6/distlib<1,>=0.3.2/' \
-e 's/filelock<4,>=3.4.1/filelock<4,>=3.3.1/' \
-e 's/platformdirs<4,>=2.4/platformdirs<4,>=2.3/' \
-e 's/hatchling>=1.12.2/hatchling>=0.25/' \
-e 's/hatch-vcs>=0.3/hatch-vcs>=0.2.1/' \
pyproject.toml
# Hacky backport of https://src.fedoraproject.org/rpms/python-virtualenv/c/87b1f95664
%if 0%{?fedora} >= 39 || 0%{?rhel} >= 10
sed -i 's/_nonwrappers/_hookimpls/' tests/conftest.py
%endif
%generate_buildrequires
%pyproject_buildrequires -w
%build
# %%pyproject_buildrequires -w makes this redundant
# %%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l virtualenv
%{?el9:
# old version of setuptools_scm produces files incompatible with
# assumptions in virtualenv code, we append the expected attributes:
echo '__version__, __version_tuple__ = version, version_tuple' >> %{buildroot}%{python3_sitelib}/virtualenv/version.py
}
%check
# test_main fails when .dist-info is not deleted at the end of %%pyproject_buildrequires
PIP_CERT=/etc/pki/tls/certs/ca-bundle.crt \
%pytest -v -k test_main
%files -n python3-virtualenv -f %{pyproject_files}
%doc README.md
%{_bindir}/virtualenv

View File

@ -0,0 +1,45 @@
Name: python-zope-event
Version: 4.2.0
Release: 0%{?dist}
Summary: Zope Event Publication
License: ZPLv2.1
URL: https://pypi.python.org/pypi/zope.event/
Source0: %{pypi_source zope.event}
BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
%description
This package contains .pth files.
Building this tests that .pth files are not listed when +auto is not used
with %%pyproject_save_files.
%package -n python3-zope-event
Summary: %{summary}
%description -n python3-zope-event
...
%prep
%setup -q -n zope.event-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l zope +auto
%check
# Internal check that the RECORD and REQUESTED files are
# always removed in %%pyproject_wheel
test ! $(find %{buildroot}%{python3_sitelib}/ | grep -E "\.dist-info/RECORD$")
test ! $(find %{buildroot}%{python3_sitelib}/ | grep -E "\.dist-info/REQUESTED$")
%files -n python3-zope-event -f %{pyproject_files}
%doc README.rst

127
tests/tests.yml Normal file
View File

@ -0,0 +1,127 @@
---
- hosts: localhost
tags:
- classic
tasks:
- dnf:
name: "*"
state: latest
- hosts: localhost
tags:
- classic
pre_tasks:
- import_role:
name: standard-test-source
vars:
fetch_only: True
roles:
- role: standard-test-basic
tests:
- mock_with_tox_tests:
dir: .
run: ./mocktest.sh pyproject-rpm-macros --with tox_tests
- pytest:
dir: .
run: ./mocktest.sh python-pytest
- entrypoints:
dir: .
run: ./mocktest.sh python-entrypoints
- pluggy:
dir: .
run: ./mocktest.sh python-pluggy
# uses poetry backend, no poetry in EL 9
# awaiting volunteers in https://bugzilla.redhat.com/2049649
#- clikit:
# dir: .
# run: ./mocktest.sh python-clikit
- distroinfo:
dir: .
run: ./mocktest.sh python-distroinfo
- tldr:
dir: .
run: ./mocktest.sh tldr
- openqa_client:
dir: .
run: ./mocktest.sh python-openqa_client
- httpbin:
dir: .
run: ./mocktest.sh python-httpbin
- ldap:
dir: .
run: ./mocktest.sh python-ldap
- isort:
dir: .
run: ./mocktest.sh python-isort
- mistune:
dir: .
run: ./mocktest.sh python-mistune
- setuptools_scm:
dir: .
run: ./mocktest.sh python-setuptools_scm
# awaiting jupyter-client in EPEL 9
#- ipykernel:
# dir: .
# run: ./mocktest.sh python-ipykernel
- zope:
dir: .
run: ./mocktest.sh python-zope-event
- django:
dir: .
run: ./mocktest.sh python-django
- printrun:
dir: .
run: ./mocktest.sh printrun
- dns_lexicon:
dir: .
run: ./mocktest.sh python-dns-lexicon
- flit_core:
dir: .
run: ./mocktest.sh python-flit-core
- poetry_core:
dir: .
run: ./mocktest.sh python-poetry-core
- setuptools:
dir: .
run: ./mocktest.sh python-setuptools
# too many missing deps in EPEL 9 (pre-commit, sphinx-issues, pallets-sphinx-themes)
#- markupsafe:
# dir: .
# run: ./mocktest.sh python-markupsafe
- getmac:
dir: .
run: ./mocktest.sh python-getmac
- userpath:
dir: .
run: ./mocktest.sh python-userpath
- double_install:
dir: .
run: ./mocktest.sh double-install
- fake_requirements:
dir: .
run: ./mocktest.sh fake-requirements
- virtualenv:
dir: .
run: ./mocktest.sh python-virtualenv
- escape_percentages:
dir: .
run: ./mocktest.sh escape_percentages
- config-settings-test:
dir: .
run: ./mocktest.sh config-settings-test
- isort_c9s:
dir: .
run: NAME="CentOS Stream" VERSION_ID=9 ./mocktest.sh python-isort
- mistune_311:
dir: .
run: ./mocktest.sh python-mistune --define 'python3_pkgversion 3.11'
- mistune_312:
dir: .
run: ./mocktest.sh python-mistune --define 'python3_pkgversion 3.12'
required_packages:
- 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm'
- 'https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm'
- mock
- rpmdevtools
- rpm-build

65
tests/tldr.spec Normal file
View File

@ -0,0 +1,65 @@
Name: tldr
Version: 0.4.4
Release: 1%{?dist}
Summary: Simplified and community-driven man pages
License: MIT
URL: https://github.com/tldr-pages/tldr-python-client
Source0: %{pypi_source}
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: pyproject-rpm-macros
%if 0%{?rhel} != 9
# Internal check for our macros: test that we can install to a custom prefix
BuildRequires: python3-rpm-macros >= 3.10-18
%global _prefix /app
%endif
%description
A Python package containing executables.
Building this tests:
- there are no bytecompiled files in %%{_bindir}
- the executable's shebang is adjusted properly
- file direct_url.json isn't created
- installation to custom prefix works
%prep
%autosetup -n %{name}-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files -l tldr +auto
%check
# Internal check for our macros: tests we don't ship __pycache__ in bindir
test ! -d %{buildroot}%{_bindir}/__pycache__
# Internal check for our macros: tests we have a proper shebang line
head -n1 %{buildroot}%{_bindir}/%{name}.py | grep -E '#!\s*%{python3}\s+%{py3_shbang_opts}\s*$'
# Internal check for our macros: tests that direct_url.json file wasn't created
test ! -e %{buildroot}%{python3_sitelib}/*.dist-info/direct_url.json
# Internal check for the value of %%{pyproject_build_lib} in a noarch package
%if 0%{?rhel} == 9
test "%{pyproject_build_lib}" == "$(echo %{_pyproject_builddir}/pip-req-build-*/build/lib)"
%else
test "%{pyproject_build_lib}" == "${PWD}/build/lib"
%endif
%if 0%{?rhel} != 9
# Internal check for custom prefix
grep '^/usr' %{pyproject_files} && exit 1 || true
grep '^/app' %{pyproject_files}
%endif
%files -f %pyproject_files
%doc README.md