|
2 | 2 |
|
3 | 3 | ## Rust |
4 | 4 |
|
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). |
6 | 7 |
|
7 | 8 | ## Environment management |
8 | 9 |
|
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 |
10 | 12 |
|
11 | 13 | ```shell |
12 | | -uv pip install -e ".[test,dev,doc]" |
| 14 | +uv sync |
13 | 15 | ``` |
14 | 16 |
|
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 | +``` |
16 | 21 |
|
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. |
18 | 25 |
|
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`. |
20 | 29 |
|
21 | | -```shell |
22 | | -pytest |
23 | | -``` |
| 30 | +For more information on the `Rust`-`Python` bridge, see the [`PyO3` docs](https://pyo3.rs/v0.22.6/). |
24 | 31 |
|
25 | | -or |
| 32 | +## Testing |
| 33 | + |
| 34 | +To run tests |
26 | 35 |
|
27 | 36 | ```shell |
28 | | -pytest -n auto |
| 37 | +uv run maturin develop |
| 38 | +uv run pytest -n auto |
29 | 39 | ``` |
30 | 40 |
|
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`. |
32 | 44 |
|
33 | 45 | ## Type hints |
34 | 46 |
|
35 | 47 | 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 | +``` |
37 | 53 |
|
38 | 54 | Once `maturin` can be run as a `hatchling` plugin, this can be made automatic. |
39 | 55 |
|
|
0 commit comments