MCPcopy
hub / github.com/pyodide/pyodide / write_sysconfig

Function write_sysconfig

cpython/adjust_sysconfig.py:13–38  ·  view source on GitHub ↗
(destfile: str, fmted_config_vars: dict[str, str])

Source from the content-addressed store, hash-verified

11
12
13def write_sysconfig(destfile: str, fmted_config_vars: dict[str, str]):
14 with open(destfile, "w", encoding="utf8") as f:
15 f.write("# system configuration generated and used by the sysconfig module\n")
16 # Set PYODIDE_ROOT
17 f.write("import os\n")
18 f.write(f'PYODIDE_ROOT = os.environ.get("PYODIDE_ROOT", "{PYODIDE_ROOT}")\n')
19 f.write("build_time_vars = ")
20 f.write(fmted_config_vars)
21 # at build time, packages that are looking for the Python includes and
22 # libraries can get deceived by the values of platbase and
23 # installed_base (and possibly others, but we haven't run into trouble
24 # with them yet).
25 #
26 # At run time, the default behavior is correct. We look for the
27 # "PYODIDE" environment variable which is defined at build time but not
28 # at run time.
29 f.write(
30 dedent(
31 """
32 import os
33 if os.environ.get("PYODIDE", None) == "1":
34 build_time_vars["installed_base"] = build_time_vars["prefix"]
35 build_time_vars["platbase"] = build_time_vars["prefix"]
36 """
37 )
38 )
39
40
41def adjust_sysconfig(config_vars: dict[str, str]):

Callers 1

Calls 2

openFunction · 0.85
writeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…