Skip to content

feat: Python 3.11–3.14 compatibility, PEP 621 packaging, and uv CI migration#154

Open
ravenoak wants to merge 16 commits into
lab-v2:mainfrom
ravenoak:python-3-12-plus-compat
Open

feat: Python 3.11–3.14 compatibility, PEP 621 packaging, and uv CI migration#154
ravenoak wants to merge 16 commits into
lab-v2:mainfrom
ravenoak:python-3-12-plus-compat

Conversation

@ravenoak
Copy link
Copy Markdown

@ravenoak ravenoak commented May 14, 2026

Summary

  • Python 3.11–3.14 support: Updated numba (≥0.65.1), numpy (≥2.1,<2.5), pandas (≥2.0.0), torch (≥2.6.0), and networkx (≥3.1) to versions that support the full 3.10–3.14 range; added classifiers for all supported versions
  • Modern packaging (PEP 621): Migrated all project metadata from setup.py into pyproject.toml [project] table; deleted setup.py; setuptools-scm now lives exclusively in [build-system] with a fallback_version = "0.0.0" safety net
  • Optional dependencies: Extracted torch, dev (pytest, ruff, pre-commit, memory_profiler), and docs (sphinx) into [project.optional-dependencies] groups; memory_profiler import in pyreason.py is now guarded with a helpful ImportError if the profiling flag is set without the package installed
  • CI/CD modernization: GitHub Actions upgraded from v3 → v4 across all workflows; Python test matrix expanded to 3.10–3.14; uv adopted for package installation (astral-sh/setup-uv@v3); publish workflow updated with fetch-depth: 0 (required for setuptools-scm tag resolution); ReadTheDocs updated to Python 3.12, ubuntu-24.04, and pip-extras install method
  • importlib.metadata: Replaced deprecated pkg_resources.get_distribution with importlib.metadata.version in __init__.py
  • pytest cleanup: Removed blanket ignore::UserWarning suppression; kept targeted Numba and NetworkX filters

Test Plan

  • Unit test suite passes: pytest tests/unit/disable_jit — 466 passed, 37 skipped, 0 failed
  • Verify CI matrix runs green on Python 3.10, 3.11, 3.12, 3.13, 3.14
  • Confirm uv pip install -e ".[dev,torch]" installs cleanly on a fresh environment
  • Confirm uv pip install -e ".[docs]" builds docs without errors

🤖 Generated with Claude Code

ravenoak and others added 12 commits May 13, 2026 14:23
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n CI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merge origin/main into python-3-12-plus-compat. Only conflict was
setup.py (deleted in this branch, bumped to 3.6.0 on main) — resolved
by keeping deletion since all metadata has moved to pyproject.toml.

All other changes (interpretation.py docstrings, test updates, annotation
function 6-arg signature support) merged automatically.
…3.12+ compat

Numba 0.65.x tightened nopython type inference for list comprehensions
that construct tuples from separate variables. The three affected cases in
get_rule_edge_clause_grounding build edge tuples (source, target) from two
string variables; replacing with empty_list + append loop resolves the
TypingError on Python 3.12/3.13/3.14.

Also bump actions/setup-python v4 -> v5 and astral-sh/setup-uv v3 -> v6
across CI workflows to avoid Node.js 20 deprecation breakage on June 2, 2026.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ravenoak ravenoak marked this pull request as draft May 14, 2026 17:34
The parallel consistency test requires interpretation.py and
interpretation_parallel.py to be identical except for parallel=True/False.
Apply the same numba.typed.List.empty_list + append loop pattern to the
three cases in get_rule_edge_clause_grounding.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ColtonPayne
Copy link
Copy Markdown
Collaborator

Hi @ravenoak! Thanks very much for working on this contribution. As an FYI, we have been testing out some python compatibility updates in a prerelease here. Just wanted you to be aware - I will look into this PR soon!

ravenoak and others added 3 commits May 14, 2026 11:36
…ba type unification on Python 3.11+

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…3.11+

Three separate issues prevented JIT compilation of reason() on Python 3.11+:

1. Recursion limit: Python 3.11+ bytecode generates ~2300 CFG nodes for
   the large reason() function; Numba's recursive _dfs_rec DFS exceeded
   Python's default limit of 1000. Fixed by raising the limit to 5000 in
   __init__.py before any JIT compilation is triggered.

2. Variable type conflict: loop variable 'i' was reused across the 567-line
   reason() function as both int64 (range/prange loops) and a complex Tuple
   (enumerate loops). Python 3.11+ bytecode creates phi nodes where Numba
   0.65.x can no longer unify the types. Fixed by renaming integer loop
   variables: facts loops use 'fi', rules-parallel loop uses 'ri',
   list-comprehension indices use 'j'. Same change applied to
   interpretation_parallel.py to keep files in sync.

3. Actions versions: bump actions/checkout v4 -> v6, actions/setup-python
   v4 -> v5, astral-sh/setup-uv v3 -> v6 across CI workflows to clear
   Node.js 20 deprecation warnings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mba JIT cache

- Replace numba.typed.List comprehensions with explicit loops in
  interpretation_fp.py to fix TypingError on Python 3.12+
- Rename integer loop variable 'i' to avoid type-unification conflicts
  with enumerate tuple 'i' in the @numba.njit reason() function
- Add actions/cache@v4 to persist Numba JIT artifacts across CI runs,
  keyed on Python version + script content hash (per-function hash
  invalidation means only changed functions recompile on cache restore)
- Remove timeout-minutes from CI job so long 3.11+ JIT runs can complete

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ravenoak
Copy link
Copy Markdown
Author

Hi @ravenoak! Thanks very much for working on this contribution. As an FYI, we have been testing out some python compatibility updates in a prerelease here. Just wanted you to be aware - I will look into this PR soon!

Awesome, thank you! There are some updates to the GHA workflows as well, which you can see in ravenoak#1

@ravenoak ravenoak changed the title feat: Python 3.12–3.14 compatibility, PEP 621 packaging, and uv CI migration feat: Python 3.11–3.14 compatibility, PEP 621 packaging, and uv CI migration May 19, 2026
@ravenoak ravenoak marked this pull request as ready for review May 19, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants