Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on platform-specific dependencies #7411

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion docs/concepts/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def hello() -> None:

And the `pyproject.toml` includes a script entrypoint:

```python title="pyproject.toml" hl_lines="9 10"
```toml title="pyproject.toml" hl_lines="9 10"
[project]
name = "example-packaged-app"
version = "0.1.0"
Expand Down Expand Up @@ -486,6 +486,38 @@ To add a dependency source, e.g., to use `httpx` from GitHub during development:
$ uv add git+https://github.com/encode/httpx
```

### Platform-specific dependencies

To ensure that a dependency is only installed on a specific platform or on specific Python versions,
use Python's standardized
[environment markers](https://peps.python.org/pep-0508/#environment-markers) syntax.

For example, to install `jax` on Linux, but not on Windows or macOS:

```console
$ uv add 'jax; sys_platform == "linux"'
```

The resulting `pyproject.toml` will then include the environment marker in the dependency
definition:

```toml title="pyproject.toml" hl_lines="6"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = ["jax; sys_platform == 'linux'"]
```

Similarly, to include `numpy` on Python 3.11 and later:

```console
$ uv add 'numpy; python_version >= "3.11"'
```

See Python's [environment marker](https://peps.python.org/pep-0508/#environment-markers)
documentation for a complete enumeration of the available markers and operators.

## Running commands

When working on a project, it is installed into virtual environment at `.venv`. This environment is
Expand Down
Loading