Skip to content

Commit 18fefa0

Browse files
authored
Merge pull request #430 from pbs-data-solutions/uv
Switch from setuptools to uv
2 parents b60af4f + 8447158 commit 18fefa0

File tree

9 files changed

+570
-31
lines changed

9 files changed

+570
-31
lines changed

.github/workflows/testing.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ 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
4952
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
53+
uv sync --frozen --all-extras
54+
uv run maturin build
5555
- name: mypy check
5656
run: just mypy
5757
test:
@@ -63,20 +63,20 @@ jobs:
6363
runs-on: ${{ matrix.os }}
6464
steps:
6565
- uses: actions/checkout@v4
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
7275
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
76+
uv sync --frozen --all-extras
77+
uv run maturin build
7878
- name: Run tests
79-
run: pytest --cov=prelude_parser --cov-report=xml
79+
run: uv run pytest --cov=prelude_parser --cov-report=xml
8080
- name: Upload coverage
8181
uses: codecov/codecov-action@v4
8282
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: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
just --list
33

44
@develop:
5-
maturin develop -E all
5+
uv run 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: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ build-backend = "maturin"
44

55
[project]
66
name = "prelude-parser"
7-
requires-python = ">=3.9"
7+
requires-python = ">=3.10"
88
description = "Parses XML files exported from Prelude EDC into formats usable by Python."
99
authors = [{name = "Paul Sanders", email = "[email protected]"}]
1010
keywords = ["parser", "prelude-edc", "xml", "pandas", "polars"]
1111
classifiers = [
1212
"Programming Language :: Rust",
1313
"Programming Language :: Python :: Implementation :: CPython",
14-
"Programming Language :: Python :: 3.9",
1514
"Programming Language :: Python :: 3.10",
1615
"Programming Language :: Python :: 3.11",
1716
"Programming Language :: Python :: 3.12",
@@ -25,13 +24,28 @@ readme = "README.md"
2524
repository = "https://github.com/pbs-data-solutions/prelude-parser"
2625
homepage = "https://github.com/pbs-data-solutions/prelude-parser"
2726
documentation = "https://github.com/pbs-data-solutions/prelude-parser"
27+
dynamic = ["version"]
2828
dependencies = ["camel-converter>=3.0.0"]
2929

3030
[project.optional-dependencies]
3131
pandas = ["pandas>=2.1.0"]
3232
polars = ["polars>=0.17.14"]
3333
all = ["pandas>=2.1.0", "polars>=0.17.14"]
3434

35+
[dependency-groups]
36+
dev = [
37+
"maturin==1.7.4",
38+
"mypy==1.13.0",
39+
"pandas-stubs==2.2.3.241009",
40+
"pytest==8.3.3",
41+
"pytest-cov==6.0.0",
42+
"ruff==0.7.1",
43+
"tomli==2.0.2; python_version<'3.11'",
44+
]
45+
46+
[tool.hatch.version]
47+
path = "prelude_parser/_version.py"
48+
3549
[tool.maturin]
3650
module-name = "prelude_parser._prelude_parser"
3751
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)