Patching Python 3.14 Support#14324
Draft
nucleogenesis wants to merge 7 commits intolearningequality:release-v0.19.xfrom
Draft
Patching Python 3.14 Support#14324nucleogenesis wants to merge 7 commits intolearningequality:release-v0.19.xfrom
nucleogenesis wants to merge 7 commits intolearningequality:release-v0.19.xfrom
Conversation
django-filter 21.1 uses pkgutil.find_loader at import time, which was removed in Python 3.14. Patch it to use importlib.util.find_spec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pytest 6.2.5 uses ast.Str removed in Python 3.14. Use pytest >=7 on Python 3.10+, which has built-in pythonpath support (replacing pytest-pythonpath). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Python 3.14 changed the behavior of copy(super()), which breaks Django 3.2's BaseContext.__copy__. Backport the fix from Django's main branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
- Revert factory-boy version split: factory-boy 2.7.0 + fake-factory work fine on all Python versions including 3.14 - Version-split cffi and cryptography in cext.txt: pinned versions don't build on Python 3.14, use newer versions there Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Add Python 3.14 support to Kolibri using monkey patches for stdlib removals, without dropping support for Python 3.6–3.13.
Python 3.14 removed several stdlib APIs that our pinned dependencies rely on:
pkgutil.find_loader(used by django-filter 21.1) — patched viaimportlib.util.find_specast.Str(used by pytest 6.x assertion rewriting) — handled by version-splitting test deps to use pytest 7+ on Python ≥3.10BaseContext.__copy__behavior change in Django 3.2 — patched with the fix from Django's main branchAdditionally:
le-utilsandmorangohavepython_requires <3.14on PyPI (code works fine on 3.14). For py3.14, they're installed frompy3.14-bumpgit branches with the constraint bumped to<3.15.cgianddistutils(added for 3.12/3.13) already cover Django and redis on 3.14.Verification:
References
Closes #13823
Reviewer guidance
The changes are isolated to build/CI config and monkey patches:
kolibri/utils/env.py— Two new monkey patch functions (monkey_patch_pkgutilandfix_django_template_context_copy), both guarded bysys.version_info < (3, 14)so they're no-ops on older Python. They follow the exact same pattern as the existingmonkey_patch_distutilsandforward_port_cgi_modulepatches in the same file.requirements/test.txt— pytest 6.x for Python <3.10, pytest 7+ for Python ≥3.10. The split is needed because pytest 6 usesast.Str(removed in 3.14) and pytest 7+ is incompatible withpytest-pythonpath.pytest.ini— Has bothpython_paths(for pytest-pythonpath on pytest <7) andpythonpath(built-in on pytest 7+). Each version warns about the other's config key but doesn't error.requirements/base.txt/tox.ini— le-utils and morango getpython_version < "3.14"markers on the PyPI pins, with git-based installs frompy3.14-bumpbranches for py≥3.14 in tox deps.Risky areas:
fix_django_template_context_copypatch is the least obvious — verify it's needed by reverting it and running tests on py3.14 if in doubt.AI usage
This PR was developed using Claude Code with a sub-agent driven workflow. I created the investigation plan and made key architectural decisions (monkey patching over conditional deps, version-split boundary at py3.10, scope limited to test-pass). Claude Code performed the empirical testing on a Python 3.14.2 venv to identify all compatibility issues, implemented each change via subagents with spec compliance and code quality reviews after each task, and ran the full test suite on both py3.14 and py3.9 to verify correctness and no regressions.