Create or extend a PYTHONPATH variable with the frozen environment we are bootstrapping with.
(environ, additional_paths)
| 157 | |
| 158 | |
| 159 | def extend_python_path(environ, additional_paths): |
| 160 | """Create or extend a PYTHONPATH variable with the frozen environment we are bootstrapping with.""" |
| 161 | |
| 162 | # we don't want to clobber any existing PYTHONPATH value, so check for it. |
| 163 | python_path = environ["PYTHONPATH"].split(os.pathsep) if "PYTHONPATH" in environ else [] |
| 164 | python_path.extend(additional_paths) |
| 165 | |
| 166 | # put it back into the environment so that PYTHONPATH contains the shiv-manipulated paths |
| 167 | # and any pre-existing PYTHONPATH values with no duplicates. |
| 168 | environ["PYTHONPATH"] = os.pathsep.join(sorted(set(python_path), key=python_path.index)) |
| 169 | |
| 170 | |
| 171 | def ensure_no_modify(site_packages, hashes): |
no outgoing calls