Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/pr_code_changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ on:
workflow_dispatch:

jobs:
Python-Compat:
name: Install + smoke-import (py${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install package
run: uv pip install --system .
- name: Smoke-import
run: python -c "import policyengine_uk; print('import OK')"
Lint:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions changelog.d/support-py39.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support Python 3.9 and 3.10 (in addition to 3.11–3.14). On Python 3.9/3.10, pip resolves `policyengine-core` to a version that has been relaxed to support older Python (3.24.0+); on 3.11+ behavior is unchanged.
4 changes: 2 additions & 2 deletions policyengine_uk/data/dataset_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas as pd
import numpy as np
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, List, Optional

if TYPE_CHECKING:
from policyengine_uk import Microsimulation
Expand Down Expand Up @@ -179,7 +179,7 @@ class UKMultiYearDataset:
def __init__(
self,
file_path: str = None,
datasets: list[UKSingleYearDataset] | None = None,
datasets: Optional[List[UKSingleYearDataset]] = None,
):
if datasets is not None:
self.datasets = {}
Expand Down
2 changes: 1 addition & 1 deletion policyengine_uk/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __init__(
Union[pd.DataFrame, str, UKSingleYearDataset, UKMultiYearDataset]
] = None,
trace: bool = False,
reform: Dict | Type[Reform] = None,
reform: Union[Dict, Type[Reform]] = None,
):
"""Initialize a UK simulation.

Expand Down
34 changes: 20 additions & 14 deletions policyengine_uk/tests/test_build_metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from contextlib import ExitStack
from unittest.mock import patch

from policyengine_uk.build_metadata import (
Expand All @@ -19,20 +20,25 @@ def test_data_build_fingerprint_is_stable_within_process():
def test_get_data_build_metadata_includes_version_git_sha_and_fingerprint():
get_data_build_fingerprint.cache_clear()

with (
patch(
"policyengine_uk.build_metadata._get_package_version",
return_value="2.74.0",
),
patch(
"policyengine_uk.build_metadata._get_git_sha",
return_value="deadbeef",
),
patch(
"policyengine_uk.build_metadata.get_data_build_fingerprint",
return_value="sha256:fingerprint",
),
):
with ExitStack() as stack:
stack.enter_context(
patch(
"policyengine_uk.build_metadata._get_package_version",
return_value="2.74.0",
)
)
stack.enter_context(
patch(
"policyengine_uk.build_metadata._get_git_sha",
return_value="deadbeef",
)
)
stack.enter_context(
patch(
"policyengine_uk.build_metadata.get_data_build_fingerprint",
return_value="sha256:fingerprint",
)
)
metadata = get_data_build_metadata()

assert metadata == {
Expand Down
19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ classifiers = [
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Information Analysis",
]
requires-python = ">=3.11"
requires-python = ">=3.9"
dependencies = [
"policyengine-core>=3.23.6",
"microdf-python>=1.2.1",
"pydantic>=2.11.7",
"tables>=3.10.2",
"tables>=3.9.2,<3.10.2; python_version < '3.10'",
"tables>=3.10.0,<3.10.2; python_version == '3.10.*'",
"tables>=3.10.2; python_version >= '3.11'",
]

[project.urls]
Expand All @@ -51,6 +55,16 @@ include = [
[tool.hatch.build.targets.wheel]
packages = ["policyengine_uk"]

[tool.uv]
# Until policyengine-core ships 3.9/3.10 support (3.24.0+), restrict
# uv.lock resolution to >=3.11. `requires-python` above still declares
# 3.9 is supported — pip users on 3.9/3.10 will resolve against PyPI
# once core 3.24+ is published. Remove this block once the lockfile
# can cleanly resolve across 3.9-3.14.
environments = [
"python_version >= '3.11'",
]

[project.optional-dependencies]
dev = [
"ruff>=0.9.0",
Expand Down Expand Up @@ -109,6 +123,7 @@ showcontent = true

[tool.ruff]
line-length = 88
target-version = "py39"
extend-exclude = [
"docs/book/programs/gov/dfe/care-to-learn.ipynb",
]
Expand Down
Loading
Loading