Skip to content

Commit 7c81637

Browse files
authored
gh-151929: Add pythoninfo commands to Platforms/WASI (#152136)
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.
1 parent 7676427 commit 7c81637

3 files changed

Lines changed: 44 additions & 6 deletions

File tree

.github/workflows/reusable-wasi.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
timeout-minutes: 60
1717
env:
1818
WASMTIME_VERSION: 38.0.3
19-
CROSS_BUILD_PYTHON: cross-build/build
2019
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2120
steps:
2221
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -54,14 +53,16 @@ jobs:
5453
run: python3 Platforms/WASI configure-build-python -- --config-cache --with-pydebug
5554
- name: "Make build Python"
5655
run: python3 Platforms/WASI make-build-python
57-
- name: "Configure host"
56+
- name: "Display build info of the build Python"
57+
run: python3 Platforms/WASI pythoninfo-build
58+
- name: "Configure host/WASI Python"
5859
# `--with-pydebug` inferred from configure-build-python
5960
run: python3 Platforms/WASI configure-host -- --config-cache
6061
env:
6162
WASI_SDK_PATH: ${{ steps.install-wasi-sdk.outputs.wasi-sdk-path }}
62-
- name: "Make host"
63+
- name: "Make host/WASI Python"
6364
run: python3 Platforms/WASI make-host
64-
- name: "Display build info"
65-
run: make --directory "${CROSS_BUILD_WASI}" pythoninfo
65+
- name: "Display build info of the host/WASI Python"
66+
run: python3 Platforms/WASI pythoninfo-host
6667
- name: "Test"
6768
run: make --directory "${CROSS_BUILD_WASI}" test

Platforms/WASI/__main__.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def main():
4040
build_python = subcommands.add_parser(
4141
"build-python", help="Build the build Python"
4242
)
43+
pythoninfo_build = subcommands.add_parser(
44+
"pythoninfo-build", help="Display build info of the build Python"
45+
)
4346
configure_host = subcommands.add_parser(
4447
"configure-host",
4548
help="Run `configure` for the "
@@ -53,6 +56,9 @@ def main():
5356
build_host = subcommands.add_parser(
5457
"build-host", help="Build the host/WASI Python"
5558
)
59+
pythoninfo_host = subcommands.add_parser(
60+
"pythoninfo-host", help="Display build info of the host/WASI Python"
61+
)
5662
subcommands.add_parser(
5763
"clean", help="Delete files and directories created by this script"
5864
)
@@ -61,8 +67,10 @@ def main():
6167
configure_build,
6268
make_build,
6369
build_python,
70+
pythoninfo_build,
6471
configure_host,
6572
make_host,
73+
pythoninfo_host,
6674
build_host,
6775
):
6876
subcommand.add_argument(
@@ -118,7 +126,13 @@ def main():
118126
help="Command template for running the WASI host; defaults to "
119127
f"`{default_host_runner}`",
120128
)
121-
for subcommand in build, configure_host, make_host, build_host:
129+
for subcommand in (
130+
build,
131+
configure_host,
132+
make_host,
133+
build_host,
134+
pythoninfo_host,
135+
):
122136
subcommand.add_argument(
123137
"--host-triple",
124138
action="store",
@@ -137,20 +151,31 @@ def main():
137151
case "build-python":
138152
_build.configure_build_python(context)
139153
_build.make_build_python(context)
154+
case "pythoninfo-build":
155+
_build.pythoninfo_build_python(context)
140156
case "configure-host":
141157
_build.configure_wasi_python(context)
142158
case "make-host":
143159
_build.make_wasi_python(context)
144160
case "build-host":
145161
_build.configure_wasi_python(context)
146162
_build.make_wasi_python(context)
163+
case "pythoninfo-host":
164+
_build.pythoninfo_wasi_python(context)
147165
case "build":
166+
# Configure and build the build Python
148167
_build.configure_build_python(context)
149168
_build.make_build_python(context)
169+
_build.pythoninfo_build_python(context)
170+
171+
# Configure and build the host/WASI Python
150172
_build.configure_wasi_python(context)
151173
_build.make_wasi_python(context)
174+
_build.pythoninfo_wasi_python(context)
152175
case "clean":
153176
_build.clean_contents(context)
177+
case None:
178+
parser.print_help()
154179
case _:
155180
raise ValueError(f"Unknown subcommand {context.subcommand!r}")
156181

Platforms/WASI/_build.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,15 @@ def clean_contents(context):
418418
if LOCAL_SETUP.exists():
419419
if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER:
420420
log("🧹", f"Deleting generated {LOCAL_SETUP} ...")
421+
422+
423+
@subdir(BUILD_DIR)
424+
def pythoninfo_build_python(context, working_dir):
425+
"""Display build info of the build Python."""
426+
call(["make", "pythoninfo"], context=context)
427+
428+
429+
@subdir(lambda context: CROSS_BUILD_DIR / host_triple(context))
430+
def pythoninfo_wasi_python(context, working_dir):
431+
"""Display build info of the host/WASI Python."""
432+
call(["make", "pythoninfo"], context=context)

0 commit comments

Comments
 (0)