Skip to content

Commit 8c16df6

Browse files
hroncokhrnciar
authored andcommitted
00401: Tests: Use setuptools+wheel from sysconfig.get_config_var('WHEEL_PKG_DIR') if set
Proposed upstream python#105056
1 parent fc160ab commit 8c16df6

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Lib/test/support/__init__.py

+21
Original file line numberDiff line numberDiff line change
@@ -2398,5 +2398,26 @@ def adjust_int_max_str_digits(max_digits):
23982398
finally:
23992399
sys.set_int_max_str_digits(current)
24002400

2401+
2402+
@functools.cache
2403+
def _findwheel(pkgname):
2404+
"""Try to find a wheel with the package specified as pkgname.
2405+
2406+
If set, the wheels are searched for in WHEEL_PKG_DIR (see ensurepip).
2407+
Otherwise, they are searched for in the test directory.
2408+
"""
2409+
wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or TEST_HOME_DIR
2410+
filenames = os.listdir(wheel_dir)
2411+
filenames = sorted(filenames) # sort this like ensurepip does it
2412+
for filename in filenames:
2413+
# filename is like 'pip-21.2.4-py3-none-any.whl'
2414+
if not filename.endswith(".whl"):
2415+
continue
2416+
prefix = pkgname + '-'
2417+
if filename.startswith(prefix):
2418+
return os.path.join(wheel_dir, filename)
2419+
raise FileNotFoundError(f"No wheel for {pkgname} found in {wheel_dir}")
2420+
2421+
24012422
#For recursion tests, easily exceeds default recursion limit
24022423
EXCEEDS_RECURSION_LIMIT = 5000

Lib/test/test_cppext.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def run_cmd(operation, cmd):
8383

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

9090
# Build and install the C++ extension

0 commit comments

Comments
 (0)