Skip to content

Commit 6c5390b

Browse files
committed
[3.14] pythongh-151929: Add pythoninfo commands to Tools/wasm/wasi.py (python#152136) (python#152224)
The "build" command now also runs "pythoninfo-build" and "pythoninfo-host" commands. If no subcommand is provided, display the help. GitHub Action "WASI": * Add "pythoninfo-build" and "pythoninfo-host" commands. * Remove unused and outdated CROSS_BUILD_PYTHON environment variable. (cherry picked from commit 7c81637) (cherry picked from commit 6426887)
1 parent 640c5f4 commit 6c5390b

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

.github/workflows/reusable-wasi.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
WASMTIME_VERSION: 38.0.3
1919
WASI_SDK_VERSION: 24
2020
WASI_SDK_PATH: /opt/wasi-sdk
21-
CROSS_BUILD_PYTHON: cross-build/build
2221
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2322
steps:
2423
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -51,12 +50,14 @@ jobs:
5150
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
5251
- name: "Make build Python"
5352
run: python3 Tools/wasm/wasi.py make-build-python
54-
- name: "Configure host"
53+
- name: "Display build info of the build Python"
54+
run: python3 Tools/wasm/wasi.py pythoninfo-build
55+
- name: "Configure host/WASI Python"
5556
# `--with-pydebug` inferred from configure-build-python
5657
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache
57-
- name: "Make host"
58+
- name: "Make host/WASI Python"
5859
run: python3 Tools/wasm/wasi.py make-host
5960
- name: "Display build info"
60-
run: make --directory "${CROSS_BUILD_WASI}" pythoninfo
61+
run: python3 Tools/wasm/wasi.py pythoninfo-host
6162
- name: "Test"
6263
run: make --directory "${CROSS_BUILD_WASI}" test

Tools/wasm/wasi.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ def make_build_python(context, working_dir):
171171
print(f"🎉 {binary} {version}")
172172

173173

174+
@subdir(BUILD_DIR)
175+
def pythoninfo_build_python(context, working_dir):
176+
"""Display build info of the build Python."""
177+
call(["make", "pythoninfo"], context=context)
178+
179+
174180
def find_wasi_sdk():
175181
"""Find the path to wasi-sdk."""
176182
if wasi_sdk_path := os.environ.get("WASI_SDK_PATH"):
@@ -316,13 +322,21 @@ def build_all(context):
316322
steps = [
317323
configure_build_python,
318324
make_build_python,
325+
pythoninfo_build_python,
319326
configure_wasi_python,
320327
make_wasi_python,
328+
pythoninfo_wasi_python,
321329
]
322330
for step in steps:
323331
step(context)
324332

325333

334+
@subdir(lambda context: CROSS_BUILD_DIR / context.host_triple)
335+
def pythoninfo_wasi_python(context, working_dir):
336+
"""Display build info of the host/WASI Python."""
337+
call(["make", "pythoninfo"], context=context)
338+
339+
326340
def clean_contents(context):
327341
"""Delete all files created by this script."""
328342
if CROSS_BUILD_DIR.exists():
@@ -364,6 +378,9 @@ def main():
364378
make_build = subcommands.add_parser(
365379
"make-build-python", help="Run `make` for the build Python"
366380
)
381+
pythoninfo_build = subcommands.add_parser(
382+
"pythoninfo-build", help="Display build info of the build Python"
383+
)
367384
configure_host = subcommands.add_parser(
368385
"configure-host",
369386
help="Run `configure` for the "
@@ -374,15 +391,20 @@ def main():
374391
make_host = subcommands.add_parser(
375392
"make-host", help="Run `make` for the host/WASI"
376393
)
394+
pythoninfo_host = subcommands.add_parser(
395+
"pythoninfo-host", help="Display build info of the host/WASI Python"
396+
)
377397
subcommands.add_parser(
378398
"clean", help="Delete files and directories created by this script"
379399
)
380400
for subcommand in (
381401
build,
382402
configure_build,
383403
make_build,
404+
pythoninfo_build,
384405
configure_host,
385406
make_host,
407+
pythoninfo_host,
386408
):
387409
subcommand.add_argument(
388410
"--quiet",
@@ -421,7 +443,12 @@ def main():
421443
"(default designed for wasmtime 14 or newer: "
422444
f"`{default_host_runner}`)",
423445
)
424-
for subcommand in build, configure_host, make_host:
446+
for subcommand in (
447+
build,
448+
configure_host,
449+
make_host,
450+
pythoninfo_host,
451+
):
425452
subcommand.add_argument(
426453
"--host-triple",
427454
action="store",
@@ -434,10 +461,13 @@ def main():
434461
dispatch = {
435462
"configure-build-python": configure_build_python,
436463
"make-build-python": make_build_python,
464+
"pythoninfo-build": pythoninfo_build_python,
437465
"configure-host": configure_wasi_python,
438466
"make-host": make_wasi_python,
467+
"pythoninfo-host": pythoninfo_wasi_python,
439468
"build": build_all,
440469
"clean": clean_contents,
470+
None: lambda args: parser.print_help(),
441471
}
442472
dispatch[context.subcommand](context)
443473

0 commit comments

Comments
 (0)