8000 gh-105084: Tests: Use setuptools+wheel from sysconfig.get_config_var('WHEEL_PKG_DIR') if set by hroncok · Pull Request #105056 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-105084: Tests: Use setuptools+wheel from sysconfig.get_config_var('WHEEL_PKG_DIR') if set #105056

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

Merged
merged 5 commits into from
May 30, 2023
Merged
Changes from 1 commit
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
8000
Diff view
Diff view
Next Next commit
Tests: Use setuptools+wheel from sysconfig.get_config_var('WHEEL_PKG_…
…DIR') if set
  • Loading branch information
hroncok committed May 29, 2023
commit de09cac82d6b2006b1e7e535f5635f90a08f0d41
23 changes: 21 additions & 2 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,25 @@ def requires_venv_with_pip():
return unittest.skipUnless(ctypes, 'venv: pip requires ctypes')


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) # sort this like ensurepip does it
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
Expand All @@ -2297,8 +2316,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))
Expand Down
0