Skip to content

Commit

Permalink
build: migrate to uv (#161)
Browse files Browse the repository at this point in the history
* build: migrate to uv

* build: remove unneeded deps
  • Loading branch information
qartik authored Feb 6, 2025
1 parent faf61bc commit 705a783
Show file tree
Hide file tree
Showing 8 changed files with 865 additions and 74 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,32 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
enable-cache: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -e .
uv sync --all-extras --dev
- name: Pre-commit checks
run: |
uv run pre-commit run --all-files
- name: Run tests
run: |
python -m pytest
uv run pytest
- name: Sphinx documentation build
run: |
make docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.python-version == '3.12' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.python-version == '3.13' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: check-json

- repo: https://github.com/crate-ci/typos
rev: dictgen-v0.3.1
rev: typos-dict-v0.12.4
hooks:
- id: typos
args: []
Expand All @@ -26,7 +26,7 @@ repos:
- id: markdownlint-cli2

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.31.0
rev: 0.31.1
hooks:
- id: check-github-workflows
- id: check-metaschema
Expand All @@ -43,7 +43,7 @@ repos:
- black==23.10.1

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.3
rev: v0.9.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
.PHONY: install dev tests lint docs clean build updateschema

install:
pip install .
uv pip install .

dev:
pip install -e .
uv pip install -e .

tests:
pytest .
uv run pytest .

lint:
pre-commit run --all-files
uv run pre-commit run --all-files

docs:
sphinx-apidoc -f -o docs/source/ phir
sphinx-build -M html docs/source/ docs/build/
uv run sphinx-apidoc -f -o docs/source/ phir
uv run sphinx-build -M html docs/source/ docs/build/

clean:
rm -rf *.egg-info dist build docs/build

build: clean
python -m build --sdist --wheel -n
uv build

updateschema: install
phir-cli -s > schema.json
uv run phir-cli -s > schema.json
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,12 @@ options:
Clone the repository and run:
```sh
python -m venv .venv
source .venv/bin/activate
pip install -U pip setuptools
pip install -r requirements.txt
pre-commit install
```
Then, install the project using:
```sh
pip install -e .
uv sync
uv run pre-commit install
```
See `Makefile` for other useful commands.
## Testing
Issue `pytest` from the root directory.
Issue `make tests` from the root directory.
34 changes: 16 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
[build-system]
requires = [
"setuptools>=64",
"setuptools_scm>=8",
"wheel",
]
requires = ["setuptools>=64", "setuptools_scm>=8", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "phir"
description = "A data model and validation tool for PHIR (PECOS High-level Intermediate Representation)."
readme = "README.md"
requires-python = ">=3.10"
license = {file = "LICENSE"}
license = { file = "LICENSE" }
authors = [
{name = "Kartik Singhal", email = "[email protected]" },
{name = "Ciarán Ryan-Anderson", email = "[email protected]" },
{ name = "Kartik Singhal", email = "[email protected]" },
{ name = "Ciarán Ryan-Anderson", email = "[email protected]" },
]
classifiers = [
"Environment :: Console",
Expand All @@ -28,15 +24,19 @@ classifiers = [
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = ["pydantic", "rich"]
dependencies = [
"pydantic==2.10.6",
"rich==13.9.4"
]

[project.optional-dependencies]
docs = [
"autodoc-pydantic",
"pydata_sphinx_theme",
"sphinx",
[dependency-groups]
dev = [
"autodoc-pydantic==2.2.0",
"pre-commit==4.1.0",
"pydata_sphinx_theme==0.16.1",
"pytest==8.3.4",
"sphinx==8.1.3",
]
tests = ["pytest"]

[project.scripts]
phir-cli = "phir.cli:main"
Expand All @@ -53,9 +53,7 @@ where = ["."]
"phir" = ["py.typed"]

[tool.pytest.ini_options]
pythonpath = [
"."
]
pythonpath = ["."]

[tool.setuptools_scm]
version_scheme = "python-simplified-semver"
12 changes: 0 additions & 12 deletions requirements.txt

This file was deleted.

36 changes: 24 additions & 12 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"properties": {
"meta": {
"const": "barrier",
"title": "Meta"
"title": "Meta",
"type": "string"
},
"args": {
"items": {
Expand Down Expand Up @@ -164,7 +165,8 @@
},
"data": {
"const": "cvar_define",
"title": "Data"
"title": "Data",
"type": "string"
},
"data_type": {
"enum": [
Expand Down Expand Up @@ -236,7 +238,8 @@
},
"data": {
"const": "cvar_export",
"title": "Data"
"title": "Data",
"type": "string"
},
"variables": {
"items": {
Expand Down Expand Up @@ -286,7 +289,8 @@
},
"cop": {
"const": "ffcall",
"title": "Cop"
"title": "Cop",
"type": "string"
},
"returns": {
"anyOf": [
Expand Down Expand Up @@ -383,7 +387,8 @@
},
"mop": {
"const": "Idle",
"title": "Mop"
"title": "Mop",
"type": "string"
},
"args": {
"items": {
Expand Down Expand Up @@ -450,7 +455,8 @@
},
"block": {
"const": "if",
"title": "Block"
"title": "Block",
"type": "string"
},
"condition": {
"$ref": "#/$defs/COp"
Expand Down Expand Up @@ -578,7 +584,8 @@
},
"qop": {
"const": "Measure",
"title": "Qop"
"title": "Qop",
"type": "string"
},
"returns": {
"items": {
Expand Down Expand Up @@ -643,7 +650,8 @@
},
"block": {
"const": "qparallel",
"title": "Block"
"title": "Block",
"type": "string"
},
"ops": {
"items": {
Expand Down Expand Up @@ -688,7 +696,8 @@
},
"data": {
"const": "qvar_define",
"title": "Data"
"title": "Data",
"type": "string"
},
"data_type": {
"anyOf": [
Expand Down Expand Up @@ -835,7 +844,8 @@
},
"block": {
"const": "sequence",
"title": "Block"
"title": "Block",
"type": "string"
},
"ops": {
"items": {
Expand Down Expand Up @@ -907,7 +917,8 @@
},
"mop": {
"const": "Skip",
"title": "Mop"
"title": "Mop",
"type": "string"
},
"args": {
"anyOf": [
Expand Down Expand Up @@ -1100,7 +1111,8 @@
},
"mop": {
"const": "Transport",
"title": "Mop"
"title": "Mop",
"type": "string"
},
"args": {
"anyOf": [
Expand Down
Loading

0 comments on commit 705a783

Please sign in to comment.