Skip to content

Commit

Permalink
00401: Tests: Use setuptools+wheel from sysconfig.get_config_var('WHE…
Browse files Browse the repository at this point in the history
…EL_PKG_DIR') if set

Proposed upstream python#105056
  • Loading branch information
hroncok committed May 29, 2023
1 parent 45c1382 commit 28229d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2398,5 +2398,26 @@ def adjust_int_max_str_digits(max_digits):
finally:
sys.set_int_max_str_digits(current)


@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) # sort this like ensurepip does it
for filename in filenames:
# filename is like 'pip-21.2.4-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}")


#For recursion tests, easily exceeds default recursion limit
EXCEEDS_RECURSION_LIMIT = 5000
4 changes: 2 additions & 2 deletions Lib/test/test_cppext.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def run_cmd(operation, cmd):

cmd = [python, '-X', 'dev',
'-m', 'pip', 'install',
support.findfile('setuptools-67.6.1-py3-none-any.whl'),
support.findfile('wheel-0.40.0-py3-none-any.whl')]
support._findwheel('setuptools'),
support._findwheel('wheel')]
run_cmd('Install build dependencies', cmd)

# Build and install the C++ extension
Expand Down

0 comments on commit 28229d0

Please sign in to comment.