@@ -147,6 +147,8 @@ def check_sdl_version() -> None:
147147 """Check the local SDL3 version on Linux distributions."""
148148 if not sys .platform .startswith ("linux" ):
149149 return
150+ if "PYODIDE" in os .environ :
151+ return
150152 needed_version = f"{ SDL_MIN_VERSION [0 ]} .{ SDL_MIN_VERSION [1 ]} .{ SDL_MIN_VERSION [2 ]} "
151153 try :
152154 sdl_version_str = subprocess .check_output (
@@ -280,12 +282,14 @@ def on_directive_handle(
280282 return super ().on_directive_handle (directive , tokens , if_passthru , preceding_tokens )
281283
282284
283- def get_emscripten_include_dir () -> Path :
284- """Find and return the Emscripten include dir."""
285- # None of the EMSDK environment variables exist! Search PATH for Emscripten as a workaround
285+ def get_emscripten_dir () -> Path :
286+ """Find and return the Emscripten directory."""
287+ if "EMSDK" in os .environ :
288+ return Path (os .environ ["EMSDK" ], "upstream/emscripten" )
289+ # Search PATH for Emscripten as a workaround
286290 for path in os .environ ["PATH" ].split (os .pathsep )[::- 1 ]:
287- if Path (path ).match ("upstream/emscripten" ):
288- return Path (path , "system/include" ).resolve (strict = True )
291+ if Path (path ).match ("emsdk/ upstream/emscripten" ):
292+ return Path (path ).resolve (strict = True )
289293 raise AssertionError (os .environ ["PATH" ])
290294
291295
@@ -298,7 +302,11 @@ def get_emscripten_include_dir() -> Path:
298302 SDL_BUNDLE_PATH = unpack_sdl (SDL_BUNDLE_VERSION )
299303
300304SDL_INCLUDE : Path
301- if sys .platform == "win32" and SDL_PARSE_PATH is not None :
305+ if "PYODIDE" in os .environ :
306+ embuilder = Path (get_emscripten_dir (), "embuilder" )
307+ subprocess .run ([embuilder , "build" , "sdl3" ], check = True )
308+ SDL_INCLUDE = Path (get_emscripten_dir (), "cache/sysroot/include" ).resolve (strict = True )
309+ elif sys .platform == "win32" and SDL_PARSE_PATH is not None :
302310 SDL_INCLUDE = SDL_PARSE_PATH / "include"
303311elif sys .platform == "darwin" and SDL_PARSE_PATH is not None :
304312 SDL_INCLUDE = SDL_PARSE_PATH / "Versions/A/Headers"
0 commit comments