mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 12:24:15 +00:00
docs: use python to highlight requirements and use more content tabs (#6549)
## Summary It appears that using `python` for code blocks containing requirements works quite well.   Also using more content tabs for cases where we need to differentiate macOS/Linux from Windows. ## Test Plan Local run of the documentation.
This commit is contained in:
parent
6a988aca55
commit
fd17f6d902
10 changed files with 69 additions and 48 deletions
|
|
@ -154,13 +154,13 @@ other dependencies. uv will always use the latest versions for build dependencie
|
|||
|
||||
For example, given the following `requirements.in` file:
|
||||
|
||||
```text title="requirements.in"
|
||||
```python title="requirements.in"
|
||||
flask>=2.0.0
|
||||
```
|
||||
|
||||
Running `uv pip compile requirements.in` would produce the following `requirements.txt` file:
|
||||
|
||||
```text title="requirements.txt"
|
||||
```python title="requirements.txt"
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in
|
||||
blinker==1.7.0
|
||||
|
|
@ -182,7 +182,7 @@ werkzeug==3.0.1
|
|||
|
||||
However, `uv pip compile --resolution lowest requirements.in` would instead produce:
|
||||
|
||||
```text title="requirements.in"
|
||||
```python title="requirements.in"
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in --resolution lowest
|
||||
click==7.1.2
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ all members.
|
|||
If a `pyproject.toml` file is found, uv will read configuration from the `[tool.uv.pip]` table. For
|
||||
example, to set a persistent index URL, add the following to a `pyproject.toml`:
|
||||
|
||||
```toml title="project.toml"
|
||||
```toml title="pyproject.toml"
|
||||
[tool.uv.pip]
|
||||
index-url = "https://test.pypi.org/simple"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -8,13 +8,17 @@ Install uv with our standalone installers or your package manager of choice.
|
|||
|
||||
uv provides a standalone installer to download and install uv:
|
||||
|
||||
```console title="macOS and Linux"
|
||||
$ curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
```
|
||||
=== "macOS and Linux"
|
||||
|
||||
```console title="Windows"
|
||||
$ powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
```
|
||||
```console
|
||||
$ curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
```
|
||||
|
||||
=== "Windows"
|
||||
|
||||
```console
|
||||
$ powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
```
|
||||
|
||||
By default, uv is installed to `~/.cargo/bin`.
|
||||
|
||||
|
|
@ -22,25 +26,33 @@ By default, uv is installed to `~/.cargo/bin`.
|
|||
|
||||
The installation script may be inspected before use:
|
||||
|
||||
```console title="macOS and Linux"
|
||||
$ curl -LsSf https://astral.sh/uv/install.sh | less
|
||||
```
|
||||
=== "macOS and Linux"
|
||||
|
||||
```console title="Windows"
|
||||
$ powershell -c "irm https://astral.sh/uv/install.ps1 | more"
|
||||
```
|
||||
```console
|
||||
$ curl -LsSf https://astral.sh/uv/install.sh | less
|
||||
```
|
||||
|
||||
=== "Windows"
|
||||
|
||||
```console
|
||||
$ powershell -c "irm https://astral.sh/uv/install.ps1 | more"
|
||||
```
|
||||
|
||||
Alternatively, the installer or binaries can be downloaded directly from [GitHub](#github-releases).
|
||||
|
||||
Request a specific version by including it in the URL:
|
||||
|
||||
```console title="macOS and Linux"
|
||||
$ curl -LsSf https://astral.sh/uv/0.3.4/install.sh | sh
|
||||
```
|
||||
=== "macOS and Linux"
|
||||
|
||||
```console title="Windows"
|
||||
$ powershell -c "irm https://astral.sh/uv/0.3.4/install.ps1 | iex"
|
||||
```
|
||||
```console
|
||||
$ curl -LsSf https://astral.sh/uv/0.3.4/install.sh | sh
|
||||
```
|
||||
|
||||
=== "Windows"
|
||||
|
||||
```console
|
||||
$ powershell -c "irm https://astral.sh/uv/0.3.4/install.ps1 | iex"
|
||||
```
|
||||
|
||||
### PyPI
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
uv installation differs depending on the platform:
|
||||
|
||||
=== "Unix"
|
||||
=== "Linux"
|
||||
|
||||
```yaml title="example.yml"
|
||||
name: Example on Unix
|
||||
name: Example on Linux
|
||||
|
||||
jobs:
|
||||
uv-example-linux:
|
||||
|
|
@ -61,10 +61,10 @@ uv installation differs depending on the platform:
|
|||
|
||||
It is considered best practice to pin to a specific uv version, e.g., with:
|
||||
|
||||
=== "Unix"
|
||||
=== "Linux"
|
||||
|
||||
```yaml title="example.yml"
|
||||
name: Example on Unix
|
||||
name: Example on Linux
|
||||
|
||||
jobs:
|
||||
uv-example-linux:
|
||||
|
|
|
|||
|
|
@ -38,13 +38,17 @@ uv is backed by [Astral](https://astral.sh), the creators of
|
|||
|
||||
Install uv with our official standalone installer:
|
||||
|
||||
```console title="macOS and Linux"
|
||||
$ curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
```
|
||||
=== "macOS and Linux"
|
||||
|
||||
```console title="Windows"
|
||||
$ powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
```
|
||||
```console
|
||||
$ curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
```
|
||||
|
||||
=== "Windows"
|
||||
|
||||
```console
|
||||
$ powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
```
|
||||
|
||||
Then, check out the [first steps](./getting-started/first-steps.md) or read on for a brief overview.
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ _should_ be equally valid.
|
|||
|
||||
For example, consider:
|
||||
|
||||
```text title="requirements.txt"
|
||||
```python title="requirements.in"
|
||||
starlette
|
||||
fastapi
|
||||
```
|
||||
|
|
@ -238,9 +238,9 @@ If a resolver prioritizes including the most recent version of `starlette`, it w
|
|||
older version of `fastapi` that excludes the upper bound on `starlette`. In practice, this requires
|
||||
falling back to `fastapi==0.1.17`:
|
||||
|
||||
```text
|
||||
```python title="requirements.txt"
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile -
|
||||
# uv pip compile requirements.in
|
||||
annotated-types==0.6.0
|
||||
# via pydantic
|
||||
anyio==4.3.0
|
||||
|
|
@ -266,8 +266,9 @@ Alternatively, if a resolver prioritizes including the most recent version of `f
|
|||
need to use an older version of `starlette` that satisfies the upper bound. In practice, this
|
||||
requires falling back to `starlette==0.36.3`:
|
||||
|
||||
```text
|
||||
# uv pip compile -
|
||||
```python title="requirements.txt"
|
||||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.in
|
||||
annotated-types==0.6.0
|
||||
# via pydantic
|
||||
anyio==4.3.0
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ dependencies of the current project.
|
|||
|
||||
To define a constraint, define a bound for a package:
|
||||
|
||||
```text title="constraints.txt"
|
||||
```python title="constraints.txt"
|
||||
pydantic<2.0
|
||||
```
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ then the dependencies cannot be resolved.
|
|||
|
||||
To define an override, define the new requirement for the problematic package:
|
||||
|
||||
```text title="overrides.txt"
|
||||
```python title="overrides.txt"
|
||||
c>=2.0
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ dependencies.
|
|||
|
||||
To define dependencies in a `requirements.in` file:
|
||||
|
||||
```text title="requirements.in"
|
||||
```python title="requirements.in"
|
||||
httpx
|
||||
ruff>=0.3.0
|
||||
```
|
||||
|
|
|
|||
|
|
@ -45,13 +45,17 @@ $ uv pip install ruff
|
|||
|
||||
The virtual environment can be "activated" to make its packages available:
|
||||
|
||||
```console title="macOS and Linux"
|
||||
$ source .venv/bin/activate
|
||||
```
|
||||
=== "macOS and Linux"
|
||||
|
||||
```console title="Windows"
|
||||
$ .venv\Scripts\activate
|
||||
```
|
||||
```console
|
||||
$ source .venv/bin/activate
|
||||
```
|
||||
|
||||
=== "Windows"
|
||||
|
||||
```console
|
||||
$ .venv\Scripts\activate
|
||||
```
|
||||
|
||||
## Using arbitrary Python environments
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ was usually limited to single environment, which one specific architecture, oper
|
|||
version, and Python implementation. Some packages use contradictory requirements for different
|
||||
environments, for example:
|
||||
|
||||
```text
|
||||
```python
|
||||
numpy>=2,<3 ; python_version >= "3.11"
|
||||
numpy>=1.16,<2 ; python_version < "3.11"
|
||||
```
|
||||
|
|
@ -85,7 +85,7 @@ In the above example, the partial solution would be split into two resolutions,
|
|||
If markers overlap or are missing a part of the marker space, the resolver splits additional times —
|
||||
there can be many forks per package. For example, given:
|
||||
|
||||
```text
|
||||
```python
|
||||
flask > 1 ; sys_platform == 'darwin'
|
||||
flask > 2 ; sys_platform == 'win32'
|
||||
flask
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue