From 1e37a4d8723ab58dc62d376c9462d8f376a11d28 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Mon, 13 Feb 2023 16:16:58 +0100 Subject: [PATCH] Remove .dist-info directory at the end of %pyproject_buildrequires An incomplete .dist-info directory in $PWD can confuse tests in %check. For example, virtualenv uses importlib.metadata to load its entry points and it does not work when it finds a virtualenv...dist-info without them. --- macros.pyproject | 2 ++ pyproject-rpm-macros.spec | 6 +++- tests/python-virtualenv.spec | 65 ++++++++++++++++++++++++++++++++++++ tests/tests.yml | 3 ++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/python-virtualenv.spec diff --git a/macros.pyproject b/macros.pyproject index 8cc59ae..7c4923b 100644 --- a/macros.pyproject +++ b/macros.pyproject @@ -172,6 +172,8 @@ if [ -f %{__python3} ]; then CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDIR="%{_pyproject_builddir}" \\\ RPM_TOXENV="%{toxenv}" HOSTNAME="rpmbuild" %{__python3} -Bs %{_rpmconfigdir}/redhat/pyproject_buildrequires.py %{?!_python_no_extras_requires:--generate-extras} --python3_pkgversion %{python3_pkgversion} --wheeldir %{_pyproject_wheeldir} %{?**} fi +# Incomplete .dist-info dir might confuse importlib.metadata +rm -rfv *.dist-info/ >&2 } diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec index 1973946..adb8b88 100644 --- a/pyproject-rpm-macros.spec +++ b/pyproject-rpm-macros.spec @@ -10,7 +10,7 @@ License: MIT # Increment Y and reset Z when new macros or features are added # Increment Z when this is a bugfix or a cosmetic change # Dropping support for EOL Fedoras is *not* considered a breaking change -Version: 1.6.2 +Version: 1.6.3 Release: 1%{?dist} # Macro files @@ -147,6 +147,10 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856 %changelog +* Mon Feb 13 2023 Lumír Balhar - 1.6.3-1 +- Remove .dist-info directory at the end of %%pyproject_buildrequires +- An incomplete .dist-info directory in $PWD can confuse tests in %%check + * Wed Feb 08 2023 Lumír Balhar - 1.6.2-1 - Improve detection of lang files - Fixes: rhbz#2166295 diff --git a/tests/python-virtualenv.spec b/tests/python-virtualenv.spec new file mode 100644 index 0000000..628dd54 --- /dev/null +++ b/tests/python-virtualenv.spec @@ -0,0 +1,65 @@ +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 Fedora 36 +# This can be reduced once Fedora 36 goes EOL, but might still be partially needed on Fedora 37 +sed -i -e 's/distlib<1,>=0.3.6/distlib<1,>=0.3.4/' \ + -e 's/filelock<4,>=3.4.1/filelock<4,>=3.3.1/' \ + -e 's/platformdirs<4,>=2.4/platformdirs<4,>=2.3/' \ + pyproject.toml + + +%generate_buildrequires +%pyproject_buildrequires + + +%build +%pyproject_wheel + + +%install +%pyproject_install +%pyproject_save_files virtualenv +%{?fc36: +# 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 diff --git a/tests/tests.yml b/tests/tests.yml index 484e1ae..5bdbc0b 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -88,6 +88,9 @@ - fake_requirements: dir: . run: ./mocktest.sh fake-requirements + - virtualenv: + dir: . + run: ./mocktest.sh python-virtualenv - escape_percentages: dir: . run: rpmbuild -ba escape_percentages.spec