Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Enable free threading support for Python #186

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,39 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13-dev', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10']
exclude:
- python-version: '3.8'
os: macos-latest
- python-version: '3.9'
os: macos-latest
- python-version: 'pypy-3.8'
os: macos-latest
include:
# Only test free threading on ubuntu latest due to setup-python availability
- os: ubuntu-latest
python-version: '3.13t'
steps:
- uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
if: matrix.python-version != '3.13t'
with:
python-version: ${{ matrix.python-version }}

# Remove once the main setup-python adds python free threading
- name: Set up Python ${{ matrix.python-version }}
uses: deadsnakes/action@6c8b9b82fe0b4344f4b98f2775fcc395df45e494 # v3.1.0
if: matrix.python-version == '3.13t'
with:
python-version: '3.13'
nogil: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ jobs:
setup-args="-Db_vscrt=mt"
setup-args="-Dcpp_link_args=['ucrt.lib','vcruntime.lib','/nodefaultlib:libucrt.lib','/nodefaultlib:libvcruntime.lib']"
CIBW_BUILD: "cp311-* cp312-* cp313-* pp39-* pp310-*"
# Enable free-threaded support
CIBW_FREE_THREADED_SUPPORT: 1
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
CIBW_ARCHS_LINUX: ${{ matrix.archs }}
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
Expand All @@ -176,6 +178,8 @@ jobs:
setup-args="-Db_vscrt=mt"
setup-args="-Dcpp_link_args=['ucrt.lib','vcruntime.lib','/nodefaultlib:libucrt.lib','/nodefaultlib:libvcruntime.lib']"
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
# Enable free-threaded support
CIBW_FREE_THREADED_SUPPORT: 1
CIBW_ARCHS_WINDOWS: ${{ matrix.archs }}
# It is not yet possible to run ARM64 tests, only cross-compile them.
CIBW_TEST_SKIP: "*-win_arm64"
Expand Down
3 changes: 3 additions & 0 deletions py/src/kiwisolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ kiwisolver_methods[] = {

PyModuleDef_Slot kiwisolver_slots[] = {
{Py_mod_exec, reinterpret_cast<void*>( kiwi_modexec ) },
#ifdef Py_GIL_DISABLED
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
#endif
{0, NULL}
};

Expand Down