Infer the Python executable from the given version. This function mutates options based on special_opts to infer the correct Python executable to use.
(options: Options, special_opts: argparse.Namespace)
| 345 | |
| 346 | |
| 347 | def infer_python_executable(options: Options, special_opts: argparse.Namespace) -> None: |
| 348 | """Infer the Python executable from the given version. |
| 349 | |
| 350 | This function mutates options based on special_opts to infer the correct Python executable |
| 351 | to use. |
| 352 | """ |
| 353 | # TODO: (ethanhs) Look at folding these checks and the site packages subprocess calls into |
| 354 | # one subprocess call for speed. |
| 355 | |
| 356 | # Use the command line specified executable, or fall back to one set in the |
| 357 | # config file. If an executable is not specified, infer it from the version |
| 358 | # (unless no_executable is set) |
| 359 | python_executable = special_opts.python_executable or options.python_executable |
| 360 | |
| 361 | if python_executable is None: |
| 362 | if not special_opts.no_executable and not options.no_site_packages: |
| 363 | python_executable = _python_executable_from_version(options.python_version) |
| 364 | options.python_executable = python_executable |
| 365 | |
| 366 | |
| 367 | HEADER: Final = """%(prog)s [-h] [-v] [-V] [more options; see below] |
searching dependent graphs…