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

Implement support for the free-threaded build of CPython 3.13 #84

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:
PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest`
PYTHONIOENCODING: utf-8
PYTHONUTF8: 1
PYTHON_LATEST: 3.12
PYTHON_LATEST: 3.13


jobs:
Expand Down Expand Up @@ -184,6 +184,7 @@ jobs:
strategy:
matrix:
pyver:
- 3.13t
- 3.13
- 3.12
- 3.11
Expand Down Expand Up @@ -231,7 +232,7 @@ jobs:

- name: Setup Python ${{ matrix.pyver }}
id: python-install
uses: actions/setup-python@v5
uses: quansight-labs/setup-python@v5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide some more color about this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this: actions/setup-python#973 (comment)

Can we again add a TODO comment to revert this once resolved: actions/setup-python#771.

with:
python-version: ${{ matrix.pyver }}
allow-prereleases: true
Expand All @@ -241,6 +242,14 @@ jobs:
uses: py-actions/py-dependency-install@v4
with:
path: requirements/test.txt
- name: Install Cython nightly on free-threading
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this can also be removed once Cython 3.1 is out? Can we get a TODO comment here as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, will 3.1.0a1 work? Would probably simplify some of this, as that's already on PyPI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this the one that broke yarl during the sprints?

Copy link
Member

@bdraco bdraco Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I think it's unlikely that we would hit that issue though, at least in this code base.

if: matrix.pyver == '3.13t'
run: |
python -m pip uninstall -y cython
python -m pip install cython \
--pre \
--extra-index-url \
https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
- name: Determine pre-compiled compatible wheel
env:
# NOTE: When `pip` is forced to colorize output piped into `jq`,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest`
PYTHONIOENCODING: utf-8
PYTHONUTF8: 1
PYTHON_LATEST: 3.12
PYTHON_LATEST: 3.13

jobs:

Expand Down
1 change: 1 addition & 0 deletions CHANGES/84.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/84.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`.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ graft docs
graft CHANGES
graft requirements
graft tests
graft scripts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be reverted, so could do with a comment as well.

global-exclude *.pyc
global-exclude *.cache
exclude src/propcache/*.c
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ linetrace = "True" # Implies `profile=True`

[tool.cibuildwheel]
build-frontend = "build"
enable = ["cpython-freethreading"]
before-test = [
# NOTE: Attempt to have pip pre-compile PyYAML wheel with our build
# NOTE: constraints unset. The hope is that pip will cache that wheel
Expand All @@ -78,6 +79,11 @@ test-command = "pytest -v --no-cov {project}/tests"
# don't build PyPy wheels, install from source instead
skip = "pp*"

[[tool.cibuildwheel.overrides]]
select = "cp313t-*"
build-frontend = "build; args: --no-isolation"
before-build = "bash {package}/scripts/cibw_before_build.sh"

Comment on lines +82 to +86
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also another comment here, I'm unclear if only the before-build line or other lines should be removed when Cython 3.1 is out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a list? Perhaps, the script could be stuffed right inside this config?

[tool.cibuildwheel.environment]
COLOR = "yes"
FORCE_COLOR = "1"
Expand Down
7 changes: 7 additions & 0 deletions scripts/cibw_before_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TODO: Delete when there's a PyPI Cython release (3.1.0) that supports free-threaded Python 3.13.
FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
if [[ $FREE_THREADED_BUILD == "True" ]]; then
python -m pip install -U pip
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be possible to implement less intrusively though PIP_CONSTRAINT and Cython @ url syntax in the constraint file..

python -m pip install setuptools expandvars
fi
2 changes: 1 addition & 1 deletion src/propcache/_helpers_c.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cython: language_level=3
# cython: language_level=3, freethreading_compatible=True
from types import GenericAlias
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can go into pyproject.toml. There's a section for Cython.



Expand Down
Loading