Skip to content

Commit 36b78af

Browse files
KemingHegithub-actions[bot]
authored andcommitted
docs(src/assets/): update uv official documentation
1 parent 122ebe8 commit 36b78af

File tree

28 files changed

+853
-103
lines changed

28 files changed

+853
-103
lines changed

src/assets/uv/_metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"source_repo": "astral-sh/uv",
33
"docs_path": "docs",
4-
"updated_at": "2025-08-26T22:05:11Z",
5-
"commit_sha": "9eb5fc240ca28d8222f1be6d62379fd795e2f09e"
4+
"updated_at": "2025-09-02T22:05:05Z",
5+
"commit_sha": "f9e98d1fb6bf2b1350f60d5bf401f7038da2d3e8"
66
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# TLS certificates
2+
3+
By default, uv loads certificates from the bundled `webpki-roots` crate. The `webpki-roots` are a
4+
reliable set of trust roots from Mozilla, and including them in uv improves portability and
5+
performance (especially on macOS, where reading the system trust store incurs a significant delay).
6+
7+
## System certificates
8+
9+
In some cases, you may want to use the platform's native certificate store, especially if you're
10+
relying on a corporate trust root (e.g., for a mandatory proxy) that's included in your system's
11+
certificate store. To instruct uv to use the system's trust store, run uv with the `--native-tls`
12+
command-line flag, or set the `UV_NATIVE_TLS` environment variable to `true`.
13+
14+
## Custom certificates
15+
16+
If a direct path to the certificate is required (e.g., in CI), set the `SSL_CERT_FILE` environment
17+
variable to the path of the certificate bundle, to instruct uv to use that file instead of the
18+
system's trust store.
19+
20+
If client certificate authentication (mTLS) is desired, set the `SSL_CLIENT_CERT` environment
21+
variable to the path of the PEM formatted file containing the certificate followed by the private
22+
key.
23+
24+
## Insecure hosts
25+
26+
If you're using a setup in which you want to trust a self-signed certificate or otherwise disable
27+
certificate verification, you can instruct uv to allow insecure connections to dedicated hosts via
28+
the `allow-insecure-host` configuration option. For example, adding the following to
29+
`pyproject.toml` will allow insecure connections to `example.com`:
30+
31+
```toml
32+
[tool.uv]
33+
allow-insecure-host = ["example.com"]
34+
```
35+
36+
`allow-insecure-host` expects to receive a hostname (e.g., `localhost`) or hostname-port pair (e.g.,
37+
`localhost:8080`), and is only applicable to HTTPS connections, as HTTP connections are inherently
38+
insecure.
39+
40+
Use `allow-insecure-host` with caution and only in trusted environments, as it can expose you to
41+
security risks due to the lack of certificate verification.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# The `uv auth` CLI
2+
3+
uv provides a high-level interface for storing and retrieving credentials from services.
4+
5+
## Logging in to a service
6+
7+
To add credentials for service, use the `uv auth login` command:
8+
9+
```console
10+
$ uv auth login example.com
11+
```
12+
13+
This will prompt for the credentials.
14+
15+
The credentials can also be provided using the `--username` and `--password` options, or the
16+
`--token` option for services which use a `__token__` or arbitrary username.
17+
18+
!!! note
19+
20+
We recommend providing the secret via stdin. Use `-` to indicate the value should be read from
21+
stdin, e.g., for `--password`:
22+
23+
```console
24+
$ echo 'my-password' | uv auth login example.com --password -
25+
```
26+
27+
The same pattern can be used with `--token`.
28+
29+
Once credentials are added, uv will use them for packaging operations that require fetching content
30+
from the given service. At this time, only HTTPS Basic authentication is supported. The credentials
31+
will not yet be used for Git requests.
32+
33+
!!! note
34+
35+
The credentials will not be validated, i.e., incorrect credentials will not fail.
36+
37+
## Logging out of a service
38+
39+
To remove credentials, use the `uv auth logout` command:
40+
41+
```console
42+
$ uv auth logout example.com
43+
```
44+
45+
!!! note
46+
47+
The credentials will not be invalidated with the remote server, i.e., they will only be removed
48+
from local storage not rendered unusable.
49+
50+
## Showing credentials for a service
51+
52+
To show the credential stored for a given URL, use the `uv auth token` command:
53+
54+
```console
55+
$ uv auth token example.com
56+
```
57+
58+
If a username was used to log in, it will need to be provided as well, e.g.:
59+
60+
```console
61+
$ uv auth token --username foo example.com
62+
```
63+
64+
## Configuring the storage backend
65+
66+
Credentials are persisted to the uv [credentials store](./http.md#the-uv-credentials-store).
67+
68+
By default, credentials are written to a plaintext file. An encrypted system-native storage backend
69+
can be enabled with `UV_PREVIEW_FEATURES=native-auth`.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Git credentials
2+
3+
uv allows packages to be installed from private Git repositories using SSH or HTTP authentication.
4+
5+
## SSH authentication
6+
7+
To authenticate using an SSH key, use the `ssh://` protocol:
8+
9+
- `git+ssh://git@<hostname>/...` (e.g., `git+ssh://git@github.com/astral-sh/uv`)
10+
- `git+ssh://git@<host>/...` (e.g., `git+ssh://git@github.com-key-2/astral-sh/uv`)
11+
12+
SSH authentication requires using the username `git`.
13+
14+
See the
15+
[GitHub SSH documentation](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh)
16+
for more details on how to configure SSH.
17+
18+
### HTTP authentication
19+
20+
To authenticate over HTTP Basic authentication using a password or token:
21+
22+
- `git+https://<user>:<token>@<hostname>/...` (e.g.,
23+
`git+https://git:github_pat_asdf@github.com/astral-sh/uv`)
24+
- `git+https://<token>@<hostname>/...` (e.g., `git+https://github_pat_asdf@github.com/astral-sh/uv`)
25+
- `git+https://<user>@<hostname>/...` (e.g., `git+https://git@github.com/astral-sh/uv`)
26+
27+
!!! note
28+
29+
When using a GitHub personal access token, the username is arbitrary. GitHub doesn't allow you to
30+
use your account name and password in URLs like this, although other hosts may.
31+
32+
If there are no credentials present in the URL and authentication is needed, the
33+
[Git credential helper](#git-credential-helpers) will be queried.
34+
35+
## Persistence of credentials
36+
37+
When using `uv add`, uv _will not_ persist Git credentials to the `pyproject.toml` or `uv.lock`.
38+
These files are often included in source control and distributions, so it is generally unsafe to
39+
include credentials in them.
40+
41+
If you have a Git credential helper configured, your credentials may be automatically persisted,
42+
resulting in successful subsequent fetches of the dependency. However, if you do not have a Git
43+
credential helper or the project is used on a machine without credentials seeded, uv will fail to
44+
fetch the dependency.
45+
46+
You _may_ force uv to persist Git credentials by passing the `--raw` option to `uv add`. However, we
47+
strongly recommend setting up a [credential helper](#git-credential-helpers) instead.
48+
49+
## Git credential helpers
50+
51+
Git credential helpers are used to store and retrieve Git credentials. See the
52+
[Git documentation](https://git-scm.com/doc/credential-helpers) to learn more.
53+
54+
If you're using GitHub, the simplest way to set up a credential helper is to
55+
[install the `gh` CLI](https://github.com/cli/cli#installation) and use:
56+
57+
```console
58+
$ gh auth login
59+
```
60+
61+
See the [`gh auth login`](https://cli.github.com/manual/gh_auth_login) documentation for more
62+
details.
63+
64+
!!! note
65+
66+
When using `gh auth login` interactively, the credential helper will be configured automatically.
67+
But when using `gh auth login --with-token`, as in the uv
68+
[GitHub Actions guide](../../guides/integration/github.md#private-repos), the
69+
[`gh auth setup-git`](https://cli.github.com/manual/gh_auth_setup-git) command will need to be
70+
run afterwards to configure the credential helper.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# HTTP credentials
2+
3+
uv supports credentials over HTTP when querying package registries.
4+
5+
Authentication can come from the following sources, in order of precedence:
6+
7+
- The URL, e.g., `https://<user>:<password>@<hostname>/...`
8+
- A [netrc](#netrc-files) configuration file
9+
- The uv credentials store
10+
- A [keyring provider](#keyring-providers) (off by default)
11+
12+
Authentication may be used for hosts specified in the following contexts:
13+
14+
- `[index]`
15+
- `index-url`
16+
- `extra-index-url`
17+
- `find-links`
18+
- `package @ https://...`
19+
20+
## netrc files
21+
22+
[`.netrc`](https://everything.curl.dev/usingcurl/netrc) files are a long-standing plain text format
23+
for storing credentials on a system.
24+
25+
Reading credentials from `.netrc` files is always enabled. The target file path will be loaded from
26+
the `NETRC` environment variable if defined, falling back to `~/.netrc` if not.
27+
28+
## The uv credentials store
29+
30+
uv can read and write credentials from a store using the [`uv auth` commands](./cli.md).
31+
32+
Credentials are stored in a plaintext file in uv's state directory, e.g.,
33+
`~/.local/share/uv/credentials/credentials.toml` on Unix. This file is currently not intended to be
34+
edited manually.
35+
36+
!!! note
37+
38+
A secure, system native storage mechanism is in [preview](../preview.md) — it is still
39+
experimental and being actively developed. In the future, this will become the default storage
40+
mechanism.
41+
42+
When enabled, uv will use the secret storage mechanism native to your operating system. On
43+
macOS, it uses the Keychain Services. On Windows, it uses the Windows Credential Manager. On
44+
Linux, it uses the DBus-based Secret Service API.
45+
46+
Currently, uv only searches the native store for credentials it has added to the secret store —
47+
it will not retrieve credentials persisted by other applications.
48+
49+
Set `UV_PREVIEW_FEATURES=native-auth` to use this storage mechanism.
50+
51+
## Keyring providers
52+
53+
A keyring provider is a concept from `pip` allowing retrieval of credentials from an interface
54+
matching the popular [keyring](https://github.com/jaraco/keyring) Python package.
55+
56+
The "subprocess" keyring provider invokes the `keyring` command to fetch credentials. uv does not
57+
support additional keyring provider types at this time.
58+
59+
Set `--keyring-provider subprocess`, `UV_KEYRING_PROVIDER=subprocess`, or
60+
`tool.uv.keyring-provider = "subprocess"` to use the provider.
61+
62+
## Persistence of credentials
63+
64+
If authentication is found for a single index URL or net location (scheme, host, and port), it will
65+
be cached for the duration of the command and used for other queries to that index or net location.
66+
Authentication is not cached across invocations of uv.
67+
68+
When using `uv add`, uv _will not_ persist index credentials to the `pyproject.toml` or `uv.lock`.
69+
These files are often included in source control and distributions, so it is generally unsafe to
70+
include credentials in them. However, uv _will_ persist credentials for direct URLs, i.e.,
71+
`package @ https://username:password:example.com/foo.whl`, as there is not currently a way to
72+
otherwise provide those credentials.
73+
74+
If credentials were attached to an index URL during `uv add`, uv may fail to fetch dependencies from
75+
indexes which require authentication on subsequent operations. See the
76+
[index authentication documentation](../indexes.md#authentication) for details on persistent
77+
authentication for indexes.
78+
79+
## Learn more
80+
81+
See the [index authentication documentation](../indexes.md#authentication) for details on
82+
authenticating index URLs.
83+
84+
See the [`pip` compatibility guide](../../pip/compatibility.md#registry-authentication) for details
85+
on differences from `pip`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Authentication
2+
3+
Authentication is required when working with private repositories or package indexes.
4+
5+
Learn more about authentication in uv:
6+
7+
- [Using the `uv auth` CLI](./cli.md)
8+
- [HTTP authentication](./http.md)
9+
- [Git authentication](./git.md)
10+
- [TLS certificates](./certificates.md)
11+
- [Third-party services](./third-party.md)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Third-party services
2+
3+
## Authentication with alternative package indexes
4+
5+
See the [alternative indexes integration guide](../../guides/integration/alternative-indexes.md) for
6+
details on authentication with popular alternative Python package indexes.
7+
8+
## Hugging Face support
9+
10+
uv supports automatic authentication for the Hugging Face Hub. Specifically, if the `HF_TOKEN`
11+
environment variable is set, uv will propagate it to requests to `huggingface.co`.
12+
13+
This is particularly useful for accessing private scripts in Hugging Face Datasets. For example, you
14+
can run the following command to execute the script `main.py` script from a private dataset:
15+
16+
```console
17+
$ HF_TOKEN=hf_... uv run https://huggingface.co/datasets/<user>/<name>/resolve/<branch>/main.py
18+
```
19+
20+
You can disable automatic Hugging Face authentication by setting the `UV_NO_HF_TOKEN=1` environment
21+
variable.

src/assets/uv/concepts/build-backend.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To use uv as a build backend in an existing project, add `uv_build` to the
3131

3232
```toml title="pyproject.toml"
3333
[build-system]
34-
requires = ["uv_build>=0.8.13,<0.9.0"]
34+
requires = ["uv_build>=0.8.14,<0.9.0"]
3535
build-backend = "uv_build"
3636
```
3737

@@ -237,6 +237,13 @@ must either be under the module root or in the appropriate
237237
[data directory](../reference/settings.md#build-backend_data). Most packages store small data in the
238238
module root alongside the source code.
239239

240+
!!! tip
241+
242+
When using the uv build backend through a frontend that is not uv, such as pip or
243+
`python -m build`, debug logging can be enabled through environment variables with
244+
`RUST_LOG=uv=debug` or `RUST_LOG=uv=verbose`. When used through uv, the uv build backend shares
245+
the verbosity level of uv.
246+
240247
### Include and exclude syntax
241248

242249
Includes are anchored, which means that `pyproject.toml` includes only `<root>/pyproject.toml` and

src/assets/uv/concepts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Read the concept documents to learn more about uv's features:
99
- [Package indexes](./indexes.md)
1010
- [Resolution](./resolution.md)
1111
- [The uv build backend](./build-backend.md)
12-
- [Authentication](./authentication.md)
12+
- [Authentication](./authentication/index.md)
1313
- [Caching](./cache.md)
1414
- [The pip interface](../pip/index.md)
1515

src/assets/uv/concepts/indexes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ access to the authenticated URL at installation time.
184184
### Using credential providers
185185

186186
In addition to providing credentials directly, uv supports discovery of credentials from netrc and
187-
keyring. See the [HTTP authentication](./authentication.md#http-authentication) documentation for
188-
details on setting up specific credential providers.
187+
keyring. See the [HTTP authentication](./authentication/http.md) documentation for details on
188+
setting up specific credential providers.
189189

190190
By default, uv will attempt an unauthenticated request before querying providers. If the request
191191
fails, uv will search for credentials. If credentials are found, an authenticated request will be

0 commit comments

Comments
 (0)