Skip to content

Commit e50540a

Browse files
committed
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Parse SDL headers from EMSDK during Pyodide builds
1 parent 3ea3f78 commit e50540a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ jobs:
332332
run: git submodule update --init --recursive --depth 1
333333
- uses: pypa/cibuildwheel@v3.0.0
334334
env:
335+
CIBW_BEFORE_BUILD: emcc --show-ports && emcc --use-port=sdl3
335336
CIBW_PLATFORM: pyodide
336337
- name: Archive wheel
337338
uses: actions/upload-artifact@v4

build_sdl.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
254263
check_sdl_version()
255264

256265
SDL_PARSE_PATH: Path | None = None
@@ -261,16 +270,7 @@ def on_directive_handle(
261270

262271
SDL_INCLUDE: Path
263272
if "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()
274274
elif sys.platform == "win32" and SDL_PARSE_PATH is not None:
275275
SDL_INCLUDE = SDL_PARSE_PATH / "include"
276276
elif sys.platform == "darwin" and SDL_PARSE_PATH is not None:

0 commit comments

Comments
 (0)