Skip to content

Commit 9d4d28f

Browse files
committed
Build free-threaded CPython 3.14t wheels
Resolves #161
1 parent a93ca11 commit 9d4d28f

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

.github/workflows/python-package.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,25 @@ jobs:
109109
needs: [ruff, mypy, sdist]
110110
runs-on: ${{ matrix.os }}
111111
timeout-minutes: 15
112+
continue-on-error: ${{ matrix.python-version == '3.14t' && matrix.os == 'windows-11-arm' }} # Until issues are resolved: https://github.com/actions/setup-python/issues/1267
112113
strategy:
113114
matrix:
114115
os: ["ubuntu-latest", "windows-latest"]
115-
python-version: ["3.10", "pypy-3.10"]
116+
python-version: ["3.10", "3.14t", "pypy-3.10"]
116117
architecture: ["x64"]
117118
include:
118119
- os: "windows-latest"
119120
python-version: "3.10"
120121
architecture: "x86"
122+
- os: "windows-latest"
123+
python-version: "3.14t"
124+
architecture: "x86"
121125
- os: "windows-11-arm"
122126
python-version: "3.11"
123127
architecture: "arm64"
128+
- os: "windows-11-arm"
129+
python-version: "3.14t"
130+
architecture: "arm64"
124131
fail-fast: false
125132

126133
steps:
@@ -240,7 +247,7 @@ jobs:
240247
strategy:
241248
matrix:
242249
arch: ["x86_64", "aarch64"]
243-
build: ["cp310-manylinux*", "pp310-manylinux*"]
250+
build: ["cp310-manylinux*", "pp310-manylinux*", "cp314t-manylinux*"]
244251
env:
245252
BUILD_DESC: ""
246253
steps:
@@ -298,7 +305,7 @@ jobs:
298305
strategy:
299306
fail-fast: true
300307
matrix:
301-
python: ["cp310-*_universal2", "pp310-*"]
308+
python: ["cp310-*_universal2", "cp314t-*_universal2", "pp310-*"]
302309
env:
303310
PYTHON_DESC: ""
304311
steps:

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"cooldown",
108108
"cplusplus",
109109
"CPLUSPLUS",
110+
"cpython",
110111
"CRSEL",
111112
"ctypes",
112113
"CURRENCYSUBUNIT",
@@ -167,6 +168,7 @@
167168
"fmean",
168169
"fontx",
169170
"fonty",
171+
"freethreading",
170172
"freetype",
171173
"frombuffer",
172174
"fullscreen",

build_libtcod.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
if TYPE_CHECKING:
3030
from collections.abc import Iterable, Iterator
3131

32-
Py_LIMITED_API = 0x03100000
32+
Py_LIMITED_API: None | int = 0x03100000
3333

3434
HEADER_PARSE_PATHS = ("tcod/", "libtcod/src/libtcod/")
3535
HEADER_PARSE_EXCLUDES = ("gl2_ext_.h", "renderer_gl_internal.h", "event.h")
@@ -167,9 +167,14 @@ def walk_sources(directory: str) -> Iterator[str]:
167167
library_dirs: list[str] = [*build_sdl.library_dirs]
168168
define_macros: list[tuple[str, Any]] = []
169169

170-
if "PYODIDE" not in os.environ:
170+
if "free-threading build" in sys.version:
171+
Py_LIMITED_API = None
172+
if "PYODIDE" in os.environ:
171173
# Unable to apply Py_LIMITED_API to Pyodide in cffi<=1.17.1
172174
# https://github.com/python-cffi/cffi/issues/179
175+
Py_LIMITED_API = None
176+
177+
if Py_LIMITED_API:
173178
define_macros.append(("Py_LIMITED_API", Py_LIMITED_API))
174179

175180
sources += walk_sources("tcod/")

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ keywords = [
4242
"field-of-view",
4343
"pathfinding",
4444
]
45-
classifiers = [
45+
classifiers = [ # https://pypi.org/classifiers/
4646
"Development Status :: 5 - Production/Stable",
4747
"Environment :: Win32 (MS Windows)",
4848
"Environment :: MacOS X",
@@ -53,6 +53,7 @@ classifiers = [
5353
"Operating System :: MacOS :: MacOS X",
5454
"Operating System :: Microsoft :: Windows",
5555
"Programming Language :: Python :: 3",
56+
"Programming Language :: Python :: Free Threading :: 2 - Beta",
5657
"Programming Language :: Python :: Implementation :: CPython",
5758
"Programming Language :: Python :: Implementation :: PyPy",
5859
"Topic :: Games/Entertainment",
@@ -72,9 +73,6 @@ Source = "https://github.com/libtcod/python-tcod"
7273
Tracker = "https://github.com/libtcod/python-tcod/issues"
7374
Forum = "https://github.com/libtcod/python-tcod/discussions"
7475

75-
[tool.distutils.bdist_wheel]
76-
py-limited-api = "cp310"
77-
7876
[tool.setuptools_scm]
7977
write_to = "tcod/version.py"
8078

setup.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ def get_package_data() -> list[str]:
4040
print("Did you forget to run 'git submodule update --init'?")
4141
sys.exit(1)
4242

43+
options = {
44+
"bdist_wheel": {
45+
"py_limited_api": "cp310",
46+
}
47+
}
48+
if "free-threading build" in sys.version:
49+
del options["bdist_wheel"]["py_limited_api"]
4350

4451
setup(
4552
py_modules=["libtcodpy"],
4653
packages=["tcod", "tcod.sdl", "tcod.__pyinstaller"],
4754
package_data={"tcod": get_package_data()},
4855
cffi_modules=["build_libtcod.py:ffi"],
4956
platforms=["Windows", "MacOS", "Linux"],
57+
options=options,
5058
)

0 commit comments

Comments
 (0)