Skip to content

Conversation

@MaxGhenis
Copy link
Contributor

Summary

This PR adds support for Python 3.14 to policyengine-core.

Changes

  • Added Python 3.14 to classifiers in setup.py
  • Added Python 3.14 to CI test matrix (Test and SmokeTestForMultipleVersions jobs)
  • Updated dependency installation logic to handle Python 3.14 similarly to Python 3.13

Test Plan

  • CI will run tests on Python 3.10, 3.11, 3.12, 3.13, and 3.14
  • Smoke tests will verify compatibility with policyengine-us on all Python versions

Related Issue

Fixes #399

🤖 Generated with Claude Code

- Add Python 3.14 to classifiers in setup.py
- Add Python 3.14 to CI test matrix
- Update dependency installation for Python 3.13+ to include 3.14

Fixes PolicyEngine#399

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.88%. Comparing base (58c2fca) to head (1b22170).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #401      +/-   ##
==========================================
+ Coverage   81.14%   81.88%   +0.74%     
==========================================
  Files         197      198       +1     
  Lines       10228    10233       +5     
  Branches     1057     1038      -19     
==========================================
+ Hits         8299     8379      +80     
+ Misses       1640     1593      -47     
+ Partials      289      261      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MaxGhenis
Copy link
Contributor Author

Status Update

Python 3.14 was released on October 7, 2025. CI tests are currently failing because h5py doesn't have Python 3.14 wheels yet.

Current Situation

  • h5py has Python 3.14 wheels in nightly builds
  • Stable release (h5py 3.15) is being planned (issue #2651)
  • Building h5py from source is failing on Python 3.14

Next Steps

This PR will remain in draft status until h5py 3.15 is released on PyPI. Once that happens, CI should pass and the PR can be marked ready for review.

Tracking: h5py/h5py#2713

@MaxGhenis
Copy link
Contributor Author

Update: h5py blocker resolved! 🎉

The dependency blocker mentioned in the status update has been resolved:

  • h5py 3.15.1 is now available on PyPI with Python 3.14 wheels
  • The h5py project now lists Python 3.14 as officially supported

This PR should be ready for a CI re-run to verify all tests pass. Once confirmed, it can be marked ready for review.

@MaxGhenis
Copy link
Contributor Author

⚠️ Important Update: Critical Bug Blocks Python 3.14 Support

While h5py 3.15.1 now supports Python 3.14, there's a critical bug that must be fixed first:

Issue #407: The person() accessor in Microsimulation returns unweighted values on Python 3.14 instead of weighted values. This causes all tax calculations to return near-zero values.

Example:

  • Python 3.13: person('taxed_dividend_income', '2027').sum() → £86.7bn ✅
  • Python 3.14: same code → £0.11bn ❌

This is a blocker for Python 3.14 support - we cannot ship 3.14 until #407 is resolved.

See also: PolicyEngine/policyengine-uk#1401 for the downstream impact on dividend tax calculations.

@MaxGhenis
Copy link
Contributor Author

Root Cause Investigation Complete

I've investigated the Python 3.14 compatibility issue (#407) and found the root cause:

The Problem

This is a NumPy bug, not a policyengine-core bug. NumPy's "temporary elision" optimization incorrectly identifies arrays as temporary on Python 3.14 due to the new LOAD_FAST_BORROW bytecode instruction.

The Fix

Upgrade NumPy to 2.3.0+

NumPy Version dividend_income_tax (UK)
2.1.3 £0.00bn ❌
2.3.5 £22.55bn ✅

Changes Needed for This PR

  1. Update setup.py to allow numpy>=2.1.0,<3 (done on master branch)
  2. This PR should require numpy>=2.3.0 specifically for Python 3.14 tests
  3. Once h5py and numpy constraints are satisfied, all tests should pass

The h5py blocker is already resolved (3.15.1 supports 3.14). With numpy 2.3.5, Python 3.14 support should work correctly.

@MaxGhenis
Copy link
Contributor Author

Closing - the main Python 3.14 blocker (NumPy temporary elision bug) is now addressed in #409, and h5py 3.15.1 has Python 3.14 wheels available.

@MaxGhenis MaxGhenis closed this Dec 2, 2025
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.

Upgrade to Python 3.14

1 participant