MCPcopy Index your code
hub / github.com/python/cpython / updated_env

Function updated_env

Platforms/WASI/_build.py:71–99  ·  view source on GitHub ↗

Create a new dict representing the environment to use. The changes made to the execution environment are printed out.

(updates={})

Source from the content-addressed store, hash-verified

69
70
71def updated_env(updates={}):
72 """Create a new dict representing the environment to use.
73
74 The changes made to the execution environment are printed out.
75 """
76 env_defaults = {}
77 # https://reproducible-builds.org/docs/source-date-epoch/
78 git_epoch_cmd = ["git", "log", "-1", "--pretty=%ct"]
79 try:
80 epoch = subprocess.check_output(
81 git_epoch_cmd, encoding="utf-8"
82 ).strip()
83 env_defaults["SOURCE_DATE_EPOCH"] = epoch
84 except subprocess.CalledProcessError:
85 pass # Might be building from a tarball.
86 # This layering lets SOURCE_DATE_EPOCH from os.environ takes precedence.
87 environment = env_defaults | os.environ | updates
88
89 env_diff = {}
90 for key, value in environment.items():
91 if os.environ.get(key) != value:
92 env_diff[key] = value
93
94 env_vars = [
95 f"\n {key}={item}" for key, item in sorted(env_diff.items())
96 ]
97 log("🌎", f"Environment changes:{''.join(env_vars)}")
98
99 return environment
100
101
102def subdir(working_dir, *, clean_ok=False):

Callers 2

configure_wasi_pythonFunction · 0.70
make_wasi_pythonFunction · 0.70

Calls 6

logFunction · 0.70
stripMethod · 0.45
check_outputMethod · 0.45
itemsMethod · 0.45
getMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…