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.
(pkgname)
| 2505 | |
| 2506 | @functools.cache |
| 2507 | def _findwheel(pkgname): |
| 2508 | """Try to find a wheel with the package specified as pkgname. |
| 2509 | |
| 2510 | If set, the wheels are searched for in WHEEL_PKG_DIR (see ensurepip). |
| 2511 | Otherwise, they are searched for in the test directory. |
| 2512 | """ |
| 2513 | wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or os.path.join( |
| 2514 | TEST_HOME_DIR, 'wheeldata', |
| 2515 | ) |
| 2516 | filenames = os.listdir(wheel_dir) |
| 2517 | filenames = sorted(filenames, reverse=True) # approximate "newest" first |
| 2518 | for filename in filenames: |
| 2519 | # filename is like 'setuptools-{version}-py3-none-any.whl' |
| 2520 | if not filename.endswith(".whl"): |
| 2521 | continue |
| 2522 | prefix = pkgname + '-' |
| 2523 | if filename.startswith(prefix): |
| 2524 | return os.path.join(wheel_dir, filename) |
| 2525 | raise FileNotFoundError(f"No wheel for {pkgname} found in {wheel_dir}") |
| 2526 | |
| 2527 | |
| 2528 | # Context manager that creates a virtual environment, install setuptools in it, |
no test coverage detected