(python_version: tuple[int, int])
| 324 | |
| 325 | |
| 326 | def _python_executable_from_version(python_version: tuple[int, int]) -> str: |
| 327 | if sys.version_info[:2] == python_version: |
| 328 | return sys.executable |
| 329 | str_ver = ".".join(map(str, python_version)) |
| 330 | try: |
| 331 | sys_exe = ( |
| 332 | subprocess.check_output( |
| 333 | python_executable_prefix(str_ver) + ["-c", "import sys; print(sys.executable)"], |
| 334 | stderr=subprocess.STDOUT, |
| 335 | ) |
| 336 | .decode() |
| 337 | .strip() |
| 338 | ) |
| 339 | return sys_exe |
| 340 | except (subprocess.CalledProcessError, FileNotFoundError) as e: |
| 341 | raise PythonExecutableInferenceError( |
| 342 | "failed to find a Python executable matching version {}," |
| 343 | " perhaps try --python-executable, or --no-site-packages?".format(python_version) |
| 344 | ) from e |
| 345 | |
| 346 | |
| 347 | def infer_python_executable(options: Options, special_opts: argparse.Namespace) -> None: |
no test coverage detected
searching dependent graphs…