2023-11-02 12:03:56 +01:00
# Contributing
2024-02-27 13:49:49 +01:00
We have issues labeled as [Good First Issue ](https://github.com/astral-sh/uv/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 ) and [Help Wanted ](https://github.com/astral-sh/uv/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22 ) which are good opportunities for new contributors.
2024-01-24 18:03:55 +01:00
## Setup
2024-02-15 11:19:46 -06:00
[Rust ](https://rustup.rs/ ), a C compiler, and CMake are required to build uv.
2024-01-24 18:03:55 +01:00
### Linux
2024-04-17 13:24:41 -04:00
On Ubuntu and other Debian-based distributions, you can install the C compiler and CMake with:
2024-01-24 18:03:55 +01:00
``` shell
sudo apt install build-essential cmake
```
2024-01-26 12:12:48 -06:00
### macOS
2024-04-17 13:24:41 -04:00
You can install CMake with Homebrew:
2024-01-26 12:12:48 -06:00
2024-02-18 19:32:37 +01:00
``` shell
2024-01-26 12:12:48 -06:00
brew install cmake
```
See the [Python ](#python ) section for instructions on installing the Python versions.
2024-01-24 18:03:55 +01:00
### Windows
2024-04-17 13:24:41 -04:00
You can install CMake from the [installers ](https://cmake.org/download/ ) or with `pipx install cmake` .
2024-01-24 18:03:55 +01:00
2024-02-08 16:09:55 -05:00
## Testing
2024-01-26 12:12:48 -06:00
2024-02-16 08:24:29 -06:00
For running tests, we recommend [nextest ](https://nexte.st/ ).
2024-04-17 13:24:41 -04:00
If tests fail due to a mismatch in the JSON Schema, run: `cargo dev generate-json-schema` .
2024-02-16 08:24:29 -06:00
### Python
2024-02-18 19:32:37 +01:00
2024-05-26 23:54:49 -04:00
Testing uv requires multiple specific Python versions; they can be installed with:
2024-01-26 12:12:48 -06:00
2024-02-08 16:09:55 -05:00
``` shell
2024-06-17 14:49:06 -04:00
cargo run toolchain install
2024-01-26 12:12:48 -06:00
```
2024-07-03 08:44:29 -04:00
The storage directory can be configured with `UV_PYTHON_INSTALL_DIR` .
2024-02-21 13:46:23 +01:00
2024-02-18 18:17:57 -08:00
### Local testing
You can invoke your development version of uv with `cargo run -- <args>` . For example:
``` shell
cargo run -- venv
cargo run -- pip install requests
```
2024-05-21 04:40:22 -04:00
### Testing on Windows
When testing debug builds on Windows, the stack can overflow resulting in a `STATUS_STACK_OVERFLOW` error code.
This is due to a small stack size limit on Windows that we encounter when running unoptimized builds — the release
builds do not have this problem. We [added a `UV_STACK_SIZE` variable ](https://github.com/astral-sh/uv/pull/941 ) to
bypass this problem during testing. We recommend bumping the stack size from the default of 1MB to 2MB, for example:
``` powershell
$Env:UV_STACK_SIZE = '2000000'
```
## Running inside a Docker container
2023-11-02 12:03:56 +01:00
2024-02-18 19:32:37 +01:00
Source distributions can run arbitrary code on build and can make unwanted modifications to your system (["Someone's Been Messing With My Subnormals!" on Blogspot ](https://moyix.blogspot.com/2022/09/someones-been-messing-with-my-subnormals.html ), ["nvidia-pyindex" on PyPI ](https://pypi.org/project/nvidia-pyindex/ )), which can even occur when just resolving requirements. To prevent this, there's a Docker container you can run commands in:
2023-11-02 12:03:56 +01:00
``` bash
2024-02-15 11:19:46 -06:00
docker buildx build -t uv-builder -f builder.dockerfile --load .
2023-11-02 12:03:56 +01:00
# Build for musl to avoid glibc errors, might not be required with your OS version
2024-05-30 15:28:48 -04:00
cargo build --target x86_64-unknown-linux-musl --profile profiling
2024-02-15 11:19:46 -06:00
docker run --rm -it -v $( pwd ) :/app uv-builder /app/target/x86_64-unknown-linux-musl/profiling/uv-dev resolve-many --cache-dir /app/cache-docker /app/scripts/popular_packages/pypi_10k_most_dependents.txt
2023-11-02 12:03:56 +01:00
```
2024-02-16 08:24:29 -06:00
We recommend using this container if you don't trust the dependency tree of the package(s) you are trying to resolve or install.
2024-02-04 22:57:16 +01:00
2024-02-27 13:49:49 +01:00
## Profiling and Benchmarking
2024-02-04 22:57:16 +01:00
2024-02-15 11:19:46 -06:00
Please refer to Ruff's [Profiling Guide ](https://github.com/astral-sh/ruff/blob/main/CONTRIBUTING.md#profiling-projects ), it applies to uv, too.
2024-02-04 22:57:16 +01:00
2024-02-27 13:49:49 +01:00
We provide diverse sets of requirements for testing and benchmarking the resolver in `scripts/requirements` and for the installer in `scripts/requirements/compiled` .
You can use `scripts/bench` to benchmark predefined workloads between uv versions and with other tools, e.g.
```
python -m scripts.bench \
--uv-path ./target/release/before \
--uv-path ./target/release/after \
./scripts/requirements/jupyter.in --benchmark resolve-cold --min-runs 20
```
2024-04-17 13:24:41 -04:00
### Analyzing concurrency
2024-02-04 22:57:16 +01:00
2024-02-15 11:19:46 -06:00
You can use [tracing-durations-export ](https://github.com/konstin/tracing-durations-export ) to visualize parallel requests and find any spots where uv is CPU-bound. Example usage, with `uv` and `uv-dev` respectively:
2024-02-04 22:57:16 +01:00
2024-02-18 19:32:37 +01:00
``` shell
2024-02-15 11:19:46 -06:00
RUST_LOG = uv = info TRACING_DURATIONS_FILE = target/traces/jupyter.ndjson cargo run --features tracing-durations-export --profile profiling -- pip compile scripts/requirements/jupyter.in
2024-02-04 22:57:16 +01:00
```
2024-02-18 19:32:37 +01:00
``` shell
2024-02-15 11:19:46 -06:00
RUST_LOG = uv = info TRACING_DURATIONS_FILE = target/traces/jupyter.ndjson cargo run --features tracing-durations-export --bin uv-dev --profile profiling -- resolve jupyter
2024-02-04 22:57:16 +01:00
```
2024-02-18 16:21:32 -08:00
### Trace-level logging
You can enable `trace` level logging using the `RUST_LOG` environment variable, i.e.
``` shell
2024-04-17 13:24:41 -04:00
RUST_LOG = trace uv
2024-02-18 16:21:32 -08:00
```
2024-02-22 16:00:13 -06:00
## Releases
Releases can only be performed by Astral team members.
Changelog entries and version bumps are automated. First, run:
```
2024-04-02 18:25:27 -05:00
./scripts/release.sh
2024-02-22 16:00:13 -06:00
```
Then, editorialize the `CHANGELOG.md` file to ensure entries are consistently styled.
Then, open a pull request e.g. `Bump version to ...` .
2024-02-27 13:49:49 +01:00
Binary builds will automatically be tested for the release.
2024-02-22 16:00:13 -06:00
After merging the pull request, run the [release workflow ](https://github.com/astral-sh/uv/actions/workflows/release.yml )
2024-02-27 13:49:49 +01:00
with the version tag. **Do not include a leading `v` ** .
The release will automatically be created on GitHub after everything else publishes.