]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-137484: Have `Tools/wasm/wasi` use the build triple instead of "build" (GH-37485)
authorBrett Cannon <brett@python.org>
Wed, 6 Aug 2025 19:28:54 +0000 (12:28 -0700)
committerGitHub <noreply@github.com>
Wed, 6 Aug 2025 19:28:54 +0000 (12:28 -0700)
This should help prevent issuse where something like a container is used to do one build and then someone tries to build again locally.

Misc/NEWS.d/next/Tools-Demos/2025-08-06-11-54-55.gh-issue-137484.8iFAQs.rst [new file with mode: 0644]
Tools/wasm/wasi/__main__.py

diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-08-06-11-54-55.gh-issue-137484.8iFAQs.rst b/Misc/NEWS.d/next/Tools-Demos/2025-08-06-11-54-55.gh-issue-137484.8iFAQs.rst
new file mode 100644 (file)
index 0000000..bd7bc09
--- /dev/null
@@ -0,0 +1,2 @@
+Have ``Tools/wasm/wasi`` put the build Python into a directory named after
+the build triple instead of "build".
index fdd93d5c0aa4af31038e7b61ed699045cc19d2e8..973d78caa0849e8e33e92ae184e8a886f01a7df1 100644 (file)
@@ -20,7 +20,8 @@ CHECKOUT = pathlib.Path(__file__).parent.parent.parent.parent
 assert (CHECKOUT / "configure").is_file(), "Please update the location of the file"
 
 CROSS_BUILD_DIR = CHECKOUT / "cross-build"
-BUILD_DIR = CROSS_BUILD_DIR / "build"
+# Build platform can also be found via `config.guess`.
+BUILD_DIR = CROSS_BUILD_DIR / sysconfig.get_config_var("BUILD_GNU_TYPE")
 
 LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
 LOCAL_SETUP_MARKER = ("# Generated by Tools/wasm/wasi .\n"
@@ -80,7 +81,7 @@ def subdir(working_dir, *, clean_ok=False):
             print("📁", working_dir)
             if (clean_ok and getattr(context, "clean", False) and
                 working_dir.exists()):
-                print(f"🚮 Deleting directory (--clean)...")
+                print("🚮 Deleting directory (--clean)...")
                 shutil.rmtree(working_dir)
 
             working_dir.mkdir(parents=True, exist_ok=True)
@@ -120,12 +121,6 @@ def call(command, *, context=None, quiet=False, logdir=None, **kwargs):
     subprocess.check_call(command, **kwargs, stdout=stdout, stderr=stderr)
 
 
-def build_platform():
-    """The name of the build/host platform."""
-    # Can also be found via `config.guess`.
-    return sysconfig.get_config_var("BUILD_GNU_TYPE")
-
-
 def build_python_path():
     """The path to the build Python binary."""
     binary = BUILD_DIR / "python"
@@ -274,7 +269,7 @@ def configure_wasi_python(context, working_dir):
     # executed from within a checkout.
     configure = [os.path.relpath(CHECKOUT / 'configure', working_dir),
                     f"--host={context.host_triple}",
-                    f"--build={build_platform()}",
+                    f"--build={BUILD_DIR.name}",
                     f"--with-build-python={build_python}"]
     if build_python_is_pydebug():
         configure.append("--with-pydebug")
@@ -357,8 +352,8 @@ def main():
                                                  "Python)")
     make_host = subcommands.add_parser("make-host",
                                        help="Run `make` for the host/WASI")
-    clean = subcommands.add_parser("clean", help="Delete files and directories "
-                                                 "created by this script")
+    subcommands.add_parser("clean", help="Delete files and directories "
+                                         "created by this script")
     for subcommand in build, configure_build, make_build, configure_host, make_host:
         subcommand.add_argument("--quiet", action="store_true", default=False,
                         dest="quiet",