MCPcopy
hub / github.com/linkedin/shiv / extend_python_path

Function extend_python_path

src/shiv/bootstrap/__init__.py:159–168  ·  view source on GitHub ↗

Create or extend a PYTHONPATH variable with the frozen environment we are bootstrapping with.

(environ, additional_paths)

Source from the content-addressed store, hash-verified

157
158
159def 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
171def ensure_no_modify(site_packages, hashes):

Callers 4

test_extend_pathMethod · 0.90
installFunction · 0.85
bootstrapFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_extend_pathMethod · 0.72