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

Function android_env

Android/android.py:143–175  ·  view source on GitHub ↗
(host)

Source from the content-addressed store, hash-verified

141
142
143def android_env(host):
144 if host:
145 prefix = subdir(host) / "prefix"
146 else:
147 prefix = ANDROID_DIR / "prefix"
148 sysconfig_files = prefix.glob("lib/python*/_sysconfigdata__android_*.py")
149 sysconfig_filename = next(sysconfig_files).name
150 host = re.fullmatch(r"_sysconfigdata__android_(.+).py", sysconfig_filename)[1]
151
152 env_output = subprocess.run(
153 f"set -eu; "
154 f"HOST={host}; "
155 f"PREFIX={prefix}; "
156 f". {ENV_SCRIPT}; "
157 f"export",
158 check=True, shell=True, capture_output=True, encoding='utf-8',
159 ).stdout
160
161 env = {}
162 for line in env_output.splitlines():
163 # We don't require every line to match, as there may be some other
164 # output from installing the NDK.
165 if match := re.search(
166 "^(declare -x |export )?(\\w+)=['\"]?(.*?)['\"]?$", line
167 ):
168 key, value = match[2], match[3]
169 if os.environ.get(key) != value:
170 env[key] = value
171
172 if not env:
173 raise ValueError(f"Found no variables in {ENV_SCRIPT.name} output:\n"
174 + env_output)
175 return env
176
177
178def build_python_path():

Callers 3

runFunction · 0.85
packageFunction · 0.85
envFunction · 0.85

Calls 6

subdirFunction · 0.70
globMethod · 0.45
runMethod · 0.45
splitlinesMethod · 0.45
searchMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…