Skip to content

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

Merged
bdraco merged 19 commits into
aio-libs:masterfrom
lysnikolaou:freethreading-support
Feb 20, 2025
Merged

bdraco merged 19 commits into
aio-libs:masterfrom
lysnikolaou:freethreading-support

Conversation

@lysnikolaou

Copy link
Copy Markdown
Contributor

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

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Dec 20, 2024
Comment thread .github/workflows/ci-cd.yml Resolved
Comment thread .github/workflows/ci-cd.yml Resolved
Comment thread pyproject.toml Resolved
Comment thread MANIFEST.in Resolved
Comment thread src/propcache/_helpers_c.pyx Resolved
Comment thread scripts/cibw_before_build.sh Resolved
@lysnikolaou

Copy link
Copy Markdown
Contributor 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.

@codspeed

codspeed Bot commented Jan 13, 2025 •

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #84 will not alter performance

Comparing lysnikolaou:freethreading-support (e36539b) with master (4fe87bc)

Summary

✅ 4 untouched benchmarks

@codecov

codecov Bot commented Jan 13, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.99%. Comparing base (4fe87bc) to head (e36539b).
Report is 22 commits behind head on master.

Files with missing lines Patch % Lines
packaging/pep517_backend/_backend.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #84      +/-   ##
==========================================
- Coverage   89.02%   88.99%   -0.04%     
==========================================
  Files          18       18              
  Lines         738      745       +7     
  Branches       75       75              
==========================================
+ Hits          657      663       +6     
- Misses         63       64       +1     
  Partials       18       18              
