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 3 commits into
base: master
Choose a base branch
from

Conversation

lysnikolaou
Copy link

What do these changes do?

  • Add a matrix config for free-threaded Python to run tests with it.
  • Change configuration to correctly build wheels under the free-threaded build.

Are there changes in behavior for the user?

No.

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Dec 20, 2024
@@ -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.

Copy link
Author

@lysnikolaou lysnikolaou Jan 9, 2025

Choose a reason for hiding this comment

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

3.1.0a1 would work sufficiently well, though there's many Cython improvements that are being currently worked on and will appear in the nightlies much sooner. I can do whatever people think is best.

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 to ease future maintenance, it'd be best to use a released version so we don't need to update this again later and can keep it simple. If there's major improvements we want, we can probably just ask them for another alpha release.

Copy link
Author

Choose a reason for hiding this comment

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

Sure! Keep in mind that Cython doesn't really do many releases though.

pyproject.toml Outdated
Comment on lines 82 to 86
[[tool.cibuildwheel.overrides]]
select = "cp313t-*"
build-frontend = "build; args: --no-isolation"
before-build = "bash {package}/scripts/cibw_before_build.sh"

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?

Copy link
Author

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?

Not sure whether that would work cross-platform, but I can try it if you want.

MANIFEST.in Outdated Show resolved Hide resolved
@@ -1,4 +1,4 @@
# cython: language_level=3
# cython: language_level=3, freethreading_compatible=True
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.

Copy link
Author

@lysnikolaou lysnikolaou Jan 9, 2025

Choose a reason for hiding this comment

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

I tried that but it unfortunately cannot, because there's not the ability to add a version-specific option to pyproject.toml. For this, the build backend would have to be changed, which seems like a bigger hassle.

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..

Copy link
Author

Choose a reason for hiding this comment

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

That would mean that we install a nightly Cython for non-free-threaded Pythons as well though, which to me seems suboptimal. What do you think?

@lysnikolaou
Copy link
Author

Hey folks, thanks for all the review and sorry for the extended delay here, I was out on PTO. I've addressed most of the comments around adding some TODOs and replied to the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants