Repository navigation
build: upgrade PyO3 to 0.30.1 so citry-core builds for Python 3.15 - #340
Merged
Merged
Conversation
pyo3-ffi 0.27 caps CPython at 3.14. PyO3 0.30.1 supports Python 3.15.0, including the free-threaded build. Little that Python can see changes: - PyO3 0.30 no longer gives a `Clone` `#[pyclass]` a `FromPyObject` implementation by default. The 30 `Clone` classes in citry_template_parser now ask for it with `from_py_object`, as 0.27 gave it to them, so the AST classes still convert from Python as before. - PyO3 0.30 makes every `#[pyclass]` a garbage-collected type. The native-render row, run, occurrence and leaf objects hold nothing that can refer back to them, and a page makes thousands of them, so they are created untracked (`new_untracked`), as they were before. - The module keeps `gil_used = true`. Since PyO3 0.28, a module that does not say so declares that it runs without the GIL. - Argument type errors use PyO3's new wording and name the argument in a note, every other class is tracked by the cyclic collector, and `HtmlAttrKind` values are shared objects. A dump of every module, class, signature and docstring in citry_core._rust before and after matches, except that the variant classes of `Node` and `TemplateElement` are named after their variant (`Node.WithBody` rather than `Node_WithBody`) and carry their docstrings, which PyO3 0.28 changed and offers no option to undo. The `_rust.pyi` stub now declares the variants as nested classes, as at runtime, and the citry-core changelog notes the new names and the new error wording. abi3 stays at py310. Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
added a commit
that referenced
this pull request
Oct 27, 2026
The rest of #177, now that citry-core builds on 3.15 (#340). - All five packages list Python 3.15 in their classifiers. - The Python test matrix gains Ubuntu and Windows 3.15 jobs, and the macOS pair becomes 3.11 and 3.15. The Citry UI wheel install check now runs on 3.11 and 3.15, the citry, citry-lsp, citry-ui and pygments-citry release install tests run on 3.15 too, and the diagnostic workflow offers it. - The citry-core release now installs and tests its ABI3 wheel on 3.15 (on Linux and Windows next to 3.11-3.14, and as the newest on macOS), and builds a free-threaded cp315t wheel for every Linux and musllinux architecture next to cp314t. The release set grows from 36 to 46 files; the verifier, its test, the toolchain validator and docs/codebase.md move with it. - uv.lock moves only what a 3.15 test job installs and has no cp315 wheel for: markupsafe 3.0.4, and pydantic 2.14.1 with pydantic-core 2.50.1 (pydantic 2.14.1 needs typing-extensions 4.16.0 and typing-inspection 0.4.4). tzdata, pygments and everything else stay. - PyYAML, which the citry-ui tests and the repository workflow tests read manifests with, has no wheel for 3.15 (or PyPy) and builds from its sdist with Cython. require-build-hashes refused that build, so scripts/build_constraints.py now also pins the backends in THIRD_PARTY_BUILD_REQUIREMENTS (Cython 3.3.0), and docs/codebase.md says how to add another one. A source build of PyYAML on CPython 3.15.1 and PyPy 3.11.17 with an empty cache passes with the pin. - django-components (and its djc-core) is in citry's `benchmark` group, and minify-html in the root `docs` extra; no test job installs either, so neither needs a 3.15 wheel. - The README, the package READMEs, the installation and compatibility pages, the development page, and docs/codebase.md say 3.11 through 3.15, and each package's changelog says it supports 3.15. The example projects keep testing on 3.11 and 3.14: their lockfiles pin the released Citry and markupsafe 3.0.3, which has no cp315 wheel, so moving them needs their own relock and is left for a follow-up. Closes #177 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
citry-core did not build for Python 3.15: the workspace pinned PyO3 0.27.1,
whose
pyo3-ffirefuses any CPython newer than 3.14. This PR moves theworkspace to PyO3 0.30.1, which supports Python 3.15.0 and free-threaded
3.15. abi3 stays at
py310here, because the Python 3.10 drop is a separatechange that moves the release files together.
Adding 3.15 to the test matrix, the classifiers and the wheel set is the
docs/CI follow-up.
What had to change
I read PyO3's changelog for 0.28, 0.29 and 0.30. The 0.30 migration guide
has no "0.29 to 0.30" section. These changes reach this repository:
FromPyObjectforCloneclasses. PyO3 0.30 no longer gives aClone#[pyclass]aFromPyObjectimplementation by default; 0.28deprecated it. The AST classes in
citry_template_parserare passed backinto Rust by value, for example through a constructor that takes a
Token. So the 30Cloneclasses there now ask for it with#[pyclass(from_py_object)], which gives them exactly what 0.27 gavethem.
#[pyclass]agarbage-collected type (PyO3#6269),
so every new object is tracked. The native-render
_NativeRow,_NativeRun,_NativeOccurrenceand_LeafJsonobjects hold onlystrings, Rust data and objects that cannot refer back to them. A page
creates thousands of them. They were untracked before, and the
native-render tests check that they still are: they are now created
through
new_untrackedinnative_render/mod.rs, which untracks eachnew object when its type is collector-managed. Every other class, such as
Template,Tokenand theBrowser*records, is now tracked. They holdonly Rust data, so I measured whether that costs enough to untrack them
too (the threshold was 2%; see "Collector cost" below). It does not.
support by default. Our module already says
#[pymodule(gil_used = true)],so a free-threaded interpreter still enables the GIL when it imports
citry_core._rust, as on 3.14t today.TypeErrorwithPyO3's new wording, and the argument's name moves into a note:
parse_template(123)raisedargument 'input': 'int' object cannot be cast as 'str', and now raises'int' object is not an instance of 'str'with
__notes__ == ["while processing 'input'"]. Nothing in therepository reads that text. The citry-core changelog notes it.
HtmlAttrKindvalues are shared objects now, soa.kind is b.kindholds where only==did. Afterdel sys.modules["citry_core._rust"], importing again builds a newmodule object, because PyO3 uses multi-phase initialization; the classes
stay the same objects.
The other removals (
Py::from_owned_ptr, thePyErrconversions from UTF-8errors, tuple super-class initialization and
get_refcnt) are not usedhere.
What Python can see
I dumped every module, class, method, signature and docstring of
citry_core._rustbefore and after: 644 entries. The dump records names,signatures and docstrings, so it does not see the error wording, tracking
and identity changes above. Within what it records, everything matches
except for one change that PyO3 0.28 made. The variant classes of
template_parser.Nodeandtemplate_parser.TemplateElementare now namedafter their variant, rather than after the enum and the variant joined
with
_:They also carry their Rust docstrings.
isinstance(node, Node.WithBody)isunaffected.
Why I kept the new names. PyO3 0.30 has no option to keep the old
flat names: its
#[pyclass]macro passes each variant's own name to theclass builder (
pyo3-macros-backend0.30.1,pyclass.rs,PyClassImplsBuilder::new(&variant_cls, &variant_name, ...)).It does not pass variant options through (its own comment there reads
"TODO: propagate variant.options"), so
#[pyo3(name = ...)]on a variantcannot rename the class. This is not a break in citry-core's public API:
the old flat names were never attributes of any module at runtime, public
or private, and existed only as type-only names in the private
_rust.pyistub.
citry_core.template_parserexportsNodeandTemplateElement,and
Node.WithBodyand the other variants are reached through them exactlyas before. So
packages/py/citry_core/CHANGELOG.mdnotes the new__name__,__qualname__and docstrings, without a breaking-change label.Nothing in the repository reads these names. I grepped
packages/py,docs_siteanddocsfor the old names, and for__name__,__qualname__andrepr()of template AST nodes. Thetype(...).__name__uses I found are on Citry's Python node classes and on Python's own
ast.The
_rust.pyistub now declares the variants as nested classes, as atruntime:
Node.SelfClosing,Node.WithBody,TemplateElement.Textandso on. The ruff exemption comment in
pyproject.tomlno longer namesNode_WithBody. mypy is clean on every package.Collector cost
Both builds were optimized (
--releasewithlto = false,codegen-units = 16and line-tables-only debug info, to fit the disk), onPython 3.14 on an Apple M-series Mac. Each figure is the median of five
fresh processes, and each process takes the median of its timed loop.
The render time and the parse-and-compile time are within noise. The newly
tracked objects add about 20% more generation-0 collections during a
render, but the time spent in them grows by about 1%. The AST classes
therefore stay tracked, and only the four native-render classes are
created untracked. The two throwaway scripts render the board through
benchmarks/web/apps/citry/app.pyand timeparse_templatepluscompile_template, with agc.callbackshook that counts and times eachcollection.
Tests
cargo test,cargo clippy --all-targets -D warningsandcargo fmtforcitry_core_pyandcitry_template_parser, plus the fast gate.suites pass (10,955 tests), including the GC-tracking tests that failed
until the objects were created untracked.
suites, and all 10,955 tests pass. The venv used newer versions of the
packages that have no 3.15 wheel at their locked version. With the newest
tzdata and Pygments, three tests that pin locked data failed; with the
locked tzdata 2026.3 and Pygments 2.20.0 they pass.
enabled, renders a component, and passes the citry_core suite (499
tests).
PyPy 3.11, 3.14t, Windows (x64 and x86, which now link with
raw-dylib)and Pyodide are not built locally; the release workflow builds them.
Changelog:
packages/py/citry_core/CHANGELOG.md(3.15 builds, thevariant-class names and the argument-error wording).
🤖 Generated with Claude Code