Flag Coverage Δ
CI-GHA 88.99% <93.75%> (-0.04%) ⬇️
MyPy 78.54% <92.85%> (+0.04%) ⬆️
OS-Linux 98.91% <80.00%> (-0.54%) ⬇️
OS-Windows 94.86% <77.77%> (-0.55%) ⬇️
OS-macOS 95.36% <80.00%> (-0.50%) ⬇️
Py-3.10.11 95.09% <80.00%> (-0.50%) ⬇️
Py-3.10.16 97.27% <80.00%> (-0.53%) ⬇️
Py-3.11.11 97.27% <80.00%> (-0.53%) ⬇️
Py-3.11.9 95.09% <80.00%> (-0.50%) ⬇️
Py-3.12.8 95.09% <80.00%> (-0.50%) ⬇️
Py-3.12.9 97.27% <80.00%> (-0.53%) ⬇️
Py-3.13.1 97.27% <80.00%> (+1.68%) ⬆️
Py-3.13.2 97.27% <80.00%> (-0.53%) ⬇️
Py-3.9.13 95.08% <80.00%> (-0.50%) ⬇️
Py-3.9.21 97.26% <80.00%> (-0.53%) ⬇️
Py-pypy7.3.16 96.66% <77.77%> (-0.58%) ⬇️
Py-pypy7.3.18 96.67% <77.77%> (-0.58%) ⬇️
VM-macos-latest 95.36% <80.00%> (-0.50%) ⬇️
VM-ubuntu-latest 98.91% <80.00%> (-0.54%) ⬇️
VM-windows-latest 94.86% <77.77%> (-0.55%) ⬇️
pytest 98.91% <80.00%> (-0.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lysnikolaou

Copy link
Copy Markdown
Contributor Author

Gentle ping on this. Is there anything I can do to move it forward?

Comment thread packaging/pep517_backend/_backend.py Resolved
bdraco
bdraco previously requested changes Jan 22, 2025

@bdraco bdraco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread packaging/pep517_backend/_backend.py Resolved
Comment thread src/propcache/_helpers_c.pyx Resolved

@asvetlov asvetlov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would suggest waiting for non-alpha Cython release. A Release Candidate is ok, but alpha is not.

@Dreamsorcerer

Copy link
Copy Markdown
Member

I would suggest waiting for non-alpha Cython release. A Release Candidate is ok, but alpha is not.

It's a compile-time experimental feature on cpython, I don't think anybody is expecting us to have a rock solid supported implementation. It's essentially a preview release at this point, so alpha is fine at this stage (and the only thing we can offer).

@asvetlov

Copy link
Copy Markdown
Member

If it is experimental, py3.13t should allow failures in build&tests, only py3.13 should use Cython alpha, and all stable builds should use stable Cython.
I worry a little about existing build stability; it would be sad if Cython alpha prevented us from publishing a new propcache release.

@Dreamsorcerer

Copy link
Copy Markdown
Member

The discussion above is to use it only on the 3.13t release. Stable Cython is used on other versions, so this has already been addressed.

@asvetlov

asvetlov commented Feb 7, 2025

Copy link
Copy Markdown
Member

@Dreamsorcerer I'm sorry; I've missed that the new config is applied to 3.13t only.
There are no objections from me anymore.

@lysnikolaou

Copy link
Copy Markdown
Contributor Author

The problem with this is that there's sadly no environment marker for free-threading in the constraint file (though there are plans for it). This creates a conflict between the specified build requirement and the Cython constraints for regular 3.13. Any ideas on how you'd like to proceed here?

@rgommers

rgommers commented Feb 7, 2025

Copy link
Copy Markdown

This creates a conflict between the specified build requirement and the Cython constraints for regular 3.13. Any ideas on how you'd like to proceed here?

What all other projects that have released cp313t wheels do here is to set the requirements for 3.13 in pyproject.toml and other metadata file for the default CPython build (i.e., 3.0.11 now, not 3.1.0a1) and disable build isolation to produce cp313t wheels, installing Cython alpha/nightly in the wheel build job. I think that's the only good option at the moment, or something equivalent like pointing at a different constraints file (requirements/cython_freethreading.txt ?).

@lysnikolaou

lysnikolaou commented Feb 7, 2025 •

Copy link
Copy Markdown
Contributor Author

Thanks @rgommers for the pointer! This is what an older verion of this PR did, though my understanding was that the maintainers did not like that. If everyone is okay with this, I can certainly revisit that approach.

@lysnikolaou
lysnikolaou force-pushed the freethreading-support branch from c948a8a to 8207cbb Compare February 17, 2025 12:10
Comment thread packaging/pep517_backend/_backend.py Resolved
@webknjaz

Copy link
Copy Markdown
Member

a different constraints file (requirements/cython_freethreading.txt ?).

@lysnikolaou I do like this approach. It'd be nice to granularly override it just for 3.13t.

@lysnikolaou

Copy link
Copy Markdown
Contributor Author

I've update this PR to use the exact same approach as yarl (around building wheels). If someone could approve the workflows, that'd be really helpful.

Comment thread tests/test_benchmarks.py
try:
from pytest_codspeed import BenchmarkFixture
except ImportError:
pytestmark = pytest.mark.skip("pytest_codspeed needs to be installed")

Check notice

Code scanning / CodeQL

Unused global variable

The global variable 'pytestmark' is not used.
@bdraco

bdraco commented Feb 20, 2025

Copy link
Copy Markdown
Member

I'm working on fixing the CI now

@bdraco

bdraco commented Feb 20, 2025

Copy link
Copy Markdown
Member

Once done, feel free to reach out on matrix or discord any time you need the CI kicked

@bdraco
bdraco dismissed their stale review February 20, 2025 16:03

LGTM now

Comment thread packaging/pep517_backend/_backend.py Resolved
Comment thread requirements/codspeed.txt Resolved
@bdraco
bdraco merged commit ccab7f4 into aio-libs:master Feb 20, 2025
@bdraco

bdraco commented Feb 20, 2025

Copy link
Copy Markdown
Member

Thanks @lysnikolaou

I'm doing release now. 🤞 that we don't hit qemu issues again

@bdraco

bdraco commented Feb 20, 2025

Copy link
Copy Markdown
Member

Manually checked all the workflows. Build looks good. Going to release it out now

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.

7 participants