⬆️ Support free-threaded Python 3.14t by svlandeg · Pull Request #15149 · fastapi/fastapi
Continues from #13946: adding support for free-threaded Python 3.14t
- Extend test suite with a configuration for
python-version: "3.14t" - Allow the test suite to run when
orjsonand/orujsonis not installed, cf also 🗑️ DeprecateORJSONResponseandUJSONResponse#14964 which deprecatedORJSONResponse&UJSONResponse - Remove
orjson&ujsonas a standard test dependency - Add an additional test configuration to test for deprecated
ujson/orjsontests (to ensure coverage goes back to 100%) - Ensure that
fastar0.9.0 is used
Checklist
- Fix issues with
orjson&ujsonon free-threaded run - Run
orjson&ujsontests in one specific non-free-threaded run - Fix
fastarissue on free-threaded run: https://github.com/DoctorJohn/fastar/releases/tag/v0.9.0 - Fix SQLAlchemy cyextension issues on Ubuntu
Open question
Decided not to do this:
- Bump
pydantic-core&strawberry-graphql(and maybe others) to allow runninguv-resolution: lowest-directon 3.14t as well. This will negatively impact other users on older Python versions / older external lib versions.
Merging this PR will not alter performance
✅ 20 untouched benchmarks
Comparing svlandeg:feat/314t (1b2934b) with master (25a3697)
| ujson = None # type: ignore | ||
|
|
||
|
|
||
| class _OrjsonModule(Protocol): |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit convoluted to avoid type checker shenanigans, as they need to work with or without orjson in the env.
(and the same thing for ujson in this module)
It looks like they need an update either to declare support for the free-threaded build or simply update to the latest PyO3 version, which does that automatically. I might poke at that today to help you out here.
It looks like they need an update either to declare support for the free-threaded build or simply update to the latest PyO3 version, which does that automatically. I might poke at that today to help you out here.
That would be awesome, thank you so much!
Looks like the Mac and Windows tests aren't picking up fastar 0.9.0.
It's unclear to me why the 3.14t test on Windows wasn't installing the latest fastar 0.9.0, https://github.com/fastapilabs/fastapi-cloud-cli has it at "fastar >= 0.8.0". Anyway for now I explicitely require 0.9.0 and then that test does succeed 🎉
The Mac test is a different issue: I was running that one with uv-resolution: lowest-direct which means that it tries out the lower bounds of our supported ranges. Here, it crashed for an older version of Pydantic, which is not surprising. Now the only open question is whether we want to bump those lower bounds (which may be annoying for users on older versions of Python & external repos), or just leave them and assume that users running 3.14t will also have updated dependencies 🤷
svlandeg
marked this pull request as ready for review
Ok cool, confirmed that bumping to pydantic >= 2.12.0 and strawberry-graphql >= 0.284.0 allows the test suite to run succesfully with uv-resolution: lowest-direct on Python 3.14t.
Discussed this internally with Sebastián and decided that we don't want to go so far as bumping Pydantic to 2.12+, as it might create issues for users still on older versions. So, I'll remove this test configuration again and then this PR should be ready for review.
svlandeg
marked this pull request as ready for review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters