Skip to content

Commit 6de82aa

Browse files
authored
chore: cleanup Python dependencies and use [dependency-groups] (#101)
and update `contributing.md`
1 parent 82b0b83 commit 6de82aa

File tree

3 files changed

+44
-40
lines changed

3 files changed

+44
-40
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ jobs:
4141
python-version: "3.x"
4242

4343
- name: Install UV
44-
uses: astral-sh/setup-uv@v3
44+
uses: astral-sh/setup-uv@v6
4545
with:
46-
version: "0.5.0"
46+
version: "0.7.19"
4747
enable-cache: true
4848
cache-dependency-glob: |
4949
pyproject.toml
5050
Cargo.toml
5151
5252
- name: Install python deps + Build
5353
run: |
54-
uv pip install --system -e ".[test,dev]" --verbose
54+
uv pip install --system -e . --group dev --verbose
5555
5656
- name: Python Tests
5757
run: pytest -n auto

docs/contributing.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,54 @@
22

33
## Rust
44

5-
You will need `rust` and `cargo` installed on your local system. For more info, see [the rust docs](https://doc.rust-lang.org/cargo/getting-started/installation.html).
5+
You will need `Rust` and `cargo` installed on your local system.
6+
For more info, see [the Rust docs](https://doc.rust-lang.org/cargo/getting-started/installation.html).
67

78
## Environment management
89

9-
We encourage the use of [uv](https://docs.astral.sh/uv/) for environment management. To install the package for development, run
10+
We encourage the use of [`uv`](https://docs.astral.sh/uv/) for environment management.
11+
To create a virtual environment for development with all `dev` dependencies, run
1012

1113
```shell
12-
uv pip install -e ".[test,dev,doc]"
14+
uv sync
1315
```
1416

15-
However, take note that while this does build the rust package, the rust package will not be rebuilt upon edits despite the `-e` flag. You will need to manually rebuild it using either `uv pip install -e .` or `maturin develop`. Take note that for benchmarking/speed testing, it is advisable to build a release version of the rust package by passing the `-r` flag to `maturin`. For more information on the `rust`-`python` bridge, see the [`PyO3` docs](https://pyo3.rs/v0.22.6/).
17+
If you prefer not to use `uv`, simply create and activate a virtual environment, then run:
18+
```shell
19+
pip install --group dev -e .
20+
```
1621

17-
## Testing
22+
> [!NOTE]
23+
> The rest of this document assumes you are using `uv`.
24+
> If you are not using `uv`, just remove the `uv run` preceeding commands.
1825
19-
To install test dependencies, simply run
26+
> [!WARNING]
27+
> The above commands initially build the `Rust` package, but it will not be rebuilt upon edits.
28+
> You will need to manually rebuild it using `uv run maturin develop`.
2029
21-
```shell
22-
pytest
23-
```
30+
For more information on the `Rust`-`Python` bridge, see the [`PyO3` docs](https://pyo3.rs/v0.22.6/).
2431

25-
or
32+
## Testing
33+
34+
To run tests
2635

2736
```shell
28-
pytest -n auto
37+
uv run maturin develop
38+
uv run pytest -n auto
2939
```
3040

31-
for parallelized tests. Most tests have been copied from the `zarr-python` repository with the exception of `test_pipeline.py` which we have written.
41+
Most tests have been copied from the `zarr-python` repository with the exception of `test_pipeline.py` which we have written.
42+
43+
For benchmarking/speed testing, it is advisable to build a release version of the `Rust` package by passing the `-r` flag to `maturin`.
3244

3345
## Type hints
3446

3547
Thanks to [`pyo3-stub-gen`][], we can generate type stubs for the `zarrs._internal` module.
36-
If the “Check formatting” CI step fails, run `cargo run --bin stub_gen`, then `pre-commit run --all-files`, and commit the changes.
48+
If the “Check formatting” CI step fails, run the following and commit the changes:
49+
```shell
50+
cargo run --bin stub_gen
51+
uv run pre-commit run --all-files
52+
```
3753

3854
Once `maturin` can be run as a `hatchling` plugin, this can be made automatic.
3955

pyproject.toml

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,27 @@ classifiers = [
1919
]
2020
dynamic = ["version"]
2121
dependencies = [
22-
'asciitree',
23-
'numpy>=1.24',
24-
'fasteners',
25-
'numcodecs[msgpack]>=0.10.0',
26-
'fsspec>2024',
27-
'crc32c',
28-
'zstandard',
29-
'typing_extensions',
30-
'donfig',
31-
'pytest',
32-
'universal_pathlib>=0.2.0',
22+
"numpy>=1.24",
3323
"zarr>=3.0.3,<3.1",
3424
]
3525

36-
[project.optional-dependencies]
26+
[dependency-groups]
3727
test = [
38-
"coverage",
28+
"aiohttp",
29+
"fsspec>2024",
30+
"numcodecs>=0.16.1",
3931
"pytest",
40-
"pytest-cov",
41-
"msgpack",
42-
"lmdb",
43-
"s3fs",
4432
"pytest-asyncio",
45-
"moto[s3]",
46-
"flask-cors",
47-
"flask",
48-
"requests",
49-
"mypy",
50-
"hypothesis",
5133
"pytest-xdist",
5234
]
53-
dev = ["maturin", "pip", "pre-commit"]
5435
doc = ["sphinx>=7.4.6", "myst-parser"]
36+
dev = [
37+
"maturin",
38+
"pip",
39+
"pre-commit",
40+
{include-group = "test"},
41+
{include-group = "doc"},
42+
]
5543

5644
[tool.maturin]
5745
python-source = "python"

0 commit comments

Comments
 (0)