diff options
author | Miro HronĨok <miro@hroncok.cz> | 2023-05-30 10:20:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-30 10:20:30 (GMT) |
commit | bd98b65e974b7a1e086a51e7b55131582f7a0491 (patch) | |
tree | 3827aa0630af86af8a70cad38f4998ab14910127 | |
parent | cda1bd3c9d3b2cecdeeba0c498cd2df83fbdb535 (diff) | |
download | cpython-bd98b65e974b7a1e086a51e7b55131582f7a0491.zip cpython-bd98b65e974b7a1e086a51e7b55131582f7a0491.tar.gz cpython-bd98b65e974b7a1e086a51e7b55131582f7a0491.tar.bz2 |
gh-105084: Tests: Use setuptools+wheel from sysconfig.get_config_var('WHEEL_PKG_DIR') if set (#105056)
-rw-r--r-- | Lib/test/support/__init__.py | 24 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2023-05-29-14-49-46.gh-issue-105084.lvVvoj.rst | 3 |
2 files changed, 25 insertions, 2 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 7f8b1d7..fee8343 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2271,6 +2271,26 @@ def requires_venv_with_pip(): return unittest.skipUnless(ctypes, 'venv: pip requires ctypes') +@functools.cache +def _findwheel(pkgname): + """Try to find a wheel with the package specified as pkgname. + + If set, the wheels are searched for in WHEEL_PKG_DIR (see ensurepip). + Otherwise, they are searched for in the test directory. + """ + wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or TEST_HOME_DIR + filenames = os.listdir(wheel_dir) + filenames = sorted(filenames, reverse=True) # approximate "newest" first + for filename in filenames: + # filename is like 'setuptools-67.6.1-py3-none-any.whl' + if not filename.endswith(".whl"): + continue + prefix = pkgname + '-' + if filename.startswith(prefix): + return os.path.join(wheel_dir, filename) + raise FileNotFoundError(f"No wheel for {pkgname} found in {wheel_dir}") + + # Context manager that creates a virtual environment, install setuptools and wheel in it # and returns the path to the venv directory and the path to the python executable @contextlib.contextmanager @@ -2297,8 +2317,8 @@ def setup_venv_with_pip_setuptools_wheel(venv_dir): cmd = [python, '-X', 'dev', '-m', 'pip', 'install', - findfile('setuptools-67.6.1-py3-none-any.whl'), - findfile('wheel-0.40.0-py3-none-any.whl')] + _findwheel('setuptools'), + _findwheel('wheel')] if verbose: print() print('Run:', ' '.join(cmd)) diff --git a/Misc/NEWS.d/next/Tests/2023-05-29-14-49-46.gh-issue-105084.lvVvoj.rst b/Misc/NEWS.d/next/Tests/2023-05-29-14-49-46.gh-issue-105084.lvVvoj.rst new file mode 100644 index 0000000..5f80d50 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-05-29-14-49-46.gh-issue-105084.lvVvoj.rst @@ -0,0 +1,3 @@ +When the Python build is configured ``--with-wheel-pkg-dir``, tests +requiring the ``setuptools`` and ``wheel`` wheels will search for the wheels +in ``WHEEL_PKG_DIR``. |