From 12befad9d0ee8d7f382283669232dc0542ec9d54 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 16:47:50 +0200 Subject: [PATCH 1/6] gh-151929: Add pythoninfo-build command to Platforms/emscripten Replace also "run --test" with "pythoninfo-host" command. --- .github/workflows/reusable-emscripten.yml | 10 ++++--- Platforms/emscripten/__main__.py | 36 ++++++++++++++++++----- Platforms/emscripten/config.toml | 3 -- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/.github/workflows/reusable-emscripten.yml b/.github/workflows/reusable-emscripten.yml index 69a780a9aebc25e..38e6dcceb8f47ca 100644 --- a/.github/workflows/reusable-emscripten.yml +++ b/.github/workflows/reusable-emscripten.yml @@ -63,15 +63,17 @@ jobs: run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug - name: "Make build Python" run: python3 Platforms/emscripten make-build-python + - name: "Display build info of the build Python" + run: python3 Platforms/emscripten pythoninfo-build - name: "Make dependencies" run: >- python3 Platforms/emscripten make-dependencies ${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }} - - name: "Configure host Python" + - name: "Configure host/Emscripten Python" run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache - - name: "Make host Python" + - name: "Make host/Emscripten Python" run: python3 Platforms/emscripten make-host - - name: "Display build info" - run: python3 Platforms/emscripten run --pythoninfo + - name: "Display build info of the host/Emscripten Python" + run: python3 Platforms/emscripten pythoninfo-host - name: "Test" run: python3 Platforms/emscripten run --test diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index c2fb1c4c36e6087..f86049ef464c700 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -290,6 +290,12 @@ def make_build_python(context, working_dir): print(f"🎉 {binary} {version}") +@subdir("native_build_dir") +def pythoninfo_build(context, working_dir): + """Display build info for the build Python.""" + call(["make", "pythoninfo"], quiet=context.quiet) + + def check_shasum(file: str, expected_shasum: str): with open(file, "rb") as f: digest = hashlib.file_digest(f, "sha256") @@ -580,6 +586,16 @@ def make_emscripten_python(context, working_dir): subprocess.check_call([exec_script, "--version"]) +@subdir("host_dir") +def pythoninfo_emscripten_python(context, working_dir): + """Display build info for the host/Emscripten Python.""" + call( + ["make", "pythoninfo"], + env=updated_env({}, context.emsdk_cache), + quiet=context.quiet, + ) + + def run_emscripten_python(context): """Run the built emscripten Python.""" host_dir = context.build_paths["host_dir"] @@ -595,8 +611,6 @@ def run_emscripten_python(context): if context.test: args = load_config_toml()["test-args"] + args - elif context.pythoninfo: - args = load_config_toml()["pythoninfo-args"] + args os.execv(str(exec_script), [str(exec_script), *args]) @@ -707,6 +721,10 @@ def main(): "make-build-python", help="Run `make` for the build Python" ) + pythoninfo_build = subcommands.add_parser( + "pythoninfo-build", help="Display build info for the build Python" + ) + configure_host = subcommands.add_parser( "configure-host", help=( @@ -719,6 +737,10 @@ def main(): "make-host", help="Run `make` for the host/emscripten" ) + pythoninfo_host = subcommands.add_parser( + "pythoninfo-host", help="Display build info for the host/Emscripten Python" + ) + run = subcommands.add_parser( "run", help="Run the built emscripten Python", @@ -732,12 +754,6 @@ def main(): "Default arguments loaded from Platforms/emscripten/config.toml" ), ) - run.add_argument( - "--pythoninfo", - action="store_true", - default=False, - help="Run -m test.pythoninfo", - ) run.add_argument( "args", nargs=argparse.REMAINDER, @@ -770,8 +786,10 @@ def main(): make_mpdec_cmd, make_dependencies_cmd, make_build, + pythoninfo_build, configure_host, make_host, + pythoninfo_host, clean, ): subcommand.add_argument( @@ -840,8 +858,10 @@ def main(): "make-dependencies": make_dependencies, "configure-build-python": configure_build_python, "make-build-python": make_build_python, + "pythoninfo-build": pythoninfo_build, "configure-host": configure_emscripten_python, "make-host": make_emscripten_python, + "pythoninfo-host": pythoninfo_emscripten_python, "build": build_target, "run": run_emscripten_python, "clean": clean_contents, diff --git a/Platforms/emscripten/config.toml b/Platforms/emscripten/config.toml index 389d2ea66ce948e..993baeb1a1fe4e3 100644 --- a/Platforms/emscripten/config.toml +++ b/Platforms/emscripten/config.toml @@ -11,9 +11,6 @@ test-args = [ "--single-process", "-W", ] -pythoninfo-args = [ - "-m", "test.pythoninfo", -] [dependencies.libffi] url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz" From e7f8e3ae7650cf52576ac07dd3713c93a8c69fef Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 16:55:01 +0200 Subject: [PATCH 2/6] Fix function name to avoid conflict with the parser name --- Platforms/emscripten/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index f86049ef464c700..55fa69278b0827b 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -291,7 +291,7 @@ def make_build_python(context, working_dir): @subdir("native_build_dir") -def pythoninfo_build(context, working_dir): +def pythoninfo_build_python(context, working_dir): """Display build info for the build Python.""" call(["make", "pythoninfo"], quiet=context.quiet) @@ -858,7 +858,7 @@ def main(): "make-dependencies": make_dependencies, "configure-build-python": configure_build_python, "make-build-python": make_build_python, - "pythoninfo-build": pythoninfo_build, + "pythoninfo-build": pythoninfo_build_python, "configure-host": configure_emscripten_python, "make-host": make_emscripten_python, "pythoninfo-host": pythoninfo_emscripten_python, From f509f0f1bb8803df3799056523e4c94b1e7f9d5e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 17:14:58 +0200 Subject: [PATCH 3/6] Keep "run --pythoninfo" command for buildbots --- Platforms/emscripten/__main__.py | 8 ++++++++ Platforms/emscripten/config.toml | 3 +++ 2 files changed, 11 insertions(+) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index 55fa69278b0827b..7c4b1aeeda6b8d9 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -611,6 +611,8 @@ def run_emscripten_python(context): if context.test: args = load_config_toml()["test-args"] + args + elif context.pythoninfo: + args = load_config_toml()["pythoninfo-args"] + args os.execv(str(exec_script), [str(exec_script), *args]) @@ -754,6 +756,12 @@ def main(): "Default arguments loaded from Platforms/emscripten/config.toml" ), ) + run.add_argument( + "--pythoninfo", + action="store_true", + default=False, + help="Run -m test.pythoninfo", + ) run.add_argument( "args", nargs=argparse.REMAINDER, diff --git a/Platforms/emscripten/config.toml b/Platforms/emscripten/config.toml index 993baeb1a1fe4e3..389d2ea66ce948e 100644 --- a/Platforms/emscripten/config.toml +++ b/Platforms/emscripten/config.toml @@ -11,6 +11,9 @@ test-args = [ "--single-process", "-W", ] +pythoninfo-args = [ + "-m", "test.pythoninfo", +] [dependencies.libffi] url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz" From 89a6d708d3f4973a8b47e91174bbeafa6d073f27 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 17:29:09 +0200 Subject: [PATCH 4/6] pythoninfo_emscripten_python() now calls run_emscripten_python() --- Platforms/emscripten/__main__.py | 34 ++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index 7c4b1aeeda6b8d9..718ae83df3cb088 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -586,17 +586,7 @@ def make_emscripten_python(context, working_dir): subprocess.check_call([exec_script, "--version"]) -@subdir("host_dir") -def pythoninfo_emscripten_python(context, working_dir): - """Display build info for the host/Emscripten Python.""" - call( - ["make", "pythoninfo"], - env=updated_env({}, context.emsdk_cache), - quiet=context.quiet, - ) - - -def run_emscripten_python(context): +def run_emscripten_python(context, args=None): """Run the built emscripten Python.""" host_dir = context.build_paths["host_dir"] exec_script = host_dir / "python.sh" @@ -604,19 +594,25 @@ def run_emscripten_python(context): print("Emscripten not built", file=sys.stderr) sys.exit(1) - args = context.args - # Strip the "--" separator if present - if args and args[0] == "--": - args = args[1:] + if args is None: + args = context.args + # Strip the "--" separator if present + if args and args[0] == "--": + args = args[1:] - if context.test: - args = load_config_toml()["test-args"] + args - elif context.pythoninfo: - args = load_config_toml()["pythoninfo-args"] + args + if context.test: + args = load_config_toml()["test-args"] + args + elif context.pythoninfo: + args = load_config_toml()["pythoninfo-args"] + args os.execv(str(exec_script), [str(exec_script), *args]) +def pythoninfo_emscripten_python(context): + """Display build info for the host/Emscripten Python.""" + run_emscripten_python(context, ["-m", "test.pythoninfo"]) + + def build_target(context): """Build one or more targets.""" steps = [] From bad47e66f6fa79bd46bb0e66c8d5a387a2a35e1f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 17:34:15 +0200 Subject: [PATCH 5/6] Add pythoninfo to the build command --- Platforms/emscripten/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index 718ae83df3cb088..3bac045804707ea 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -620,6 +620,7 @@ def build_target(context): steps.extend([ configure_build_python, make_build_python, + pythoninfo_build_python, ]) if context.target in {"host", "all"}: steps.extend([ @@ -627,6 +628,7 @@ def build_target(context): make_mpdec, configure_emscripten_python, make_emscripten_python, + pythoninfo_emscripten_python, ]) for step in steps: From 59393c6ec1c02bc41d55e49e8f318acc02afec87 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 18:10:09 +0200 Subject: [PATCH 6/6] Rephrase --- Platforms/emscripten/__main__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index 3bac045804707ea..84a1589b81f6a20 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -292,7 +292,7 @@ def make_build_python(context, working_dir): @subdir("native_build_dir") def pythoninfo_build_python(context, working_dir): - """Display build info for the build Python.""" + """Display build info of the build Python.""" call(["make", "pythoninfo"], quiet=context.quiet) @@ -609,7 +609,7 @@ def run_emscripten_python(context, args=None): def pythoninfo_emscripten_python(context): - """Display build info for the host/Emscripten Python.""" + """Display build info of the host/Emscripten Python.""" run_emscripten_python(context, ["-m", "test.pythoninfo"]) @@ -722,7 +722,7 @@ def main(): ) pythoninfo_build = subcommands.add_parser( - "pythoninfo-build", help="Display build info for the build Python" + "pythoninfo-build", help="Display build info of the build Python" ) configure_host = subcommands.add_parser( @@ -738,7 +738,7 @@ def main(): ) pythoninfo_host = subcommands.add_parser( - "pythoninfo-host", help="Display build info for the host/Emscripten Python" + "pythoninfo-host", help="Display build info of the host/Emscripten Python" ) run = subcommands.add_parser(