Skip to content

Pin Python version in R wrapper setup#708

Merged
MaxGhenis merged 1 commit intomainfrom
fix-setup-python-version-constraint
Feb 25, 2026
Merged

Pin Python version in R wrapper setup#708
MaxGhenis merged 1 commit intomainfrom
fix-setup-python-version-constraint

Conversation

@PavelMakarchuk
Copy link
Copy Markdown
Collaborator

Summary

  • setup_policyengine() now constrains the virtualenv to Python >=3.10,<3.14, matching the policyengine-us PyPI requirement
  • On machines with only Python 3.14 (current stable), setup previously failed silently at the pip install step
  • Adds clear error messages directing users to install Python 3.12 if no compatible version is found

Context

The Living Wage Calculator team bypassed setup_policyengine() entirely and wrote an 8-step manual installation guide — largely because setup_policyengine() doesn't handle the Python version constraint. On a fresh machine with Python 3.14, reticulate::virtualenv_create() picks up 3.14, then pip install policyengine-us fails because policyengine-us requires <3.14.

Changes

In r-package/policyenginetaxsim/R/setup.R:

  • Added .PE_PYTHON_VERSION constant (">=3.10,<3.14") matching the policyengine-us constraint
  • virtualenv_create() now passes version = .PE_PYTHON_VERSION to select a compatible Python
  • Pre-checks for compatible Python using virtualenv_starter() before attempting venv creation
  • Error messages now explain the version requirement and suggest brew install python@3.12

Closes #707

Test plan

  • Verify setup_policyengine(force = TRUE) works on machine with Python 3.12/3.13
  • Verify error message is clear on machine with only Python 3.14
  • Verify policyengine_calculate_taxes() works end-to-end after setup

🤖 Generated with Claude Code

setup_policyengine() now constrains the virtualenv to Python >=3.10,<3.14,
matching the policyengine-us requirement. Without this, setup fails on new
machines where the system Python is 3.14 (current stable as of Feb 2026).

Closes #707

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MaxGhenis MaxGhenis marked this pull request as ready for review February 25, 2026 02:24
@MaxGhenis MaxGhenis merged commit 3e4b4da into main Feb 25, 2026
7 checks passed
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.

R wrapper: setup_policyengine() fails on Python 3.14 (current stable)

2 participants