]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] Touch up `Setup.local` handling in `Tools/wasm/wasi` (GH-137051) (GH-137053)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 7 Oct 2025 20:58:53 +0000 (22:58 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Oct 2025 20:58:53 +0000 (20:58 +0000)
Touch up `Setup.local` handling in `Tools/wasm/wasi` (GH-137051)

The comment in the generated file is now more self-explanatory. The checks for unexpected file contents are also strengthened.
(cherry picked from commit ec7fad79d24e79961b86e17177a32b32bb340fe5)

Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Tools/wasm/wasi/__main__.py

index 54ccc95157d57dbfb186bc1e6b77ed7188345c71..f3c97ff3fd11a015b2e3f3224b773a30b0bb7656 100644 (file)
@@ -23,7 +23,8 @@ CROSS_BUILD_DIR = CHECKOUT / "cross-build"
 BUILD_DIR = CROSS_BUILD_DIR / "build"
 
 LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
-LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/wasi.py\n".encode("utf-8")
+LOCAL_SETUP_MARKER = ("# Generated by Tools/wasm/wasi .\n"
+                      "# Required to statically build extension modules.").encode("utf-8")
 
 WASMTIME_VAR_NAME = "WASMTIME"
 WASMTIME_HOST_RUNNER_VAR = f"{{{WASMTIME_VAR_NAME}}}"
@@ -141,9 +142,12 @@ def build_python_is_pydebug():
 def configure_build_python(context, working_dir):
     """Configure the build/host Python."""
     if LOCAL_SETUP.exists():
-        print(f"๐Ÿ‘ {LOCAL_SETUP} exists ...")
+        if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER:
+            print(f"๐Ÿ‘ {LOCAL_SETUP} exists ...")
+        else:
+            print(f"โš ๏ธ {LOCAL_SETUP} exists, but has unexpected contents")
     else:
-        print(f"๐Ÿ“ Touching {LOCAL_SETUP} ...")
+        print(f"๐Ÿ“ Creating {LOCAL_SETUP} ...")
         LOCAL_SETUP.write_bytes(LOCAL_SETUP_MARKER)
 
     configure = [os.path.relpath(CHECKOUT / 'configure', working_dir)]
@@ -297,9 +301,8 @@ def clean_contents(context):
         shutil.rmtree(CROSS_BUILD_DIR)
 
     if LOCAL_SETUP.exists():
-        with LOCAL_SETUP.open("rb") as file:
-            if file.read(len(LOCAL_SETUP_MARKER)) == LOCAL_SETUP_MARKER:
-                print(f"๐Ÿงน Deleting generated {LOCAL_SETUP} ...")
+        if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER:
+            print(f"๐Ÿงน Deleting generated {LOCAL_SETUP} ...")
 
 
 def main():