Skip to content

Commit bd7e155

Browse files
authored
Merge pull request #339 from bgilbert/free
Support free-threaded Python
2 parents 3d934f0 + 55ccd85 commit bd7e155

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

.github/workflows/python.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
strategy:
5151
matrix:
5252
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest]
53-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
53+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.13t", "3.14", "3.14t"]
5454
openslide: [system, wheel]
5555
include:
5656
- os: ubuntu-latest
@@ -132,8 +132,8 @@ jobs:
132132
mkdir -p "artifacts/whl/${{ needs.pre-commit.outputs.dist-base }}"
133133
mv dist/* "artifacts/whl/${{ needs.pre-commit.outputs.dist-base }}"
134134
# from system builds, save version-specific wheels and oldest abi3 wheel
135-
python -c 'import sys
136-
if sys.version_info < (3, 12) and "${{ matrix.openslide }}" == "system":
135+
python -c 'import sys, sysconfig
136+
if "${{ matrix.openslide }}" == "system" and (sys.version_info < (3, 12) or sysconfig.get_config_var("Py_GIL_DISABLED")):
137137
print("archive_wheel=1")' >> $GITHUB_ENV
138138
- name: Install
139139
run: pip install artifacts/whl/${{ needs.pre-commit.outputs.dist-base }}/*.whl
@@ -165,7 +165,7 @@ jobs:
165165
shell: bash
166166
strategy:
167167
matrix:
168-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
168+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.13t", "3.14", "3.14t"]
169169
openslide: [zip, wheel]
170170
steps:
171171
- name: Check out repo
@@ -203,8 +203,8 @@ jobs:
203203
mkdir -p "artifacts/whl/${{ needs.pre-commit.outputs.dist-base }}"
204204
mv dist/*.whl "artifacts/whl/${{ needs.pre-commit.outputs.dist-base }}"
205205
# from zip builds, save version-specific wheels and oldest abi3 wheel
206-
python -c 'import sys
207-
if sys.version_info < (3, 12) and "${{ matrix.openslide }}" == "zip":
206+
python -c 'import sys, sysconfig
207+
if "${{ matrix.openslide }}" == "zip" and (sys.version_info < (3, 12) or sysconfig.get_config_var("Py_GIL_DISABLED")):
208208
print("archive_wheel=1")' >> $GITHUB_ENV
209209
- name: Install
210210
run: pip install artifacts/whl/${{ needs.pre-commit.outputs.dist-base }}/*.whl

openslide/_convert.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ static PyMethodDef _convert_methods[] = {
103103
};
104104

105105
static PyModuleDef_Slot _convert_slots[] = {
106+
#if PY_VERSION_HEX >= 0x030D0000 && !defined(Py_LIMITED_API)
107+
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
108+
#endif
106109
{0, NULL}
107110
};
108111

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: 3.12",
2424
"Programming Language :: Python :: 3.13",
2525
"Programming Language :: Python :: 3.14",
26+
"Programming Language :: Python :: Free Threading :: 2 - Beta",
2627
"Topic :: Scientific/Engineering :: Bio-Informatics",
2728
"Typing :: Typed",
2829
]

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from pathlib import Path
22
import sys
3+
import sysconfig
34

45
from setuptools import Extension, setup
56

67
# Load version string
78
with open(Path(__file__).parent / 'openslide/_version.py') as _fh:
89
exec(_fh.read()) # instantiates __version__
910

10-
# use the Limited API on Python 3.11+; build release-specific wheels on
11-
# older Python
12-
_abi3 = sys.version_info >= (3, 11)
11+
# use the Limited API on Python 3.11+ on GIL builds; build release-specific
12+
# wheels on older or free-threaded Python
13+
_abi3 = sys.version_info >= (3, 11) and not sysconfig.get_config_var('Py_GIL_DISABLED')
1314

1415
setup(
1516
ext_modules=[

0 commit comments

Comments
 (0)