Skip to content

Commit 6426887

Browse files
authored
[3.14] gh-151929: Add pythoninfo commands to Tools/wasm/wasi (#152136) (#152224)
* gh-151929: Add pythoninfo commands to Platforms/WASI (#152136) The "build-python", "build-host" and "build" commands now also run "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)
1 parent 8162f61 commit 6426887

2 files changed

Lines changed: 46 additions & 8 deletions

File tree

.github/workflows/reusable-wasi.yml

Lines changed: 6 additions & 5 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 configure-build-python -- --config-cache --with-pydebug
5251
- name: "Make build Python"
5352
run: python3 Tools/wasm/wasi make-build-python
54-
- name: "Configure host"
53+
- name: "Display build info of the build Python"
54+
run: python3 Tools/wasm/wasi pythoninfo-build
55+
- name: "Configure host/WASI Python"
5556
# `--with-pydebug` inferred from configure-build-python
5657
run: python3 Tools/wasm/wasi configure-host -- --config-cache
57-
- name: "Make host"
58+
- name: "Make host/WASI Python"
5859
run: python3 Tools/wasm/wasi make-host
59-
- name: "Display build info"
60-
run: make --directory "${CROSS_BUILD_WASI}" pythoninfo
60+
- name: "Display build info of the host/WASI Python"
61+
run: python3 Tools/wasm/wasi pythoninfo-host
6162
- name: "Test"
6263
run: make --directory "${CROSS_BUILD_WASI}" test

Tools/wasm/wasi/__main__.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ def make_build_python(context, working_dir):
211211
log("🎉", f"{binary} {version}")
212212

213213

214+
@subdir(BUILD_DIR)
215+
def pythoninfo_build_python(context, working_dir):
216+
"""Display build info of the build Python."""
217+
call(["make", "pythoninfo"], context=context)
218+
219+
214220
def find_wasi_sdk():
215221
"""Find the path to the WASI SDK."""
216222
wasi_sdk_path = None
@@ -390,6 +396,12 @@ def make_wasi_python(context, working_dir):
390396
)
391397

392398

399+
@subdir(lambda context: CROSS_BUILD_DIR / context.host_triple)
400+
def pythoninfo_wasi_python(context, working_dir):
401+
"""Display build info of the host/WASI Python."""
402+
call(["make", "pythoninfo"], context=context)
403+
404+
393405
def clean_contents(context):
394406
"""Delete all files created by this script."""
395407
if CROSS_BUILD_DIR.exists():
@@ -443,6 +455,9 @@ def main():
443455
build_python = subcommands.add_parser(
444456
"build-python", help="Build the build Python"
445457
)
458+
pythoninfo_build = subcommands.add_parser(
459+
"pythoninfo-build", help="Display build info of the build Python"
460+
)
446461
configure_host = subcommands.add_parser(
447462
"configure-host",
448463
help="Run `configure` for the "
@@ -456,6 +471,9 @@ def main():
456471
build_host = subcommands.add_parser(
457472
"build-host", help="Build the host/WASI Python"
458473
)
474+
pythoninfo_host = subcommands.add_parser(
475+
"pythoninfo-host", help="Display build info of the host/WASI Python"
476+
)
459477
subcommands.add_parser(
460478
"clean", help="Delete files and directories created by this script"
461479
)
@@ -464,8 +482,10 @@ def main():
464482
configure_build,
465483
make_build,
466484
build_python,
485+
pythoninfo_build,
467486
configure_host,
468487
make_host,
488+
pythoninfo_host,
469489
build_host,
470490
):
471491
subcommand.add_argument(
@@ -520,7 +540,13 @@ def main():
520540
help="Command template for running the WASI host; defaults to "
521541
f"`{default_host_runner}`",
522542
)
523-
for subcommand in build, configure_host, make_host, build_host:
543+
for subcommand in (
544+
build,
545+
configure_host,
546+
make_host,
547+
build_host,
548+
pythoninfo_host,
549+
):
524550
subcommand.add_argument(
525551
"--host-triple",
526552
action="store",
@@ -532,18 +558,29 @@ def main():
532558
context = parser.parse_args()
533559
context.init_dir = pathlib.Path().absolute()
534560

535-
build_build_python = build_steps(configure_build_python, make_build_python)
536-
build_wasi_python = build_steps(configure_wasi_python, make_wasi_python)
561+
build_build_python = build_steps(
562+
configure_build_python,
563+
make_build_python,
564+
pythoninfo_build_python,
565+
)
566+
build_wasi_python = build_steps(
567+
configure_wasi_python,
568+
make_wasi_python,
569+
pythoninfo_wasi_python,
570+
)
537571

538572
dispatch = {
539573
"configure-build-python": configure_build_python,
540574
"make-build-python": make_build_python,
541575
"build-python": build_build_python,
576+
"pythoninfo-build": pythoninfo_build_python,
542577
"configure-host": configure_wasi_python,
543578
"make-host": make_wasi_python,
544579
"build-host": build_wasi_python,
580+
"pythoninfo-host": pythoninfo_wasi_python,
545581
"build": build_steps(build_build_python, build_wasi_python),
546582
"clean": clean_contents,
583+
None: lambda args: parser.print_help(),
547584
}
548585
dispatch[context.subcommand](context)
549586

0 commit comments

Comments
 (0)