Skip to content

Commit 12befad

Browse files
committed
gh-151929: Add pythoninfo-build command to Platforms/emscripten
Replace also "run --test" with "pythoninfo-host" command.
1 parent 56ae0b8 commit 12befad

3 files changed

Lines changed: 34 additions & 15 deletions

File tree

.github/workflows/reusable-emscripten.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ jobs:
6363
run: python3 Platforms/emscripten configure-build-python -- --config-cache --with-pydebug
6464
- name: "Make build Python"
6565
run: python3 Platforms/emscripten make-build-python
66+
- name: "Display build info of the build Python"
67+
run: python3 Platforms/emscripten pythoninfo-build
6668
- name: "Make dependencies"
6769
run: >-
6870
python3 Platforms/emscripten make-dependencies
6971
${{ steps.emsdk-cache.outputs.cache-hit == 'true' && '--check-up-to-date' || '' }}
70-
- name: "Configure host Python"
72+
- name: "Configure host/Emscripten Python"
7173
run: python3 Platforms/emscripten configure-host --host-runner node -- --config-cache
72-
- name: "Make host Python"
74+
- name: "Make host/Emscripten Python"
7375
run: python3 Platforms/emscripten make-host
74-
- name: "Display build info"
75-
run: python3 Platforms/emscripten run --pythoninfo
76+
- name: "Display build info of the host/Emscripten Python"
77+
run: python3 Platforms/emscripten pythoninfo-host
7678
- name: "Test"
7779
run: python3 Platforms/emscripten run --test

Platforms/emscripten/__main__.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ def make_build_python(context, working_dir):
290290
print(f"🎉 {binary} {version}")
291291

292292

293+
@subdir("native_build_dir")
294+
def pythoninfo_build(context, working_dir):
295+
"""Display build info for the build Python."""
296+
call(["make", "pythoninfo"], quiet=context.quiet)
297+
298+
293299
def check_shasum(file: str, expected_shasum: str):
294300
with open(file, "rb") as f:
295301
digest = hashlib.file_digest(f, "sha256")
@@ -580,6 +586,16 @@ def make_emscripten_python(context, working_dir):
580586
subprocess.check_call([exec_script, "--version"])
581587

582588

589+
@subdir("host_dir")
590+
def pythoninfo_emscripten_python(context, working_dir):
591+
"""Display build info for the host/Emscripten Python."""
592+
call(
593+
["make", "pythoninfo"],
594+
env=updated_env({}, context.emsdk_cache),
595+
quiet=context.quiet,
596+
)
597+
598+
583599
def run_emscripten_python(context):
584600
"""Run the built emscripten Python."""
585601
host_dir = context.build_paths["host_dir"]
@@ -595,8 +611,6 @@ def run_emscripten_python(context):
595611

596612
if context.test:
597613
args = load_config_toml()["test-args"] + args
598-
elif context.pythoninfo:
599-
args = load_config_toml()["pythoninfo-args"] + args
600614

601615
os.execv(str(exec_script), [str(exec_script), *args])
602616

@@ -707,6 +721,10 @@ def main():
707721
"make-build-python", help="Run `make` for the build Python"
708722
)
709723

724+
pythoninfo_build = subcommands.add_parser(
725+
"pythoninfo-build", help="Display build info for the build Python"
726+
)
727+
710728
configure_host = subcommands.add_parser(
711729
"configure-host",
712730
help=(
@@ -719,6 +737,10 @@ def main():
719737
"make-host", help="Run `make` for the host/emscripten"
720738
)
721739

740+
pythoninfo_host = subcommands.add_parser(
741+
"pythoninfo-host", help="Display build info for the host/Emscripten Python"
742+
)
743+
722744
run = subcommands.add_parser(
723745
"run",
724746
help="Run the built emscripten Python",
@@ -732,12 +754,6 @@ def main():
732754
"Default arguments loaded from Platforms/emscripten/config.toml"
733755
),
734756
)
735-
run.add_argument(
736-
"--pythoninfo",
737-
action="store_true",
738-
default=False,
739-
help="Run -m test.pythoninfo",
740-
)
741757
run.add_argument(
742758
"args",
743759
nargs=argparse.REMAINDER,
@@ -770,8 +786,10 @@ def main():
770786
make_mpdec_cmd,
771787
make_dependencies_cmd,
772788
make_build,
789+
pythoninfo_build,
773790
configure_host,
774791
make_host,
792+
pythoninfo_host,
775793
clean,
776794
):
777795
subcommand.add_argument(
@@ -840,8 +858,10 @@ def main():
840858
"make-dependencies": make_dependencies,
841859
"configure-build-python": configure_build_python,
842860
"make-build-python": make_build_python,
861+
"pythoninfo-build": pythoninfo_build,
843862
"configure-host": configure_emscripten_python,
844863
"make-host": make_emscripten_python,
864+
"pythoninfo-host": pythoninfo_emscripten_python,
845865
"build": build_target,
846866
"run": run_emscripten_python,
847867
"clean": clean_contents,

Platforms/emscripten/config.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ test-args = [
1111
"--single-process",
1212
"-W",
1313
]
14-
pythoninfo-args = [
15-
"-m", "test.pythoninfo",
16-
]
1714

1815
[dependencies.libffi]
1916
url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz"

0 commit comments

Comments
 (0)