Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ jobs:
strategy:
matrix:
pyver:
- 3.13t
- 3.13
- 3.12
- 3.11
Expand Down Expand Up @@ -238,7 +239,8 @@ jobs:
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/test.txt
path: requirements/test${{
matrix.pyver == '3.13t' && '-freethreading' || '' }}.txt
- name: Determine pre-compiled compatible wheel
env:
# NOTE: When `pip` is forced to colorize output piped into `jq`,
Expand Down
1 change: 1 addition & 0 deletions CHANGES/618.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implemented support for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`.
1 change: 1 addition & 0 deletions CHANGES/618.packaging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Started building wheels for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`.
22 changes: 16 additions & 6 deletions frozenlist/_frozenlist.pyx
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
# cython: freethreading_compatible = True
# distutils: language = c++

from cpython.bool import PyBool_FromLong
from libcpp.atomic cimport atomic

import types
from collections.abc import MutableSequence


cdef class FrozenList:
__class_getitem__ = classmethod(types.GenericAlias)

cdef readonly bint frozen
cdef atomic[bint] _frozen
cdef list _items

def __init__(self, items=None):
self.frozen = False
self._frozen.store(False)
if items is not None:
items = list(items)
else:
items = []
self._items = items

@property
def frozen(self):
return PyBool_FromLong(self._frozen.load())

cdef object _check_frozen(self):
if self.frozen:
if self._frozen.load():
raise RuntimeError("Cannot modify frozen list.")

cdef inline object _fast_len(self):
return len(self._items)

def freeze(self):
self.frozen = True
self._frozen.store(True)

def __getitem__(self, index):
return self._items[index]
Expand Down Expand Up @@ -103,11 +113,11 @@ cdef class FrozenList:
return self._items.count(item)

def __repr__(self):
return '<FrozenList(frozen={}, {!r})>'.format(self.frozen,
return '<FrozenList(frozen={}, {!r})>'.format(self._frozen.load(),
self._items)

def __hash__(self):
if self.frozen:
if self._frozen.load():
return hash(tuple(self._items))
else:
raise RuntimeError("Cannot hash unfrozen list.")
Expand Down
11 changes: 7 additions & 4 deletions packaging/pep517_backend/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import os
import sysconfig
from contextlib import contextmanager, nullcontext, suppress
from functools import partial
from pathlib import Path
Expand Down Expand Up @@ -372,10 +373,12 @@ def get_requires_for_build_wheel(
stacklevel=999,
)

c_ext_build_deps = [] if is_pure_python_build else [
'Cython ~= 3.0.0; python_version >= "3.12"',
'Cython; python_version < "3.12"',
]
if is_pure_python_build:
c_ext_build_deps = []
elif sysconfig.get_config_var('Py_GIL_DISABLED'):
c_ext_build_deps = ['Cython ~= 3.1.0a1']
else:
c_ext_build_deps = ['Cython >= 3.0.12']

return _setuptools_get_requires_for_build_wheel(
config_settings=config_settings,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ linetrace = "True" # Implies `profile=True`
#error_on_uninitialized = "True"

[tool.cibuildwheel]
enable = ["cpython-freethreading"]
build-frontend = "build"
before-test = [
# NOTE: Attempt to have pip pre-compile PyYAML wheel with our build
Expand Down
1 change: 1 addition & 0 deletions requirements/cython-freethreading.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cython==3.1.0a1
2 changes: 2 additions & 0 deletions requirements/test-freethreading.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r cython-freethreading.txt
-r test-pure.txt
3 changes: 3 additions & 0 deletions requirements/test-pure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage==7.6.1
pytest==7.4.3
pytest-cov==4.1.0
4 changes: 1 addition & 3 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
-r cython.txt
coverage==7.6.1
pytest==7.4.3
pytest-cov==4.1.0
-r test-pure.txt
Loading