From b01a01a153234309563b1f53cf63913a9f08839c Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 16 Oct 2026 12:19:44 -0700 Subject: [PATCH 1/2] Add a builder that is agnostic to the WASI version This also caps the `wasm32-wasip1` builder to Python 3.15 as it's going to be the last version to support that triple. --- master/custom/builders.py | 4 +- master/custom/factories.py | 118 +++++++++++++++++++++++++++++++++++-- 2 files changed, 116 insertions(+), 6 deletions(-) diff --git a/master/custom/builders.py b/master/custom/builders.py index f781c69c..e9ac27a8 100644 --- a/master/custom/builders.py +++ b/master/custom/builders.py @@ -56,6 +56,7 @@ WindowsARM64ReleaseBuild, Wasm32WasiCrossBuild, Wasm32WasiPreview1DebugBuild, + Wasm32WasiPlatformDebugBuild, IOSARM64SimulatorBuild, AndroidBuild, EmscriptenBuild, @@ -281,7 +282,8 @@ def generate_builderdefs(tags, entries): ("x86-64 MacOS Intel ASAN NoGIL", "itamaro-macos-intel-aws", MacOSAsanNoGilBuild), # WASI - ("wasm32-wasi", "bcannon-wasi", Wasm32WasiPreview1DebugBuild), + ("wasm32-wasip1", "bcannon-wasi", Wasm32WasiPreview1DebugBuild), + ("wasm32-wasi", "bcannon-wasi", Wasm32WasiPlatformDebugBuild), # Windows aarch64 MSVC ("ARM64 Windows", "ware-win11-arm64", WindowsARM64Build), diff --git a/master/custom/factories.py b/master/custom/factories.py index c5ce171e..e3e37ecb 100644 --- a/master/custom/factories.py +++ b/master/custom/factories.py @@ -10,7 +10,7 @@ from buildbot.plugins import util from . import JUNIT_FILENAME -from .branches import BRANCHES +from .branches import BRANCHES, BranchSet from .steps import ( Test, Clean, @@ -976,6 +976,7 @@ def setup(self, branch, worker, test_with_PTY=False, **kwargs): super().setup(branch, worker, test_with_PTY=test_with_PTY, **kwargs) +# This can go once Wasm32WasiPreview1DebugBuild is removed post-3.15. class _Wasm32WasiPreview1Build(UnixBuild): """Build Python for wasm32-wasi using Tools/wasm/wasi.py.""" buildersuffix = ".wasi" @@ -987,8 +988,12 @@ def __init__(self, source, *, extra_tags=[], **kwargs): extra_tags.append("nondebug") self.buildersuffix += self.append_suffix if self.pydebug: - # The debug buildbot is meant for 3.13+, where WASM is tier 2 - self.branches = BRANCHES.only_since(3, 13) + # The debug buildbot is meant for 3.13+, where WASM is tier 2. + # This builder is only needed up to 3.15 as that's the last version + # using wasm32-wasip1. + floor = BRANCHES.only_since(3, 13) + ceiling = BRANCHES.only_until(3, 15) + self.branches = BranchSet([*floor, *ceiling]) else: # The non-debug WASI buildbot is meant for 3.11 and 3.12 only. # Don't use it on PRs; it's tier 3 only and getting it to @@ -1076,14 +1081,117 @@ def setup(self, branch, worker, test_with_PTY=False, **kwargs): ) -# Preventing this from running on versions older than 3.13 is managed in -# workers.py. +# Only needed for Python 3.13 - Python 3.15. class Wasm32WasiPreview1DebugBuild(_Wasm32WasiPreview1Build): append_suffix = ".debug" pydebug = True testFlags = ["-u-cpu"] +class Wasm32WasiPlatformDebugBuild(UnixBuild): + factory_tags = ["wasm", "wasi"] + buildersuffix = ".wasi" + pydebug = True + append_suffix = ".debug" + + testFlags = ["-u-cpu"] + + def __init__(self, source, *, extra_tags=[], **kwargs): + if self.pydebug: + self.buildersuffix += self.append_suffix + # `Platforms/WASI` was introduced in Python 3.15. + # `Platforms/WASI path` was introduced in Python 3.16. + self.branches = BRANCHES.only_since(3, 16) + super().__init__(source, extra_tags=extra_tags, **kwargs) + + def setup(self, branch, worker, test_with_PTY=False, **kwargs): + wasi_py = "Platforms/WASI" + self.addStep( + SetPropertyFromCommand( + name="Determine WASI host path", + command=["python3", wasi_py, "path"], + property="wasi_host_path", + haltOnFailure=True, + ) + ) + + # Build Python + build_configure = ["python3", wasi_py, "configure-build-python"] + if self.pydebug: + build_configure.extend(["--", "--with-pydebug"]) + self.addStep( + Configure( + name="Configure build Python", + command=build_configure, + ) + ) + self.addStep( + Compile( + name="Compile build Python", + command=["python3", wasi_py, "make-build-python"], + ) + ) + self.addStep( + PythonInfo( + name="Display build info of the build Python", + command=["python3", wasi_py, "pythoninfo-build"], + ) + ) + + # Host/WASI Python + self.addStep( + # Pydebug build automatically inferred from build Python. + Configure( + name="Configure host Python", + command=["python3", wasi_py, "configure-host"], + ) + ) + self.addStep( + Compile( + name="Compile host Python", + command=["python3", wasi_py, "make-host"], + ) + ) + + self.addStep( + PythonInfo( + name="Display build info of the host/WASI Python", + command=["python3", wasi_py, "pythoninfo-host"], + ) + ) + + # Copied from UnixBuild. + testopts = self.create_test_opts(branch, worker) + test = [ + "make", + "buildbottest", + "TESTOPTS=" + " ".join(testopts) + " ${BUILDBOT_TESTOPTS}", + f"TESTPYTHONOPTS={self.interpreterFlags}", + f"TESTTIMEOUT={self.test_timeout}", + ] + self.addStep( + Test( + command=test, + timeout=step_timeout(self.test_timeout), + usePTY=test_with_PTY, + env=self.test_environ, + workdir=util.Property("wasi_host_path"), + ) + ) + if not branch.is_pr and not has_option("-R", self.testFlags): + filename = util.Interpolate( + f"%(prop:wasi_host_path)s/{JUNIT_FILENAME}" + ) + self.addStep(UploadTestResults(branch, filename=filename)) + + self.addStep( + Clean( + name="Clean the builds", + command=["python3", wasi_py, "clean"], + ) + ) + + ############################################################################## ################################ IOS BUILDS ################################ ############################################################################## From 7b5ab7cb090ceb1e6386ebe963df1e3631ea3239 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 16 Oct 2026 12:27:09 -0700 Subject: [PATCH 2/2] Try to deal with the duplicate builder issue --- master/custom/factories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/custom/factories.py b/master/custom/factories.py index e3e37ecb..8a6c965f 100644 --- a/master/custom/factories.py +++ b/master/custom/factories.py @@ -979,7 +979,7 @@ def setup(self, branch, worker, test_with_PTY=False, **kwargs): # This can go once Wasm32WasiPreview1DebugBuild is removed post-3.15. class _Wasm32WasiPreview1Build(UnixBuild): """Build Python for wasm32-wasi using Tools/wasm/wasi.py.""" - buildersuffix = ".wasi" + buildersuffix = ".wasip1" factory_tags = ["wasm", "wasi"] # pydebug and append_suffix defined in subclasses.