| 62 | |
| 63 | @attr.s(frozen=True) |
| 64 | class InterpreterTest(object): |
| 65 | entry_point = attr.ib() # type: str |
| 66 | pex_info = attr.ib() # type: PexInfo |
| 67 | |
| 68 | @property |
| 69 | def interpreter_constraints(self): |
| 70 | # type: () -> InterpreterConstraints |
| 71 | return self.pex_info.interpreter_constraints |
| 72 | |
| 73 | def test_resolve(self, interpreter): |
| 74 | # type: (PythonInterpreter) -> Union[ResolveError, bool] |
| 75 | """Checks if `interpreter` can resolve all required distributions for the PEX under test.""" |
| 76 | with TRACER.timed( |
| 77 | "Testing {python} can resolve PEX at {pex}".format( |
| 78 | python=interpreter.binary, pex=self.entry_point |
| 79 | ) |
| 80 | ): |
| 81 | from pex.environment import PEXEnvironment |
| 82 | |
| 83 | pex_environment = PEXEnvironment.mount( |
| 84 | self.entry_point, |
| 85 | pex_info=self.pex_info, |
| 86 | target=LocalInterpreter.create(interpreter), |
| 87 | ) |
| 88 | try: |
| 89 | pex_environment.resolve() |
| 90 | return True |
| 91 | except ResolveError as e: |
| 92 | return e |
| 93 | |
| 94 | |
| 95 | # TODO(John Sirois): Move this to interpreter_constraints.py. As things stand, both pex/bin/pex.py |
no outgoing calls