From 9a62314b1764fcd20a892f3a4350fbeccce0370b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 01:45:33 +0200 Subject: [PATCH 1/4] gh-151929: Add pythoninfo commands to Platforms/WASI The "build" command now runs also "pythoninfo-build" and "pythoninfo-host" commands. GitHub Action "WASI": * Run "pythoninfo-build" command. * Remove unused and outdated CROSS_BUILD_PYTHON environment variable. If no subcommand is provided, display the help. --- .github/workflows/reusable-wasi.yml | 7 ++++--- Platforms/WASI/__main__.py | 21 ++++++++++++++++++++- Platforms/WASI/_build.py | 12 ++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml index 48fb70cbff80095..39edad9a6f19c2b 100644 --- a/.github/workflows/reusable-wasi.yml +++ b/.github/workflows/reusable-wasi.yml @@ -16,7 +16,6 @@ jobs: timeout-minutes: 60 env: WASMTIME_VERSION: 38.0.3 - CROSS_BUILD_PYTHON: cross-build/build CROSS_BUILD_WASI: cross-build/wasm32-wasip1 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -54,6 +53,8 @@ jobs: run: python3 Platforms/WASI configure-build-python -- --config-cache --with-pydebug - name: "Make build Python" run: python3 Platforms/WASI make-build-python + - name: "Display build info of the build Python" + run: python3 Platforms/WASI pythoninfo-build - name: "Configure host" # `--with-pydebug` inferred from configure-build-python run: python3 Platforms/WASI configure-host -- --config-cache @@ -61,7 +62,7 @@ jobs: WASI_SDK_PATH: ${{ steps.install-wasi-sdk.outputs.wasi-sdk-path }} - name: "Make host" run: python3 Platforms/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 Platforms/WASI pythoninfo-host - name: "Test" run: make --directory "${CROSS_BUILD_WASI}" test diff --git a/Platforms/WASI/__main__.py b/Platforms/WASI/__main__.py index b8513a004f18e5f..5bc9737a15c6239 100644 --- a/Platforms/WASI/__main__.py +++ b/Platforms/WASI/__main__.py @@ -40,6 +40,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 " @@ -53,6 +56,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" ) @@ -61,8 +67,10 @@ def main(): configure_build, make_build, build_python, + pythoninfo_build, configure_host, make_host, + pythoninfo_host, build_host, ): subcommand.add_argument( @@ -118,7 +126,7 @@ 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", @@ -137,6 +145,8 @@ def main(): case "build-python": _build.configure_build_python(context) _build.make_build_python(context) + case "pythoninfo-build": + _build.pythoninfo_build_python(context) case "configure-host": _build.configure_wasi_python(context) case "make-host": @@ -144,13 +154,22 @@ def main(): case "build-host": _build.configure_wasi_python(context) _build.make_wasi_python(context) + case "pythoninfo-host": + _build.pythoninfo_wasi_python(context) case "build": + # Configure and build the build Python _build.configure_build_python(context) _build.make_build_python(context) + _build.pythoninfo_build_python(context) + + # Configure and build the host/WASI Python _build.configure_wasi_python(context) _build.make_wasi_python(context) + _build.pythoninfo_wasi_python(context) case "clean": _build.clean_contents(context) + case None: + parser.print_help() case _: raise ValueError(f"Unknown subcommand {context.subcommand!r}") diff --git a/Platforms/WASI/_build.py b/Platforms/WASI/_build.py index c1a91a9c833b8e8..68bc61a7823071a 100644 --- a/Platforms/WASI/_build.py +++ b/Platforms/WASI/_build.py @@ -418,3 +418,15 @@ def clean_contents(context): if LOCAL_SETUP.exists(): if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER: log("🧹", f"Deleting generated {LOCAL_SETUP} ...") + + +@subdir(BUILD_DIR) +def pythoninfo_build_python(context, working_dir): + """Display build info of the build Python.""" + call(["make", "pythoninfo"], context=context) + + +@subdir(lambda context: CROSS_BUILD_DIR / host_triple(context)) +def pythoninfo_wasi_python(context, working_dir): + """Display build info of the host Python.""" + call(["make", "pythoninfo"], context=context) From 9641edb258ff8b1adc2591db5ae3a2a97e040093 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 02:06:55 +0200 Subject: [PATCH 2/4] Run prek to reformat __main__.py --- Platforms/WASI/__main__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Platforms/WASI/__main__.py b/Platforms/WASI/__main__.py index 5bc9737a15c6239..880058bad660be9 100644 --- a/Platforms/WASI/__main__.py +++ b/Platforms/WASI/__main__.py @@ -126,7 +126,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, pythoninfo_host: + for subcommand in ( + build, + configure_host, + make_host, + build_host, + pythoninfo_host, + ): subcommand.add_argument( "--host-triple", action="store", From a1d1c4bf05c42ddb9b606309cef40f9a0e293539 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 16:51:48 +0200 Subject: [PATCH 3/4] Renable GHA steps Replace "host" with "host/WASI Python", as done in Platforms/WASI command line. --- .github/workflows/reusable-wasi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-wasi.yml b/.github/workflows/reusable-wasi.yml index 39edad9a6f19c2b..4b4888c38444092 100644 --- a/.github/workflows/reusable-wasi.yml +++ b/.github/workflows/reusable-wasi.yml @@ -55,12 +55,12 @@ jobs: run: python3 Platforms/WASI make-build-python - name: "Display build info of the build Python" run: python3 Platforms/WASI pythoninfo-build - - name: "Configure host" + - name: "Configure host/WASI Python" # `--with-pydebug` inferred from configure-build-python run: python3 Platforms/WASI configure-host -- --config-cache env: WASI_SDK_PATH: ${{ steps.install-wasi-sdk.outputs.wasi-sdk-path }} - - name: "Make host" + - name: "Make host/WASI Python" run: python3 Platforms/WASI make-host - name: "Display build info of the host/WASI Python" run: python3 Platforms/WASI pythoninfo-host From 013e20f381cd4e2c81d28e95f81d89eac6d2591d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 25 Jun 2026 18:16:52 +0200 Subject: [PATCH 4/4] Update docstring --- Platforms/WASI/_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platforms/WASI/_build.py b/Platforms/WASI/_build.py index 68bc61a7823071a..792f8edd9943138 100644 --- a/Platforms/WASI/_build.py +++ b/Platforms/WASI/_build.py @@ -428,5 +428,5 @@ def pythoninfo_build_python(context, working_dir): @subdir(lambda context: CROSS_BUILD_DIR / host_triple(context)) def pythoninfo_wasi_python(context, working_dir): - """Display build info of the host Python.""" + """Display build info of the host/WASI Python.""" call(["make", "pythoninfo"], context=context)