From 9028be1a8f326c507d7e79e2a8ee8a462c01bd6c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 19:15:45 +0200 Subject: [PATCH 1/4] gh-151929: Add pythoninfo commands to Platforms/WASI (#152136) The "build-python", "build-host" and "build" commands now also run "pythoninfo-build" and "pythoninfo-host" commands. If no subcommand is provided, display the help. GitHub Action "WASI": * Add "pythoninfo-build" and "pythoninfo-host" commands. * Remove unused and outdated CROSS_BUILD_PYTHON environment variable. (cherry picked from commit 7c8163719cd23d41daeaed0b243be45de3e82e05) --- .github/workflows/reusable-wasi.yml | 11 ++++---- Tools/wasm/wasi/__main__.py | 43 +++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml index ed39d7ff2326509..af9494e6af0ebec 100644 --- a/.github/workflows/reusable-wasi.yml +++ b/.github/workflows/reusable-wasi.yml @@ -18,7 +18,6 @@ jobs: WASMTIME_VERSION: 38.0.3 WASI_SDK_VERSION: 24 WASI_SDK_PATH: /opt/wasi-sdk - CROSS_BUILD_PYTHON: cross-build/build CROSS_BUILD_WASI: cross-build/wasm32-wasip1 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -51,12 +50,14 @@ jobs: run: python3 Tools/wasm/wasi configure-build-python -- --config-cache --with-pydebug - name: "Make build Python" run: python3 Tools/wasm/wasi make-build-python - - name: "Configure host" + - name: "Display build info of the build Python" + run: python3 Platforms/WASI pythoninfo-build + - name: "Configure host/WASI Python" # `--with-pydebug` inferred from configure-build-python run: python3 Tools/wasm/wasi configure-host -- --config-cache - - name: "Make host" + - name: "Make host/WASI Python" run: python3 Tools/wasm/wasi make-host - - name: "Display build info" - run: make --directory "${CROSS_BUILD_WASI}" pythoninfo + - name: "Display build info of the host/WASI Python" + run: python3 Tools/wasm/wasi pythoninfo-host - name: "Test" run: make --directory "${CROSS_BUILD_WASI}" test diff --git a/Tools/wasm/wasi/__main__.py b/Tools/wasm/wasi/__main__.py index f27e15300e6bdec..8594b5820f301ba 100644 --- a/Tools/wasm/wasi/__main__.py +++ b/Tools/wasm/wasi/__main__.py @@ -211,6 +211,12 @@ def make_build_python(context, working_dir): log("🎉", f"{binary} {version}") +@subdir(BUILD_DIR) +def pythoninfo_build_python(context, working_dir): + """Display build info of the build Python.""" + call(["make", "pythoninfo"], context=context) + + def find_wasi_sdk(): """Find the path to the WASI SDK.""" wasi_sdk_path = None @@ -390,6 +396,12 @@ def make_wasi_python(context, working_dir): ) +@subdir(lambda context: CROSS_BUILD_DIR / context.host_triple) +def pythoninfo_wasi_python(context, working_dir): + """Display build info of the host/WASI Python.""" + call(["make", "pythoninfo"], context=context) + + def clean_contents(context): """Delete all files created by this script.""" if CROSS_BUILD_DIR.exists(): @@ -443,6 +455,9 @@ def main(): build_python = subcommands.add_parser( "build-python", help="Build the build Python" ) + pythoninfo_build = subcommands.add_parser( + "pythoninfo-build", help="Display build info of the build Python" + ) configure_host = subcommands.add_parser( "configure-host", help="Run `configure` for the " @@ -456,6 +471,9 @@ def main(): build_host = subcommands.add_parser( "build-host", help="Build the host/WASI Python" ) + pythoninfo_host = subcommands.add_parser( + "pythoninfo-host", help="Display build info of the host/WASI Python" + ) subcommands.add_parser( "clean", help="Delete files and directories created by this script" ) @@ -464,8 +482,10 @@ def main(): configure_build, make_build, build_python, + pythoninfo_build, configure_host, make_host, + pythoninfo_host, build_host, ): subcommand.add_argument( @@ -520,7 +540,13 @@ def main(): help="Command template for running the WASI host; defaults to " f"`{default_host_runner}`", ) - for subcommand in build, configure_host, make_host, build_host: + for subcommand in ( + build, + configure_host, + make_host, + build_host, + pythoninfo_host, + ): subcommand.add_argument( "--host-triple", action="store", @@ -532,18 +558,29 @@ def main(): context = parser.parse_args() context.init_dir = pathlib.Path().absolute() - build_build_python = build_steps(configure_build_python, make_build_python) - build_wasi_python = build_steps(configure_wasi_python, make_wasi_python) + build_build_python = build_steps( + configure_build_python, + make_build_python, + pythoninfo_build_python, + ) + build_wasi_python = build_steps( + configure_wasi_python, + make_wasi_python, + pythoninfo_wasi_python, + ) dispatch = { "configure-build-python": configure_build_python, "make-build-python": make_build_python, "build-python": build_build_python, + "pythoninfo-build": pythoninfo_build_python, "configure-host": configure_wasi_python, "make-host": make_wasi_python, "build-host": build_wasi_python, + "pythoninfo-host": pythoninfo_wasi_python, "build": build_steps(build_build_python, build_wasi_python), "clean": clean_contents, + None: lambda args: parser.print_help() } dispatch[context.subcommand](context) From 9ff023a691fcd52feea4e9ba548178e26c95b0e9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 19:45:40 +0200 Subject: [PATCH 2/4] Run prek to reformat the code --- Tools/wasm/wasi/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/wasm/wasi/__main__.py b/Tools/wasm/wasi/__main__.py index 8594b5820f301ba..26b14d24e952ac9 100644 --- a/Tools/wasm/wasi/__main__.py +++ b/Tools/wasm/wasi/__main__.py @@ -580,7 +580,7 @@ def main(): "pythoninfo-host": pythoninfo_wasi_python, "build": build_steps(build_build_python, build_wasi_python), "clean": clean_contents, - None: lambda args: parser.print_help() + None: lambda args: parser.print_help(), } dispatch[context.subcommand](context) From c659efdc84ef718072b4e05bc03b4ff543314b9b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 19:48:02 +0200 Subject: [PATCH 3/4] empty commit From 29051b8d4b5247c1c246bfd91ef9fec0beb15a22 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 19:52:28 +0200 Subject: [PATCH 4/4] Replace Platforms/WASI with Tools/wasm/wasi --- .github/workflows/reusable-wasi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml index af9494e6af0ebec..eb26e248c15b5a1 100644 --- a/.github/workflows/reusable-wasi.yml +++ b/.github/workflows/reusable-wasi.yml @@ -51,7 +51,7 @@ jobs: - name: "Make build Python" run: python3 Tools/wasm/wasi make-build-python - name: "Display build info of the build Python" - run: python3 Platforms/WASI pythoninfo-build + run: python3 Tools/wasm/wasi pythoninfo-build - name: "Configure host/WASI Python" # `--with-pydebug` inferred from configure-build-python run: python3 Tools/wasm/wasi configure-host -- --config-cache