Skip to content

Commit 0159433

Browse files
committed
Switch from setuptools to uv
1 parent e8b1c03 commit 0159433

File tree

9 files changed

+585
-32
lines changed

9 files changed

+585
-32
lines changed

.github/workflows/testing.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,16 @@ jobs:
4040
- uses: actions/checkout@v4
4141
- name: install Just
4242
uses: taiki-e/install-action@just
43+
- name: Install uv
44+
uses: astral-sh/setup-uv@v3
45+
with:
46+
enable-cache: true
4347
- name: Set up Python
4448
uses: actions/setup-python@v5
4549
with:
4650
python-version: ${{ env.PYTHON_VERSION }}
47-
cache: "pip"
4851
- name: Install dependencies
49-
run: |
50-
pip install -U pip
51-
pip install -r requirements-dev.txt
52-
pip install -e .[all]
53-
maturin build --out dist
54-
pip install --no-index --find-links=dist/ prelude-parser
52+
run: just install
5553
- name: mypy check
5654
run: just mypy
5755
test:
@@ -63,20 +61,20 @@ jobs:
6361
runs-on: ${{ matrix.os }}
6462
steps:
6563
- uses: actions/checkout@v4
64+
- name: install Just
65+
uses: taiki-e/install-action@just
66+
- name: Install uv
67+
uses: astral-sh/setup-uv@v3
68+
with:
69+
enable-cache: true
6670
- name: Set up Python ${{ matrix.python-version }}
6771
uses: actions/setup-python@v5
6872
with:
6973
python-version: ${{ matrix.python-version }}
70-
cache: "pip"
7174
- name: Install dependencies
72-
run: |
73-
pip install -U pip
74-
pip install -r requirements-dev.txt
75-
pip install -e .[all]
76-
maturin build --out dist
77-
pip install --no-index --find-links=dist/ prelude-parser
75+
run: just install
7876
- name: Run tests
79-
run: pytest --cov=prelude_parser --cov-report=xml
77+
run: uv run pytest --cov=prelude_parser --cov-report=xml
8078
- name: Upload coverage
8179
uses: codecov/codecov-action@v4
8280
with:

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ Please include:
2626

2727
## Working on the code
2828

29-
In order to work on this project you will need to have [Rust](https://www.rust-lang.org/) and
29+
Note: This project uses uv to manage dependencies. If you do not already have uv installed you will
30+
need to install it with the instructions [here](https://docs.astral.sh/uv/getting-started/installation/)
31+
32+
In order to work on this project you will need to have [Rust](https://www.rust-lang.org/),
33+
[uv](https://docs.astral.sh/uv/getting-started/installation/), and
3034
[just](https://github.com/casey/just) in addition to Python.
3135

3236
### Fork the project
@@ -48,7 +52,7 @@ This creates the directory prelude-parser and connects your repository to the up
4852
Next create a vitural environment and activate it.
4953

5054
```sh
51-
python -m venv .venv
55+
uv venv
5256

5357
. .venv/bin/activate
5458
```

justfile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
maturin develop -E all
66

77
@install: && develop
8-
pip install -r requirements-dev.txt
8+
uv sync --frozen --all-extras
9+
10+
@lock:
11+
uv lock
912

1013
@lint:
1114
echo cargo check
@@ -14,8 +17,10 @@
1417
just --justfile {{justfile()}} clippy
1518
echo cargo fmt
1619
just --justfile {{justfile()}} fmt
17-
echo ruff
18-
just --justfile {{justfile()}} ruff
20+
echo ruff-check
21+
just --justfile {{justfile()}} ruff-check
22+
echo ruff-format
23+
just --justfile {{justfile()}} ruff-format
1924
echo mypy
2025
just --justfile {{justfile()}} mypy
2126

@@ -29,10 +34,13 @@
2934
cargo fmt
3035

3136
@mypy:
32-
mypy prelude_parser tests
37+
uv run mypy prelude_parser tests
38+
39+
@ruff-check:
40+
uv run ruff check prelude_parser tests
3341

34-
@ruff:
35-
ruff check . --fix
42+
@ruff-format:
43+
uv run ruff format prelude_parser tests
3644

3745
@test *args="":
38-
pytest {{args}}
46+
uv run pytest {{args}}

prelude_parser/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
parse_user_native_file,
1010
parse_user_native_string,
1111
)
12+
from prelude_parser._version import VERSION
1213
from prelude_parser.parser import parse_to_classes, parse_to_dict
1314

15+
__version__ = VERSION
16+
1417
__all__ = [
1518
"parse_site_native_file",
1619
"parse_site_native_string",

prelude_parser/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERSION = "0.11.2"

pyproject.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["maturin>=1.5,<2.0"]
3-
build-backend = "maturin"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "prelude-parser"
@@ -25,13 +25,28 @@ readme = "README.md"
2525
repository = "https://github.com/pbs-data-solutions/prelude-parser"
2626
homepage = "https://github.com/pbs-data-solutions/prelude-parser"
2727
documentation = "https://github.com/pbs-data-solutions/prelude-parser"
28+
dynamic = ["version"]
2829
dependencies = ["camel-converter>=3.0.0"]
2930

3031
[project.optional-dependencies]
3132
pandas = ["pandas>=2.1.0"]
3233
polars = ["polars>=0.17.14"]
3334
all = ["pandas>=2.1.0", "polars>=0.17.14"]
3435

36+
[dependency-groups]
37+
dev = [
38+
"maturin==1.7.4",
39+
"mypy==1.13.0",
40+
"pandas-stubs==2.2.3.241009; python_version>='3.10'",
41+
"pytest==8.3.3",
42+
"pytest-cov==6.0.0",
43+
"ruff==0.7.1",
44+
"tomli==2.0.2; python_version<'3.11'",
45+
]
46+
47+
[tool.hatch.version]
48+
path = "prelude_parser/_version.py"
49+
3550
[tool.maturin]
3651
module-name = "prelude_parser._prelude_parser"
3752
binding = "pyo3"

requirements-dev.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/test_version.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
from pathlib import Path
3+
4+
from prelude_parser import __version__
5+
6+
if sys.version_info < (3, 11):
7+
import tomli as tomllib
8+
else:
9+
import tomllib
10+
11+
12+
def test_versions_match():
13+
pyproject = Path().absolute() / "Cargo.toml"
14+
with open(pyproject, "rb") as f:
15+
data = tomllib.load(f)
16+
cargo_version = data["package"]["version"]
17+
18+
assert __version__ == cargo_version

0 commit comments

Comments
 (0)