| 1099 | # type: (...) -> SpawnedJob[PythonInterpreter] |
| 1100 | |
| 1101 | def create_interpreter( |
| 1102 | stdout, # type: bytes |
| 1103 | check_binary=False, # type: bool |
| 1104 | ): |
| 1105 | # type: (...) -> PythonInterpreter |
| 1106 | identity = stdout.decode("utf-8").strip() |
| 1107 | if not identity: |
| 1108 | raise cls.IdentificationError("Could not establish identity of {}.".format(binary)) |
| 1109 | interpreter = cls(PythonIdentity.decode(identity)) |
| 1110 | # We should not need to check this since binary == interpreter.binary should always be |
| 1111 | # true, but historically this could be untrue as noted in `PythonIdentity.get`. |
| 1112 | if check_binary and not os.path.exists(interpreter.binary): |
| 1113 | raise cls.InterpreterNotFound( |
| 1114 | "Cached interpreter for {} reports a binary of {}, which could not be found".format( |
| 1115 | binary, interpreter.binary |
| 1116 | ) |
| 1117 | ) |
| 1118 | return interpreter |
| 1119 | |
| 1120 | cache_dir = InterpreterDir.create(binary) |
| 1121 | if ignore_cached: |