Skip to content

Commit 5c3a8bf

Browse files
committed
Parse SDL headers from EMSDK during Pyodide builds
Try not to bundle win/mac binaries during Pyodide build
1 parent fc0f5b3 commit 5c3a8bf

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

.github/workflows/python-package.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,6 @@ jobs:
330330
fetch-depth: ${{ env.git-depth }}
331331
- name: Checkout submodules
332332
run: git submodule update --init --recursive --depth 1
333-
- uses: libsdl-org/setup-sdl@6574e20ac65ce362cd12f9c26b3a5e4d3cd31dee
334-
with:
335-
install-linux-dependencies: true
336-
build-type: "Debug"
337-
version: ${{ env.sdl-version }}
338333
- uses: pypa/cibuildwheel@v3.0.0
339334
env:
340335
CIBW_PLATFORM: pyodide

build_sdl.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,18 @@ def on_directive_handle(
251251

252252
check_sdl_version()
253253

254-
if sys.platform == "win32" or sys.platform == "darwin":
254+
SDL_PARSE_PATH: Path | None = None
255+
SDL_BUNDLE_PATH: Path | None = None
256+
if (sys.platform == "win32" or sys.platform == "darwin") and "PYODIDE" not in os.environ:
255257
SDL_PARSE_PATH = unpack_sdl(SDL_PARSE_VERSION)
256258
SDL_BUNDLE_PATH = unpack_sdl(SDL_BUNDLE_VERSION)
257259

258260
SDL_INCLUDE: Path
259-
if sys.platform == "win32":
261+
if "PYODIDE" in os.environ:
262+
SDL_INCLUDE = Path(os.environ["EMSDK"], "include")
263+
elif sys.platform == "win32" and SDL_PARSE_PATH is not None:
260264
SDL_INCLUDE = SDL_PARSE_PATH / "include"
261-
elif sys.platform == "darwin":
265+
elif sys.platform == "darwin" and SDL_PARSE_PATH is not None:
262266
SDL_INCLUDE = SDL_PARSE_PATH / "Versions/A/Headers"
263267
else: # Unix
264268
matches = re.findall(
@@ -275,6 +279,7 @@ def on_directive_handle(
275279
raise AssertionError(matches)
276280
assert SDL_INCLUDE
277281

282+
logger.info(f"{SDL_INCLUDE=}")
278283

279284
EXTRA_CDEF = """
280285
#define SDLK_SCANCODE_MASK ...
@@ -358,7 +363,7 @@ def get_cdef() -> tuple[str, dict[str, str]]:
358363
libraries += ["SDL3"]
359364

360365
# Bundle the Windows SDL DLL.
361-
if sys.platform == "win32":
366+
if sys.platform == "win32" and SDL_BUNDLE_PATH is not None:
362367
include_dirs.append(str(SDL_INCLUDE))
363368
ARCH_MAPPING = {"32bit": "x86", "64bit": "x64"}
364369
SDL_LIB_DIR = Path(SDL_BUNDLE_PATH, "lib/", ARCH_MAPPING[BIT_SIZE])
@@ -372,7 +377,7 @@ def get_cdef() -> tuple[str, dict[str, str]]:
372377

373378
# Link to the SDL framework on MacOS.
374379
# Delocate will bundle the binaries in a later step.
375-
if sys.platform == "darwin":
380+
if sys.platform == "darwin" and SDL_BUNDLE_PATH is not None:
376381
include_dirs.append(SDL_INCLUDE)
377382
extra_link_args += [f"-F{SDL_BUNDLE_PATH}/.."]
378383
extra_link_args += ["-rpath", f"{SDL_BUNDLE_PATH}/.."]

0 commit comments

Comments
 (0)