Skip to content

Commit

Permalink
Merge pull request #430 from pbs-data-solutions/uv
Browse files Browse the repository at this point in the history
Switch from setuptools to uv
  • Loading branch information
sanders41 authored Nov 2, 2024
2 parents b60af4f + 8447158 commit 18fefa0
Show file tree
Hide file tree
Showing 9 changed files with 570 additions and 31 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ jobs:
- uses: actions/checkout@v4
- name: install Just
uses: taiki-e/install-action@just
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
- name: Install dependencies
run: |
pip install -U pip
pip install -r requirements-dev.txt
pip install -e .[all]
maturin build --out dist
pip install --no-index --find-links=dist/ prelude-parser
uv sync --frozen --all-extras
uv run maturin build
- name: mypy check
run: just mypy
test:
Expand All @@ -63,20 +63,20 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
pip install -U pip
pip install -r requirements-dev.txt
pip install -e .[all]
maturin build --out dist
pip install --no-index --find-links=dist/ prelude-parser
uv sync --frozen --all-extras
uv run maturin build
- name: Run tests
run: pytest --cov=prelude_parser --cov-report=xml
run: uv run pytest --cov=prelude_parser --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
Expand Down
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ Please include:

## Working on the code

In order to work on this project you will need to have [Rust](https://www.rust-lang.org/) and
Note: This project uses uv to manage dependencies. If you do not already have uv installed you will
need to install it with the instructions [here](https://docs.astral.sh/uv/getting-started/installation/)

In order to work on this project you will need to have [Rust](https://www.rust-lang.org/),
[uv](https://docs.astral.sh/uv/getting-started/installation/), and
[just](https://github.com/casey/just) in addition to Python.

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

```sh
python -m venv .venv
uv venv

. .venv/bin/activate
```
Expand Down
24 changes: 16 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
just --list

@develop:
maturin develop -E all
uv run maturin develop -E all

@install: && develop
pip install -r requirements-dev.txt
uv sync --frozen --all-extras

@lock:
uv lock

@lint:
echo cargo check
Expand All @@ -14,8 +17,10 @@
just --justfile {{justfile()}} clippy
echo cargo fmt
just --justfile {{justfile()}} fmt
echo ruff
just --justfile {{justfile()}} ruff
echo ruff-check
just --justfile {{justfile()}} ruff-check
echo ruff-format
just --justfile {{justfile()}} ruff-format
echo mypy
just --justfile {{justfile()}} mypy

Expand All @@ -29,10 +34,13 @@
cargo fmt

@mypy:
mypy prelude_parser tests
uv run mypy prelude_parser tests

@ruff-check:
uv run ruff check prelude_parser tests

@ruff:
ruff check . --fix
@ruff-format:
uv run ruff format prelude_parser tests

@test *args="":
pytest {{args}}
uv run pytest {{args}}
3 changes: 3 additions & 0 deletions prelude_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
parse_user_native_file,
parse_user_native_string,
)
from prelude_parser._version import VERSION
from prelude_parser.parser import parse_to_classes, parse_to_dict

__version__ = VERSION

__all__ = [
"parse_site_native_file",
"parse_site_native_string",
Expand Down
1 change: 1 addition & 0 deletions prelude_parser/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = "0.11.2"
18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ build-backend = "maturin"

[project]
name = "prelude-parser"
requires-python = ">=3.9"
requires-python = ">=3.10"
description = "Parses XML files exported from Prelude EDC into formats usable by Python."
authors = [{name = "Paul Sanders", email = "paul@pbsdatasolutions.com"}]
keywords = ["parser", "prelude-edc", "xml", "pandas", "polars"]
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -25,13 +24,28 @@ readme = "README.md"
repository = "https://github.com/pbs-data-solutions/prelude-parser"
homepage = "https://github.com/pbs-data-solutions/prelude-parser"
documentation = "https://github.com/pbs-data-solutions/prelude-parser"
dynamic = ["version"]
dependencies = ["camel-converter>=3.0.0"]

[project.optional-dependencies]
pandas = ["pandas>=2.1.0"]
polars = ["polars>=0.17.14"]
all = ["pandas>=2.1.0", "polars>=0.17.14"]

[dependency-groups]
dev = [
"maturin==1.7.4",
"mypy==1.13.0",
"pandas-stubs==2.2.3.241009",
"pytest==8.3.3",
"pytest-cov==6.0.0",
"ruff==0.7.1",
"tomli==2.0.2; python_version<'3.11'",
]

[tool.hatch.version]
path = "prelude_parser/_version.py"

[tool.maturin]
module-name = "prelude_parser._prelude_parser"
binding = "pyo3"
Expand Down
6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

18 changes: 18 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys
from pathlib import Path

from prelude_parser import __version__

if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib


def test_versions_match():
pyproject = Path().absolute() / "Cargo.toml"
with open(pyproject, "rb") as f:
data = tomllib.load(f)
cargo_version = data["package"]["version"]

assert __version__ == cargo_version
Loading

0 comments on commit 18fefa0

Please sign in to comment.