https://github.com/python/cpython/commit/5a639ca1b316101d24e7219841d3c73d559be370
commit: 5a639ca1b316101d24e7219841d3c73d559be370
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: brettcannon <[email protected]>
date: 2025-12-05T15:04:50-08:00
summary:

[3.14] Introduce `build-python` and `build-host` subcommands for 
`Tools/wasm/wasi` (GH-142266) (#142322)

Introduce `build-python` and `build-host` subcommands for `Tools/wasm/wasi` 
(GH-142266)

It should make it easier when you need to rebuild just the e.g. host Python, 
but it requires ./configure to run.
(cherry picked from commit 58e1c7a16f0926b1047c336eeed2849d5fff7c70)

Co-authored-by: Brett Cannon <[email protected]>
Co-authored-by: Emma Smith <[email protected]>

files:
M Tools/wasm/wasi/__main__.py

diff --git a/Tools/wasm/wasi/__main__.py b/Tools/wasm/wasi/__main__.py
index 62085dc0e64030..b57bcaca924380 100644
--- a/Tools/wasm/wasi/__main__.py
+++ b/Tools/wasm/wasi/__main__.py
@@ -389,18 +389,6 @@ def make_wasi_python(context, working_dir):
     )
 
 
-def build_all(context):
-    """Build everything."""
-    steps = [
-        configure_build_python,
-        make_build_python,
-        configure_wasi_python,
-        make_wasi_python,
-    ]
-    for step in steps:
-        step(context)
-
-
 def clean_contents(context):
     """Delete all files created by this script."""
     if CROSS_BUILD_DIR.exists():
@@ -412,6 +400,16 @@ def clean_contents(context):
             log("🧹", f"Deleting generated {LOCAL_SETUP} ...")
 
 
+def build_steps(*steps):
+    """Construct a command from other steps."""
+
+    def builder(context):
+        for step in steps:
+            step(context)
+
+    return builder
+
+
 def main():
     default_host_triple = "wasm32-wasip1"
     default_wasi_sdk = find_wasi_sdk()
@@ -439,6 +437,9 @@ def main():
     make_build = subcommands.add_parser(
         "make-build-python", help="Run `make` for the build Python"
     )
+    build_python = subcommands.add_parser(
+        "build-python", help="Build the build Python"
+    )
     configure_host = subcommands.add_parser(
         "configure-host",
         help="Run `configure` for the "
@@ -449,6 +450,9 @@ def main():
     make_host = subcommands.add_parser(
         "make-host", help="Run `make` for the host/WASI"
     )
+    build_host = subcommands.add_parser(
+        "build-host", help="Build the host/WASI Python"
+    )
     subcommands.add_parser(
         "clean", help="Delete files and directories created by this script"
     )
@@ -456,8 +460,10 @@ def main():
         build,
         configure_build,
         make_build,
+        build_python,
         configure_host,
         make_host,
+        build_host,
     ):
         subcommand.add_argument(
             "--quiet",
@@ -472,7 +478,12 @@ def main():
             default=default_logdir,
             help=f"Directory to store log files; defaults to {default_logdir}",
         )
-    for subcommand in configure_build, configure_host:
+    for subcommand in (
+        configure_build,
+        configure_host,
+        build_python,
+        build_host,
+    ):
         subcommand.add_argument(
             "--clean",
             action="store_true",
@@ -480,11 +491,17 @@ def main():
             dest="clean",
             help="Delete any relevant directories before building",
         )
-    for subcommand in build, configure_build, configure_host:
+    for subcommand in (
+        build,
+        configure_build,
+        configure_host,
+        build_python,
+        build_host,
+    ):
         subcommand.add_argument(
             "args", nargs="*", help="Extra arguments to pass to `configure`"
         )
-    for subcommand in build, configure_host:
+    for subcommand in build, configure_host, build_host:
         subcommand.add_argument(
             "--wasi-sdk",
             type=pathlib.Path,
@@ -500,7 +517,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:
+    for subcommand in build, configure_host, make_host, build_host:
         subcommand.add_argument(
             "--host-triple",
             action="store",
@@ -512,12 +529,17 @@ 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)
+
     dispatch = {
         "configure-build-python": configure_build_python,
         "make-build-python": make_build_python,
+        "build-python": build_build_python,
         "configure-host": configure_wasi_python,
         "make-host": make_wasi_python,
-        "build": build_all,
+        "build-host": build_wasi_python,
+        "build": build_steps(build_build_python, build_wasi_python),
         "clean": clean_contents,
     }
     dispatch[context.subcommand](context)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to