@@ -671,7 +671,7 @@ class WindowsARM64ReleaseBuild(WindowsARM64Build):
671671 factory_tags = ["win-arm64" , "nondebug" ]
672672
673673##############################################################################
674- ############################## WASM BUILDS #################################
674+ ############################## WASI BUILDS #################################
675675##############################################################################
676676
677677
@@ -821,81 +821,28 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
821821 )
822822
823823
824- class Wasm32EmscriptenBuild (UnixCrossBuild ):
825- """wasm32-emscripten builder
826-
827- * Emscripten SDK >= 3.1.12 must be installed
828- * ccache must be installed
829- * Emscripten PATHs must be pre-pended to PATH
830- * ``which node`` must be equal $EMSDK_NODE
831- """
832- factory_tags = ["wasm" , "emscripten" ]
833- compile_environ = {
834- "CONFIG_SITE" : "../../Tools/wasm/config.site-wasm32-emscripten" ,
835- "EM_COMPILER_WRAPPER" : "ccache" ,
836- }
837-
838- host = "wasm32-unknown-emscripten"
839- host_configure_cmd = ["emconfigure" , "../../configure" ]
840- host_make_cmd = ["emmake" , "make" ]
841-
842-
843- class Wasm32EmscriptenNodePThreadsBuild (Wasm32EmscriptenBuild ):
844- """Emscripten with pthreads, testing with NodeJS
845- """
846- buildersuffix = ".emscripten-node-pthreads"
847- extra_configure_flags = [
848- # don't run with --with-pydebug, Emscripten has limited stack
849- "--without-pydebug" ,
850- "--with-emscripten-target=node" ,
851- "--disable-wasm-dynamic-linking" ,
852- "--enable-wasm-pthreads" ,
853- ]
854-
855-
856- class Wasm32EmscriptenNodeDLBuild (Wasm32EmscriptenBuild ):
857- """Emscripten with dynamic linking, testing with NodeJS
858- """
859- buildersuffix = ".emscripten-node-dl"
860- extra_configure_flags = [
861- # don't run with --with-pydebug, Emscripten has limited stack
862- "--without-pydebug" ,
863- "--with-emscripten-target=node" ,
864- "--enable-wasm-dynamic-linking" ,
865- "--disable-wasm-pthreads" ,
866- ]
867-
868-
869- class Wasm32EmscriptenBrowserBuild (Wasm32EmscriptenBuild ):
870- """Emscripten browser builds (no tests)
871- """
872- buildersuffix = ".emscripten-browser"
873- extra_configure_flags = [
874- # don't run with --with-pydebug, Emscripten has limited stack
875- "--without-pydebug" ,
876- "--with-emscripten-target=browser" ,
877- "--enable-wasm-dynamic-linking" ,
878- "--disable-wasm-pthreads" ,
879- ]
880- # browser builds do not accept argv from CLI
881- can_execute_python = False
882-
883-
884- class Wasm32WASIBuild (UnixCrossBuild ):
824+ # Deprecated since Python 3.13; can be dropped once `wasi.py` is in all versions.
825+ class Wasm32WasiCrossBuild (UnixCrossBuild ):
885826 """wasm32-wasi builder
886827
887828 * WASI SDK >= 16 must be installed to default path /opt/wasi-sdk
888829 * wasmtime must be installed and on PATH
889- * Tools/wasm/wasi-env detects presence of WASIX and ccache
890830 """
891- buildersuffix = ".wasi"
892- factory_tags = ["wasm" , "wasi" ]
831+
832+ buildersuffix = ".wasi.nondebug"
833+ factory_tags = ["wasm" , "wasi" , "nondebug" ]
893834 extra_configure_flags = [
894835 # debug builds exhaust the limited call stack on WASI
895836 "--without-pydebug" ,
896837 ]
897838 compile_environ = {
898839 "CONFIG_SITE" : "../../Tools/wasm/config.site-wasm32-wasi" ,
840+ # Silence warnings about using the old CLI as raised by wasmtime 14+.
841+ "WASMTIME_NEW_CLI" : "0" ,
842+ }
843+ test_environ = {
844+ # Silence warnings about using the old CLI as raised by wasmtime 14+.
845+ "WASMTIME_NEW_CLI" : "0" ,
899846 }
900847 host = "wasm32-unknown-wasi"
901848 host_configure_cmd = ["../../Tools/wasm/wasi-env" , "../../configure" ]
@@ -909,6 +856,105 @@ def setup(self, parallel, branch, test_with_PTY=False, **kwargs):
909856 haltOnFailure = True ,
910857 )
911858 )
912- super ().setup (
913- parallel , branch , test_with_PTY = test_with_PTY , ** kwargs
859+ super ().setup (parallel , branch , test_with_PTY = test_with_PTY , ** kwargs )
860+
861+
862+ class _Wasm32WasiBuild (UnixBuild ):
863+ """Build Python for wasm32-wasi using Tools/wasm/wasi.py."""
864+ buildersuffix = ".wasi"
865+ factory_tags = ["wasm" , "wasi" ]
866+ # pydebug and append_suffix defined in subclasses.
867+
868+ def __init__ (self , source , * , extra_tags = [], ** kwargs ):
869+ if not self .pydebug :
870+ extra_tags .append ("nondebug" )
871+ self .buildersuffix += self .append_suffix
872+ super ().__init__ (source , extra_tags = extra_tags , ** kwargs )
873+
874+ def setup (self , parallel , branch , test_with_PTY = False , ** kwargs ):
875+ wasi_py = "Tools/wasm/wasi.py"
876+ host_path = "build/wasm32-wasi"
877+
878+ # Build Python
879+ build_configure = ["python3" , wasi_py , "configure-build-python" ]
880+ if self .pydebug :
881+ build_configure .extend (["--" , "--with-pydebug" ])
882+ self .addStep (
883+ Configure (
884+ name = "Configure build Python" ,
885+ command = build_configure ,
886+ )
887+ )
888+ self .addStep (
889+ Compile (
890+ name = "Compile build Python" ,
891+ command = ["python3" , wasi_py , "make-build-python" ],
892+ )
914893 )
894+
895+ # Host/WASI Python
896+ self .addStep (
897+ # Pydebug build automatically inferred from build Python.
898+ Configure (
899+ name = "Configure host Python" ,
900+ command = ["python3" , wasi_py , "configure-host" ],
901+ )
902+ )
903+ self .addStep (
904+ Compile (
905+ name = "Compile host Python" ,
906+ command = ["python3" , wasi_py , "make-host" ],
907+ )
908+ )
909+
910+ self .addStep (
911+ ShellCommand (
912+ name = "pythoninfo" ,
913+ description = "pythoninfo" ,
914+ command = ["make" , "pythoninfo" ],
915+ warnOnFailure = True ,
916+ workdir = host_path ,
917+ )
918+ )
919+
920+ # Copied from UnixBuild.
921+ testopts = list (self .testFlags )
922+ if not has_option ("-R" , self .testFlags ):
923+ testopts .extend (("--junit-xml" , JUNIT_FILENAME ))
924+ if parallel :
925+ testopts .append (parallel )
926+ if not has_option ("-j" , testopts ):
927+ testopts .append ("-j2" )
928+ test = [
929+ "make" ,
930+ "buildbottest" ,
931+ "TESTOPTS=" + " " .join (testopts ) + " ${BUILDBOT_TESTOPTS}" ,
932+ f"TESTPYTHONOPTS={ self .interpreterFlags } " ,
933+ f"TESTTIMEOUT={ self .test_timeout } " ,
934+ ]
935+ self .addStep (
936+ Test (
937+ command = test ,
938+ timeout = step_timeout (self .test_timeout ),
939+ usePTY = test_with_PTY ,
940+ env = self .test_environ ,
941+ workdir = host_path ,
942+ )
943+ )
944+ if branch not in ("3" ,) and not has_option ("-R" , self .testFlags ):
945+ filename = os .path .join (host_path , JUNIT_FILENAME )
946+ self .addStep (UploadTestResults (branch , filename = filename ))
947+
948+ self .addStep (
949+ Clean (
950+ name = "Clean the builds" ,
951+ command = ["python3" , wasi_py , "clean" ],
952+ )
953+ )
954+
955+
956+ # Preventing this from running on versions older than 3.13 is managed in
957+ # master.cfg.
958+ class Wasm32WasiDebugBuild (_Wasm32WasiBuild ):
959+ append_suffix = ".debug"
960+ pydebug = True
0 commit comments