]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-151929: Add pythoninfo-build command to Platforms/emscripten (GH-152210...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 25 Jun 2026 16:51:32 +0000 (18:51 +0200)
committerGitHub <noreply@github.com>
Thu, 25 Jun 2026 16:51:32 +0000 (16:51 +0000)
gh-151929: Add pythoninfo-build command to Platforms/emscripten (GH-152210)

* Add also "pythoninfo-host" command.
* Add pythoninfo to the "build" command.
(cherry picked from commit 7676427cd875a4b7b3d1ad8521b0de151b9e1e63)

Co-authored-by: Victor Stinner <vstinner@python.org>
.github/workflows/reusable-emscripten.yml
Platforms/emscripten/__main__.py

index 69a780a9aebc25e8a20bc947961fa2b794c64bf3..38e6dcceb8f47ca8c1f44f8415e90f373cb1c7c3 100644 (file)
@@ -63,15 +63,17 @@ jobs:
       run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug
     - name: "Make build Python"
       run: python3 Platforms/emscripten make-build-python
+    - name: "Display build info of the build Python"
+      run: python3 Platforms/emscripten pythoninfo-build
     - name: "Make dependencies"
       run: >-
         python3 Platforms/emscripten make-dependencies
         ${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }}
-    - name: "Configure host Python"
+    - name: "Configure host/Emscripten Python"
       run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
-    - name: "Make host Python"
+    - name: "Make host/Emscripten Python"
       run: python3 Platforms/emscripten make-host
-    - name: "Display build info"
-      run: python3 Platforms/emscripten run --pythoninfo
+    - name: "Display build info of the host/Emscripten Python"
+      run: python3 Platforms/emscripten pythoninfo-host
     - name: "Test"
       run: python3 Platforms/emscripten run --test
index c2fb1c4c36e6087262c429efe252b105b8d20b88..84a1589b81f6a20f2ee6a2171a35a2b0d50415da 100644 (file)
@@ -290,6 +290,12 @@ def make_build_python(context, working_dir):
     print(f"🎉 {binary} {version}")
 
 
+@subdir("native_build_dir")
+def pythoninfo_build_python(context, working_dir):
+    """Display build info of the build Python."""
+    call(["make", "pythoninfo"], quiet=context.quiet)
+
+
 def check_shasum(file: str, expected_shasum: str):
     with open(file, "rb") as f:
         digest = hashlib.file_digest(f, "sha256")
@@ -580,7 +586,7 @@ def make_emscripten_python(context, working_dir):
     subprocess.check_call([exec_script, "--version"])
 
 
-def run_emscripten_python(context):
+def run_emscripten_python(context, args=None):
     """Run the built emscripten Python."""
     host_dir = context.build_paths["host_dir"]
     exec_script = host_dir / "python.sh"
@@ -588,19 +594,25 @@ def run_emscripten_python(context):
         print("Emscripten not built", file=sys.stderr)
         sys.exit(1)
 
-    args = context.args
-    # Strip the "--" separator if present
-    if args and args[0] == "--":
-        args = args[1:]
+    if args is None:
+        args = context.args
+        # Strip the "--" separator if present
+        if args and args[0] == "--":
+            args = args[1:]
 
-    if context.test:
-        args = load_config_toml()["test-args"] + args
-    elif context.pythoninfo:
-        args = load_config_toml()["pythoninfo-args"] + args
+        if context.test:
+            args = load_config_toml()["test-args"] + args
+        elif context.pythoninfo:
+            args = load_config_toml()["pythoninfo-args"] + args
 
     os.execv(str(exec_script), [str(exec_script), *args])
 
 
+def pythoninfo_emscripten_python(context):
+    """Display build info of the host/Emscripten Python."""
+    run_emscripten_python(context, ["-m", "test.pythoninfo"])
+
+
 def build_target(context):
     """Build one or more targets."""
     steps = []
@@ -608,6 +620,7 @@ def build_target(context):
         steps.extend([
             configure_build_python,
             make_build_python,
+            pythoninfo_build_python,
         ])
     if context.target in {"host", "all"}:
         steps.extend([
@@ -615,6 +628,7 @@ def build_target(context):
             make_mpdec,
             configure_emscripten_python,
             make_emscripten_python,
+            pythoninfo_emscripten_python,
         ])
 
     for step in steps:
@@ -707,6 +721,10 @@ def main():
         "make-build-python", help="Run `make` for 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=(
@@ -719,6 +737,10 @@ def main():
         "make-host", help="Run `make` for the host/emscripten"
     )
 
+    pythoninfo_host = subcommands.add_parser(
+        "pythoninfo-host", help="Display build info of the host/Emscripten Python"
+    )
+
     run = subcommands.add_parser(
         "run",
         help="Run the built emscripten Python",
@@ -770,8 +792,10 @@ def main():
         make_mpdec_cmd,
         make_dependencies_cmd,
         make_build,
+        pythoninfo_build,
         configure_host,
         make_host,
+        pythoninfo_host,
         clean,
     ):
         subcommand.add_argument(
@@ -840,8 +864,10 @@ def main():
         "make-dependencies": make_dependencies,
         "configure-build-python": configure_build_python,
         "make-build-python": make_build_python,
+        "pythoninfo-build": pythoninfo_build_python,
         "configure-host": configure_emscripten_python,
         "make-host": make_emscripten_python,
+        "pythoninfo-host": pythoninfo_emscripten_python,
         "build": build_target,
         "run": run_emscripten_python,
         "clean": clean_contents,