Skip to content

Commit a0ae33d

Browse files
committed
Build Pyodide wheel
Disable link flags to let Emscripten take over for SDL3 Disable Py_LIMITED_API definition to workaround issue with cffi Related to #123
1 parent 9392a48 commit a0ae33d

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

.github/workflows/python-package.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,30 @@ jobs:
321321
retention-days: 7
322322
compression-level: 0
323323

324+
pyodide:
325+
runs-on: ubuntu-24.04
326+
steps:
327+
- uses: actions/checkout@v4
328+
with:
329+
fetch-depth: ${{ env.git-depth }}
330+
- name: Checkout submodules
331+
run: git submodule update --init --recursive --depth 1
332+
- uses: libsdl-org/setup-sdl@6574e20ac65ce362cd12f9c26b3a5e4d3cd31dee
333+
with:
334+
install-linux-dependencies: true
335+
build-type: "Debug"
336+
version: ${{ env.sdl-version }}
337+
- uses: pypa/cibuildwheel@v3.0.0
338+
env:
339+
CIBW_PLATFORM: pyodide
340+
- name: Archive wheel
341+
uses: actions/upload-artifact@v4
342+
with:
343+
name: wheels-pyodide
344+
path: wheelhouse/*.whl
345+
retention-days: 30
346+
compression-level: 0
347+
324348
publish:
325349
needs: [sdist, build, build-macos, linux-wheels]
326350
runs-on: ubuntu-latest

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@
350350
"pycall",
351351
"pycparser",
352352
"pyinstaller",
353+
"pyodide",
353354
"pypa",
354355
"PYPI",
355356
"pypiwin",

build_libtcod.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ def walk_sources(directory: str) -> Iterator[str]:
162162

163163
libraries: list[str] = [*build_sdl.libraries]
164164
library_dirs: list[str] = [*build_sdl.library_dirs]
165-
define_macros: list[tuple[str, Any]] = [("Py_LIMITED_API", Py_LIMITED_API)]
165+
define_macros: list[tuple[str, Any]] = []
166+
167+
if "PYODIDE" not in os.environ:
168+
# Unable to apply Py_LIMITED_API to Pyodide in cffi<=1.17.1
169+
# https://github.com/python-cffi/cffi/issues/179
170+
define_macros.append(("Py_LIMITED_API", Py_LIMITED_API))
166171

167172
sources += walk_sources("tcod/")
168173
sources += walk_sources("libtcod/src/libtcod/")

build_sdl.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ def get_cdef() -> tuple[str, dict[str, str]]:
350350
libraries: list[str] = []
351351
library_dirs: list[str] = []
352352

353-
354-
if sys.platform == "darwin":
353+
if "PYODIDE" in os.environ:
354+
pass
355+
elif sys.platform == "darwin":
355356
extra_link_args += ["-framework", "SDL3"]
356357
else:
357358
libraries += ["SDL3"]
@@ -382,6 +383,7 @@ def get_cdef() -> tuple[str, dict[str, str]]:
382383
extra_compile_args += (
383384
subprocess.check_output(["pkg-config", "sdl3", "--cflags"], universal_newlines=True).strip().split()
384385
)
385-
extra_link_args += (
386-
subprocess.check_output(["pkg-config", "sdl3", "--libs"], universal_newlines=True).strip().split()
387-
)
386+
if "PYODIDE" not in os.environ:
387+
extra_link_args += (
388+
subprocess.check_output(["pkg-config", "sdl3", "--libs"], universal_newlines=True).strip().split()
389+
)

0 commit comments

Comments
 (0)