@@ -251,6 +251,15 @@ def on_directive_handle(
251251 return super ().on_directive_handle (directive , tokens , if_passthru , preceding_tokens )
252252
253253
254+ def get_emscripten_include_dir () -> Path :
255+ """Find and return the Emscripten include dir."""
256+ # None of the EMSDK environment variables exist! Search PATH for Emscripten as a workaround
257+ for path in os .environ ["PATH" ].split (os .pathsep )[::- 1 ]:
258+ if Path (path ).match ("upstream/emscripten" ):
259+ return Path (path , "system/include" ).resolve (strict = True )
260+ raise AssertionError (os .environ ["PATH" ])
261+
262+
254263check_sdl_version ()
255264
256265SDL_PARSE_PATH : Path | None = None
@@ -261,16 +270,7 @@ def on_directive_handle(
261270
262271SDL_INCLUDE : Path
263272if "PYODIDE" in os .environ :
264- # None of the EMSDK environment variables exist! Search PATH for Emscripten as a workaround
265- for path in os .environ ["PATH" ].split (os .pathsep )[::- 1 ]:
266- if Path (path ).match ("upstream/emscripten" ):
267- print (f"{ list (Path (path ).iterdir ())} " )
268- SDL_INCLUDE = Path (path , "system/include" )
269- print (f"{ list (SDL_INCLUDE .iterdir ())} " )
270- print (f"{ list ((SDL_INCLUDE / 'SDL' ).iterdir ())} " )
271- break
272- else :
273- raise AssertionError (os .environ ["PATH" ])
273+ SDL_INCLUDE = get_emscripten_include_dir ()
274274elif sys .platform == "win32" and SDL_PARSE_PATH is not None :
275275 SDL_INCLUDE = SDL_PARSE_PATH / "include"
276276elif sys .platform == "darwin" and SDL_PARSE_PATH is not None :
0 commit comments