Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/is-version-number-acceptable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ then
exit 0
fi

current_version=`python setup.py --version`
current_version=`python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])"`

if git rev-parse --verify --quiet $current_version
then
echo "Version $current_version already exists in commit:"
git --no-pager log -1 $current_version
echo
echo "Update the version number in setup.py before merging this branch into master."
echo "Update the version number in pyproject.toml before merging this branch into master."
echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated."
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/publish-git-tag.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env bash

git tag `python setup.py --version`
git tag `python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])"`
git push --tags || true # update the repository version
30 changes: 18 additions & 12 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build changelog
run: pip install yaml-changelog>=0.1.7 && make changelog
run: uv tool install yaml-changelog>=0.1.7 && make changelog
- name: Preview changelog update
run: ".github/get-changelog-diff.sh"
- name: Check version number has been properly updated
Expand All @@ -39,7 +41,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Enable long paths in Git (Windows only)
if: runner.os == 'Windows'
run: git config --system core.longpaths true
Expand All @@ -50,6 +52,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install package
run: make install
- name: Run tests
Expand All @@ -75,27 +79,29 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install -core package
run: |
python -m pip install .
python -m pip install "pytest-rerunfailures>=10,<15"
uv sync
uv pip install "pytest-rerunfailures>=10,<15"
- name: Verify pytest plugins
run: python -m pytest --version
run: uv run python -m pytest --version
- name: Install -us package from PyPI
run: |
if [[ "${{ matrix.python-version }}" == "3.13" ]]; then
# For Python 3.13, install newer tables first and ignore conflicts
pip install "tables>=3.10.1"
pip install policyengine-us --no-deps
uv pip install "tables>=3.10.1"
uv pip install policyengine-us --no-deps
# Install remaining dependencies manually
pip install click==8.1.3 pathlib pytest-dependency synthimpute tabulate
pip install policyengine-us-data --no-deps
uv pip install click==8.1.3 pathlib pytest-dependency synthimpute tabulate
uv pip install policyengine-us-data --no-deps
else
python -m pip install policyengine-us
uv pip install policyengine-us
fi
shell: bash
- name: Run smoke tests only
run: python -m pytest -m smoke --reruns 2 --reruns-delay 5 -v -s
run: uv run python -m pytest -m smoke --reruns 2 --reruns-delay 5 -v -s
env:
RUN_SMOKE_TESTS: "0"
POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build changelog
run: pip install yaml-changelog && make changelog
run: uv tool install yaml-changelog && make changelog
- name: Preview changelog update
run: ".github/get-changelog-diff.sh"
- name: Update changelog
Expand All @@ -54,6 +56,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install package
run: make install
- name: Run tests
Expand All @@ -80,6 +84,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Publish a git tag
run: ".github/publish-git-tag.sh || true"
- name: Install package
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ all: install format test build changelog
documentation:
jb clean docs
jb build docs
python docs/add_plotly_to_book.py docs/_build
uv run python docs/add_plotly_to_book.py docs/_build

format:
black . -l 79
uv run black . -l 79

install:
pip install -e ".[dev]" --config-settings editable_mode=compat
uv sync --all-extras

test-country-template:
policyengine-core test policyengine_core/country_template/tests -c policyengine_core.country_template
uv run policyengine-core test policyengine_core/country_template/tests -c policyengine_core.country_template

mypy:
mypy --config-file mypy.ini policyengine_core tests
uv run mypy --config-file mypy.ini policyengine_core tests

test: test-country-template
coverage run -a --branch -m pytest tests --disable-pytest-warnings --reruns 2 --reruns-delay 5
coverage xml -i
uv run coverage run -a --branch -m pytest tests --disable-pytest-warnings --reruns 2 --reruns-delay 5
uv run coverage xml -i

build:
python setup.py sdist bdist_wheel
uv build

changelog:
build-changelog changelog.yaml --output changelog.yaml --update-last-date --start-from 0.1.0 --append-file changelog_entry.yaml
build-changelog changelog.yaml --org PolicyEngine --repo policyengine-core --output CHANGELOG.md --template .github/changelog_template.md
bump-version changelog.yaml setup.py
uv run build-changelog changelog.yaml --output changelog.yaml --update-last-date --start-from 0.1.0 --append-file changelog_entry.yaml
uv run build-changelog changelog.yaml --org PolicyEngine --repo policyengine-core --output CHANGELOG.md --template .github/changelog_template.md
uv run bump-version changelog.yaml pyproject.toml
rm changelog_entry.yaml || true
touch changelog_entry.yaml
touch changelog_entry.yaml
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
changed:
- Migrated from pip/setup.py to uv/pyproject.toml for faster dependency management and modern Python packaging
87 changes: 87 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "policyengine-core"
version = "3.23.6"
description = "Core microsimulation engine enabling country-specific policy models."
readme = "README.md"
license = "AGPL-3.0-or-later"
license-files = ["LICENSE"]
authors = [
{ name = "PolicyEngine", email = "hello@policyengine.org" }
]
keywords = ["tax", "benefit", "microsimulation", "framework"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Information Analysis",
]
requires-python = ">=3.10"

dependencies = [
"pytest>=8,<9",
# NumPy 2.3+ required for Python 3.14 due to temporary elision bug fix
# See: https://github.com/numpy/numpy/issues/28681
"numpy>=2.1.0,<3",
"sortedcontainers<3",
"numexpr<3",
"dpath<3",
"psutil>=6,<7",
"wheel<1",
"h5py>=3,<4",
"requests>=2,<3",
"pandas>=1",
"plotly>=5,<6",
"ipython>=8,<9",
"pyvis>=0.3.2",
"microdf_python>=1.0.0",
"huggingface_hub>=0.25.1",
"standard-imghdr",
]

[project.optional-dependencies]
dev = [
"black",
"linecheck<1",
"jupyter-book<1",
"yaml-changelog<1",
"coverage",
"furo<2025",
"markupsafe<3",
"mypy<2",
"sphinx==5.0.0",
"sphinx-argparse==0.4.0",
"sphinx-math-dollar==1.2.1",
"types-PyYAML==6.0.12.2",
"types-requests==2.28.11.7",
"types-setuptools==65.6.0.2",
"types-urllib3==1.26.25.4",
"pytest-rerunfailures>=10,<15",
]

[project.scripts]
policyengine-core = "policyengine_core.scripts.policyengine_command:main"

[project.urls]
Homepage = "https://github.com/policyengine/policyengine-core"
Repository = "https://github.com/policyengine/policyengine-core"
Documentation = "https://policyengine.github.io/policyengine-core/"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
exclude = ["tests*"]

[tool.setuptools.package-data]
"*" = ["*"]

[tool.black]
line-length = 79
91 changes: 0 additions & 91 deletions setup.py

This file was deleted.

Loading
Loading