Skip to content

Commit ba3bb24

Browse files
committed
Upgrade to use SDL3 version of libtcod
1 parent 8c25d37 commit ba3bb24

File tree

12 files changed

+194
-165
lines changed

12 files changed

+194
-165
lines changed

.github/workflows/python-package.yml

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ jobs:
4444
sdist:
4545
runs-on: ubuntu-latest
4646
steps:
47-
- name: APT update
48-
run: sudo apt-get update
49-
- name: Install APT dependencies
50-
run: sudo apt-get install libsdl2-dev
47+
- uses: libsdl-org/setup-sdl@6574e20ac65ce362cd12f9c26b3a5e4d3cd31dee
48+
with:
49+
install-linux-dependencies: true
50+
build-type: "Debug"
51+
version: "3.2.14"
5152
- uses: actions/checkout@v4
5253
with:
5354
fetch-depth: ${{ env.git-depth }}
@@ -71,7 +72,7 @@ jobs:
7172
strategy:
7273
matrix:
7374
os: ["windows-latest", "macos-latest"]
74-
sdl-version: ["2.0.14", "2.0.16", "2.30.0"]
75+
sdl-version: ["3.2.10"]
7576
fail-fast: true
7677
steps:
7778
- uses: actions/checkout@v4
@@ -90,7 +91,7 @@ jobs:
9091
SDL_VERSION: ${{ matrix.sdl-version }}
9192

9293
build:
93-
needs: [ruff, mypy]
94+
needs: [ruff, mypy, sdist]
9495
runs-on: ${{ matrix.os }}
9596
strategy:
9697
matrix:
@@ -122,7 +123,13 @@ jobs:
122123
if: runner.os == 'Linux'
123124
run: |
124125
sudo apt-get update
125-
sudo apt-get install libsdl2-dev xvfb
126+
sudo apt-get install xvfb
127+
- uses: libsdl-org/setup-sdl@6574e20ac65ce362cd12f9c26b3a5e4d3cd31dee
128+
if: runner.os == 'Linux'
129+
with:
130+
install-linux-dependencies: true
131+
build-type: "Release"
132+
version: "3.2.14"
126133
- name: Install Python dependencies
127134
run: |
128135
python -m pip install --upgrade pip
@@ -157,13 +164,15 @@ jobs:
157164
compression-level: 0
158165

159166
test-docs:
160-
needs: [ruff, mypy]
167+
needs: [ruff, mypy, sdist]
161168
runs-on: ubuntu-latest
162169
steps:
163-
- name: Install APT dependencies
164-
run: |
165-
sudo apt-get update
166-
sudo apt-get install libsdl2-dev
170+
- uses: libsdl-org/setup-sdl@6574e20ac65ce362cd12f9c26b3a5e4d3cd31dee
171+
if: runner.os == 'Linux'
172+
with:
173+
install-linux-dependencies: true
174+
build-type: "Debug"
175+
version: "3.2.14"
167176
- uses: actions/checkout@v4
168177
with:
169178
fetch-depth: ${{ env.git-depth }}
@@ -182,7 +191,7 @@ jobs:
182191
run: python -m sphinx -T -E -W --keep-going . _build/html
183192

184193
tox:
185-
needs: [ruff]
194+
needs: [ruff, sdist]
186195
runs-on: ${{ matrix.os }}
187196
strategy:
188197
matrix:
@@ -200,17 +209,18 @@ jobs:
200209
- name: Install Python dependencies
201210
run: |
202211
python -m pip install --upgrade pip tox
203-
- name: Install APT dependencies
212+
- uses: libsdl-org/setup-sdl@6574e20ac65ce362cd12f9c26b3a5e4d3cd31dee
204213
if: runner.os == 'Linux'
205-
run: |
206-
sudo apt-get update
207-
sudo apt-get install libsdl2-dev
214+
with:
215+
install-linux-dependencies: true
216+
build-type: "Debug"
217+
version: "3.2.14"
208218
- name: Run tox
209219
run: |
210220
tox -vv
211221
212222
linux-wheels:
213-
needs: [ruff, mypy]
223+
needs: [ruff, mypy, sdist]
214224
runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-latest'}}
215225
strategy:
216226
matrix:
@@ -248,7 +258,7 @@ jobs:
248258
CIBW_BEFORE_ALL_LINUX: >
249259
yum install -y epel-release &&
250260
yum-config-manager --enable epel &&
251-
yum install -y SDL2-devel
261+
yum install -y SDL3-devel
252262
CIBW_BEFORE_TEST: pip install numpy
253263
CIBW_TEST_COMMAND: python -c "import tcod.context"
254264
# Skip test on emulated architectures
@@ -267,7 +277,7 @@ jobs:
267277
compression-level: 0
268278

269279
build-macos:
270-
needs: [ruff, mypy]
280+
needs: [ruff, mypy, sdist]
271281
runs-on: "macos-14"
272282
strategy:
273283
fail-fast: true
@@ -287,7 +297,7 @@ jobs:
287297
- name: Install Python dependencies
288298
run: pip install -r requirements.txt
289299
- name: Prepare package
290-
# Downloads SDL2 for the later step.
300+
# Downloads SDL for the later step.
291301
run: python build_sdl.py
292302
- name: Build wheels
293303
uses: pypa/cibuildwheel@v2.23.3

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ Release/
6969
tcod/_*.c
7070
tcod/_*.pyd
7171
.benchmarks
72-
dependencies/SDL2*
72+
dependencies/SDL*
7373
tcod/x86
7474
tcod/x64
75-
tcod/SDL2.framework
75+
tcod/SDL?.framework
7676
deb_dist/
7777
*.tar.gz
7878
tcod/version.py

.readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
version: 2
66

77
build:
8-
os: ubuntu-22.04
8+
os: ubuntu-24.04
99
tools:
1010
python: "3.11"
1111
apt_packages:
12-
- libsdl2-dev
12+
- libsdl3-dev
1313

1414
submodules:
1515
include: all

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ For the most part it's just::
4848
==============
4949
* Python 3.10+
5050
* Windows, Linux, or MacOS X 10.9+.
51-
* On Linux, requires libsdl2 (2.0.10+).
51+
* On Linux, requires libsdl3 (3.2.0+).
5252

5353
===========
5454
Changelog

build_libtcod.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ def walk_sources(directory: str) -> Iterator[str]:
208208
for include in includes:
209209
try:
210210
ffi.cdef(include.header)
211-
except Exception:
211+
except Exception: # noqa: PERF203
212212
# Print the source, for debugging.
213213
print(f"Error with: {include.path}")
214214
for i, line in enumerate(include.header.split("\n"), 1):
215-
print("%03i %s" % (i, line))
215+
print(f"{i:03i} {line}")
216216
raise
217217
ffi.cdef(
218218
"""
@@ -221,7 +221,10 @@ def walk_sources(directory: str) -> Iterator[str]:
221221
)
222222
ffi.set_source(
223223
module_name,
224-
"#include <tcod/cffi.h>\n#include <SDL.h>",
224+
"""\
225+
#include <tcod/cffi.h>
226+
#define SDL_oldnames_h_
227+
#include <SDL3/SDL.h>""",
225228
include_dirs=include_dirs,
226229
library_dirs=library_dirs,
227230
sources=sources,

0 commit comments

Comments
 (0)