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

Function configure_emscripten_python

Platforms/emscripten/__main__.py:460–567  ·  view source on GitHub ↗

Configure the emscripten/host build.

(context, working_dir)

Source from the content-addressed store, hash-verified

458
459@subdir("host_dir", clean_ok=True)
460def configure_emscripten_python(context, working_dir):
461 """Configure the emscripten/host build."""
462 validate_emsdk_version(context.emsdk_cache)
463 host_runner = context.host_runner
464 if host_runner is None:
465 host_runner = calculate_node_path()
466
467 paths = context.build_paths
468 config_site = os.fsdecode(EMSCRIPTEN_DIR / "config.site-wasm32-emscripten")
469
470 emscripten_build_dir = working_dir.relative_to(CHECKOUT)
471
472 python_build_dir = paths["native_build_dir"] / "build"
473 lib_dirs = list(python_build_dir.glob("lib.*"))
474 assert len(lib_dirs) == 1, (
475 f"Expected a single lib.* directory in {python_build_dir}"
476 )
477 lib_dir = os.fsdecode(lib_dirs[0])
478 pydebug = lib_dir.endswith("-pydebug")
479 python_version = lib_dir.removesuffix("-pydebug").rpartition("-")[-1]
480 sysconfig_data = (
481 f"{emscripten_build_dir}/build/lib.emscripten-wasm32-{python_version}"
482 )
483 if pydebug:
484 sysconfig_data += "-pydebug"
485 pkg_config_path_dir = (paths["prefix_dir"] / "lib/pkgconfig/").resolve()
486 env_additions = {
487 "CONFIG_SITE": config_site,
488 "HOSTRUNNER": host_runner,
489 "EM_PKG_CONFIG_PATH": str(pkg_config_path_dir),
490 }
491 build_python = os.fsdecode(build_python_path(context))
492 configure = [
493 "emconfigure",
494 os.path.relpath(CHECKOUT / "configure", working_dir),
495 "CFLAGS=-DPY_CALL_TRAMPOLINE -sUSE_BZIP2",
496 "PKG_CONFIG=pkg-config",
497 f"--host={HOST_TRIPLE}",
498 f"--build={build_platform()}",
499 f"--with-build-python={build_python}",
500 "--without-pymalloc",
501 "--disable-shared",
502 "--disable-ipv6",
503 "--enable-big-digits=30",
504 "--enable-wasm-dynamic-linking",
505 f"--prefix={paths['prefix_dir']}",
506 ]
507 if pydebug:
508 configure.append("--with-pydebug")
509 if context.args:
510 configure.extend(context.args)
511 call(
512 configure,
513 env=updated_env(env_additions, context.emsdk_cache),
514 quiet=context.quiet,
515 )
516
517 shutil.copy(

Callers

nothing calls this directly

Calls 15

dedentFunction · 0.90
validate_emsdk_versionFunction · 0.85
calculate_node_pathFunction · 0.85
listClass · 0.85
strFunction · 0.85
build_platformFunction · 0.85
build_python_pathFunction · 0.70
callFunction · 0.70
updated_envFunction · 0.70
relative_toMethod · 0.45
globMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…