|
19 | 19 |
|
20 | 20 | def add_module_dir_to_sys_path(dirname, zip_safe=True): |
21 | 21 | """Adds the given dirname to sys.path if it's nonempty.""" |
22 | | - # Add .bootstrap dir to path, after the initial pex entry |
23 | | - sys.path = sys.path[:1] + [os.path.join(sys.path[0], '.bootstrap')] + sys.path[1:] |
24 | | - # Now we have .bootstrap on the path, we can import our own hooks. |
25 | | - import plz |
| 22 | + import plz # this needs to be imported after paths are set up |
26 | 23 | if dirname: |
27 | | - sys.path = sys.path[:1] + [os.path.join(sys.path[0], dirname)] + sys.path[1:] |
| 24 | + sys.path.insert(1, os.path.join(sys.path[0], dirname)) |
28 | 25 | sys.meta_path.insert(0, plz.ModuleDirImport(dirname)) |
29 | 26 | if zip_safe: |
30 | 27 | sys.meta_path.append(plz.SoImport(MODULE_DIR)) |
@@ -82,10 +79,10 @@ def _explode_zip(): |
82 | 79 | os.makedirs(basepath, exist_ok=True) |
83 | 80 | with pex_lockfile(basepath, uniquedir) as lockfile: |
84 | 81 | if len(lockfile.read()) == 0: |
85 | | - import compileall, zipfile |
| 82 | + import compileall, zipfile, plz |
86 | 83 |
|
87 | 84 | os.makedirs(PEX_PATH, exist_ok=True) |
88 | | - with ZipFileWithPermissions(PEX, "r") as zf: |
| 85 | + with plz.ZipFileWithPermissions(PEX, "r") as zf: |
89 | 86 | zf.extractall(PEX_PATH) |
90 | 87 |
|
91 | 88 | if not no_cache: # Don't bother optimizing; we're deleting this when we're done. |
|
0 commit comments