| 66 | |
| 67 | @classmethod |
| 68 | def for_pex( |
| 69 | cls, |
| 70 | interpreter, # type: Union[PythonInterpreter, PythonIdentity] |
| 71 | pex, # type: str |
| 72 | pex_pex=None, # type: Optional[str] |
| 73 | ): |
| 74 | # type: (...) -> IsolatedSysPath |
| 75 | ident = interpreter.identity if isinstance(interpreter, PythonInterpreter) else interpreter |
| 76 | sys_path = OrderedSet(ident.sys_path) |
| 77 | sys_path.add(pex) |
| 78 | sys_path.add(Bootstrap.locate().path) |
| 79 | if pex_pex: |
| 80 | sys_path.add(pex_pex) |
| 81 | |
| 82 | site_packages = OrderedSet() # type: OrderedSet[str] |
| 83 | for site_lib in ident.site_packages: |
| 84 | TRACER.log("Discarding site packages path: {site_lib}".format(site_lib=site_lib)) |
| 85 | site_packages.add(site_lib.path) |
| 86 | |
| 87 | extras_paths = OrderedSet() # type: OrderedSet[str] |
| 88 | for extras_path in ident.extras_paths: |
| 89 | TRACER.log("Discarding site extras path: {extras_path}".format(extras_path=extras_path)) |
| 90 | extras_paths.add(extras_path) |
| 91 | |
| 92 | return cls( |
| 93 | sys_path=sys_path, |
| 94 | site_packages=site_packages, |
| 95 | extras_paths=extras_paths, |
| 96 | is_venv=ident.is_venv, |
| 97 | ) |
| 98 | |
| 99 | def __init__( |
| 100 | self, |