Run functional tests

- Drop test requirement of python-wheel-wheel
- Use pytest-xdist to run tests faster

The motivation for this was the need to drop python-wheel-wheel in wheel 0.46+.
Due to newly gained runtime dependencies of wheel,
such wheel cannot be used as is.

I realized that when the explicit BuildRequires is removed,
the package is brought in by python3-virtualenv.
But even when python3-virtualenv drops the dependency,
the tests still passed without python-wheel-wheel.

Because the tests that require packaged wheels were all --ignored
for obsolete reasons. When unignored, they errored due to missing coverage.whl.

While attempting to fix this, I realized we cannot use the RPM packaged wheel anyway.

When the functional tests run, it takes a while, hence pytest-xdist.

---

For the record, the coverage-0-py3-none-any.whl was created as:

    [project]
    name = "coverage"
    version = "0"

    [build-system]
    requires = ["setuptools >= 77.0.3"]
    build-backend = "setuptools.build_meta"

And coverage.py with:

    def process_startup():
        pass

Wheel generated by `python3 -m build` (with python3-build-1.2.1-4.fc41.noarch).
This commit is contained in:
Miro Hrončok 2025-05-05 23:33:04 +02:00
commit b4fe5333a1
3 changed files with 46 additions and 14 deletions

2
.gitignore vendored
View file

@ -4,4 +4,4 @@
/pip/
/results_python-pip/
*.rpm
*.whl

View file

@ -44,6 +44,28 @@ License: MIT AND Python-2.0.1 AND Apache-2.0 AND BSD-2-Clause AND BSD-3-C
URL: https://pip.pypa.io/
Source0: https://github.com/pypa/pip/archive/%{upstream_version}/%{srcname}-%{upstream_version}.tar.gz
# The following sources are wheels used only for tests.
# They are not bundled in the built package and do not contribute to the overall license.
# They are pre-built but only contain text files, rebuilding them in %%build has very little benefit.
# setuptools.whl
# We cannot use RPM-packaged python-setuptools-wheel because upstream pins to <80.
# See https://github.com/pypa/pip/pull/13357 for rationale.
Source1: https://files.pythonhosted.org/packages/0d/6d/b4752b044bf94cb802d88a888dc7d288baaf77d7910b7dedda74b5ceea0c/setuptools-79.0.1-py3-none-any.whl
# wheel.whl
# We cannot use RPM-packaged python-wheel-wheel because we intent to drop that package in wheel 0.46+.
# That version of wheel has runtime dependencies and is generally useless as a standalone wheel.
# See https://github.com/pypa/pip/pull/13382 as an attempt to drop the requirement from pip tests.
Source2: https://files.pythonhosted.org/packages/0b/2c/87f3254fd8ffd29e4c02732eee68a83a1d3c346ae39bc6822dcbcb697f2b/wheel-0.45.1-py3-none-any.whl
# coverage.whl
# There is no RPM-packaged python-coverage-wheel, the package is archful.
# Upstream uses this to measure coverage, which we don't.
# This is a dummy placeholder package that only contains empty coverage.process_startup().
# That way, we don't need to patch the usage out of conftest.py.
Source3: coverage-0-py3-none-any.whl
BuildArch: noarch
%if %{with tests}
@ -51,8 +73,7 @@ BuildRequires: /usr/bin/git
BuildRequires: /usr/bin/hg
BuildRequires: /usr/bin/bzr
BuildRequires: /usr/bin/svn
BuildRequires: python-setuptools-wheel
BuildRequires: python-wheel-wheel
BuildRequires: python%{python3_pkgversion}-pytest-xdist
%endif
%if %{with man}
@ -190,9 +211,6 @@ A Python wheel of pip to use with venv.
# this goes together with patch4
rm src/pip/_vendor/certifi/*.pem
# tests expect wheels in here
ln -s %{python_wheel_dir} tests/data/common_wheels
# Remove windows executable binaries
rm -v src/pip/_vendor/distlib/*.exe
sed -i '/\.exe/d' pyproject.toml
@ -200,6 +218,12 @@ sed -i '/\.exe/d' pyproject.toml
# Remove unused test requirements
sed -Ei '/(pytest-(cov|xdist|rerunfailures)|proxy\.py)/d' tests/requirements.txt
%if %{with tests}
# tests expect wheels in here
mkdir tests/data/common_wheels
cp -a %{SOURCE1} %{SOURCE2} %{SOURCE3} tests/data/common_wheels
%endif
%if %{with tests}
%generate_buildrequires
@ -272,15 +296,20 @@ grep "pem$" %{pyproject_files} && exit 1 || true
# Upstream tests
# bash completion tests only work from installed package
pytest_k='not completion'
# this clashes with our PYTHONPATH
pytest_k="$pytest_k and not environments_with_no_pip"
# this seems to require internet (despite no network marker)
# added in https://github.com/pypa/pip/pull/13378 TODO drop this in the next release
pytest_k="$pytest_k and not test_prompt_for_keyring_if_needed and not test_double_install_fail and not test_install_sdist_links and not test_lock_vcs and not test_lock_archive and not test_backend_sees_config_via_sdist"
# this cannot import breezy, TODO investigate
pytest_k="$pytest_k and not (functional and bazaar)"
# failures to investigate
pytest_k="$pytest_k and not test_all_fields and not test_report_mixed_not_found and not test_basic_show" # "Editable project location" missing
pytest_k="$pytest_k and not test_basic_install_from_wheel"
pytest_k="$pytest_k and not test_check_unsupported"
# --ignore'd tests are not compatible with the latest virtualenv
# These files contain almost 500 tests so we should enable them back
# as soon as pip will be compatible upstream
# https://github.com/pypa/pip/pull/8441
# among them, tests/functional/test_proxy.py needs proxy.py which is not
# yet packaged in Fedora
%pytest -m 'not network' -k "$(echo $pytest_k)" \
--ignore tests/functional --ignore tests/lib/test_lib.py
%pytest -n auto -m 'not network' -k "$(echo $pytest_k)" \
--ignore tests/functional/test_proxy.py # no proxy.py in Fedora
%endif

View file

@ -1 +1,4 @@
SHA512 (pip-25.1.1.tar.gz) = ce61c9861265139b3c5ea9be9dc246097cd75c21687cf8301f80a377d02420c4524f0d6307d2ca0232ff8715b1105343bcfdb9cac6b69503780ab2c4645558dc
SHA512 (setuptools-79.0.1-py3-none-any.whl) = fef6cfc6f95a5bb7320f1680e1c665cb8d9a4e4227cde4d8aab8a50bed4bcf04320085b9d7d5343359f887008db5c5a861e57f3d08b7b0b2311a28adaeee6b4a
SHA512 (wheel-0.45.1-py3-none-any.whl) = 86c16248ec804ee0ac95d43b03d47351dceb534d0cdc4025ca1eb073e39e539de44c870b9261f0373144e1537f0e42675a759a318a8d5d346bbd9efcb704061d
SHA512 (coverage-0-py3-none-any.whl) = e734192565347010efe68f8ba600254259c9b647f3c553fd4e5d87b1d7f955cb15d6f7d807716f4a6415d239beed945fbec7210feaf502e9cc849c332845926e