| 1228 | |
| 1229 | @classmethod |
| 1230 | def _spawn_from_binary( |
| 1231 | cls, |
| 1232 | binary, # type: str |
| 1233 | ignore_cached=False, # type: bool |
| 1234 | ): |
| 1235 | # type: (...) -> SpawnedJob[PythonInterpreter] |
| 1236 | canonicalized_binary = cls.canonicalize_path(binary) |
| 1237 | if not os.path.exists(canonicalized_binary): |
| 1238 | raise cls.InterpreterNotFound( |
| 1239 | "The interpreter path {} does not exist.".format(canonicalized_binary) |
| 1240 | ) |
| 1241 | |
| 1242 | # N.B.: The cache is written as the last step in PythonInterpreter instance initialization. |
| 1243 | cached_interpreter = cls._PYTHON_INTERPRETER_BY_NORMALIZED_PATH.get(canonicalized_binary) |
| 1244 | if cached_interpreter is not None and not ignore_cached: |
| 1245 | return SpawnedJob.completed(cached_interpreter) |
| 1246 | return cls._spawn_from_binary_external(canonicalized_binary, ignore_cached=ignore_cached) |
| 1247 | |
| 1248 | @classmethod |
| 1249 | def from_binary( |