fix(setup): don't force abi3 wheel tag on free-threaded builds#341
Open
JSap0914 wants to merge 1 commit into
Open
fix(setup): don't force abi3 wheel tag on free-threaded builds#341JSap0914 wants to merge 1 commit into
JSap0914 wants to merge 1 commit into
Conversation
On free-threaded CPython (Py_GIL_DISABLED), the extension is already built without the limited API (py_limited_api = not Py_GIL_DISABLED), so the produced .so uses the full, version-specific ABI (e.g. _binding.cpython-314t-darwin.so). BdistWheel.get_tag, however, unconditionally rewrote any cp* wheel tag to cp310/abi3, mislabeling the free-threaded wheel as a stable-ABI (abi3) wheel. This produces a wheel whose tag does not match its contents, which breaks installation/import on free-threaded interpreters (tree-sitter#337). Gate the abi3 rewrite on the same Py_GIL_DISABLED condition already used for py_limited_api so the wheel tag matches the ABI the extension was actually built against. GIL builds are unaffected and still tag cp310/abi3. Closes tree-sitter#337 Signed-off-by: JSup <hanjisang0914@gmail.com>
|
Thanks! Free-threaded 3.15 and newer does support limited API builds, so you might as well account for that right now and make the build skip it only on 3.14 and older. |
|
Although I don't know offhand if tree-sitter's C extensions actually do build on abi3t, see https://docs.python.org/3.15/howto/abi3t-migration.html#abi3t-migration-howto |
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.
Problem
On free-threaded CPython (
Py_GIL_DISABLED),tree-sitter-pythonbuilds an extension without the limited API — this is already correct, because theExtensionsets:So on a free-threaded interpreter the produced
.souses the full, version-specific ABI (e.g._binding.cpython-314t-darwin.so).However,
BdistWheel.get_tagunconditionally rewrote anycp*wheel tag tocp310/abi3:The result is a wheel tagged as stable-ABI (
cp310-abi3) whose contents are a non-abi3, free-threaded extension. The wheel tag lies about the ABI, which breaks installation/import on free-threaded interpreters (reported in #337 asImportError: symbol not found in flat namespace '_tree_sitter_python_external_scanner_create'/ anabi3wheel that is unusable on3.14t).Fix
Gate the
abi3rewrite on the samePy_GIL_DISABLEDcondition already used forpy_limited_api, so the wheel tag matches the ABI the extension was actually built against. This mirrors the fix suggested by the reporter (@ngoldbaum) in #337, expressed against the existingget_config_varimport so the two ABI decisions stay in sync.cp310-abi3.cp314-cp314t).Verification
Built and installed the wheel with
cpython-3.14.6+freethreadedand a regular GIL3.13:import tree_sitter_python3.14t(free-threaded)cp310-abi3(wrong)cp314-cp314t(correct)3.13(GIL)cp310-abi3cp310-abi3(unchanged)After the fix, on free-threaded
3.14tthe wheelWHEELmetadata reportsTag: cp314-cp314t-..., matching the bundled_binding.cpython-314t-darwin.so, and the existing binding test (bindings/python/tests/test_binding.py) passes on both interpreters.Closes #337