Skip to content

Commit 0d58495

Browse files
brettcannonmiss-islington
authored andcommitted
GH-137484: Have Tools/wasm/wasi use the build triple instead of "build" (GH-37485)
This should help prevent issuse where something like a container is used to do one build and then someone tries to build again locally. (cherry picked from commit 0953200) Co-authored-by: Brett Cannon <brett@python.org>
1 parent 43d8f52 commit 0d58495

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Have ``Tools/wasm/wasi`` put the build Python into a directory named after
2+
the build triple instead of "build".

Tools/wasm/wasi/__main__.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
assert (CHECKOUT / "configure").is_file(), "Please update the location of the file"
2121

2222
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
23-
BUILD_DIR = CROSS_BUILD_DIR / "build"
23+
# Build platform can also be found via `config.guess`.
24+
BUILD_DIR = CROSS_BUILD_DIR / sysconfig.get_config_var("BUILD_GNU_TYPE")
2425

2526
LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
2627
LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/wasi.py\n".encode("utf-8")
@@ -77,7 +78,7 @@ def wrapper(context):
7778
print("📁", working_dir)
7879
if (clean_ok and getattr(context, "clean", False) and
7980
working_dir.exists()):
80-
print(f"🚮 Deleting directory (--clean)...")
81+
print("🚮 Deleting directory (--clean)...")
8182
shutil.rmtree(working_dir)
8283

8384
working_dir.mkdir(parents=True, exist_ok=True)
@@ -110,12 +111,6 @@ def call(command, *, quiet, **kwargs):
110111
subprocess.check_call(command, **kwargs, stdout=stdout, stderr=stderr)
111112

112113

113-
def build_platform():
114-
"""The name of the build/host platform."""
115-
# Can also be found via `config.guess`.
116-
return sysconfig.get_config_var("BUILD_GNU_TYPE")
117-
118-
119114
def build_python_path():
120115
"""The path to the build Python binary."""
121116
binary = BUILD_DIR / "python"
@@ -249,7 +244,7 @@ def configure_wasi_python(context, working_dir):
249244
# executed from within a checkout.
250245
configure = [os.path.relpath(CHECKOUT / 'configure', working_dir),
251246
f"--host={context.host_triple}",
252-
f"--build={build_platform()}",
247+
f"--build={BUILD_DIR.name}",
253248
f"--with-build-python={build_python}"]
254249
if build_python_is_pydebug():
255250
configure.append("--with-pydebug")
@@ -330,8 +325,8 @@ def main():
330325
"Python)")
331326
make_host = subcommands.add_parser("make-host",
332327
help="Run `make` for the host/WASI")
333-
clean = subcommands.add_parser("clean", help="Delete files and directories "
334-
"created by this script")
328+
subcommands.add_parser("clean", help="Delete files and directories "
329+
"created by this script")
335330
for subcommand in build, configure_build, make_build, configure_host, make_host:
336331
subcommand.add_argument("--quiet", action="store_true", default=False,
337332
dest="quiet",

0 commit comments

Comments
 (0)