Files
uv/mkdocs.template.yml
Charlie Marsh 5b391770df Add support for named and explicit indexes (#7481)
## Summary

This PR adds a first-class API for defining registry indexes, beyond our
existing `--index-url` and `--extra-index-url` setup.

Specifically, you now define indexes like so in a `uv.toml` or
`pyproject.toml` file:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
```

You can also provide indexes via `--index` and `UV_INDEX`, and override
the default index with `--default-index` and `UV_DEFAULT_INDEX`.

### Index priority

Indexes are prioritized in the order in which they're defined, such that
the first-defined index has highest priority.

Indexes are also inherited from parent configuration (e.g., the
user-level `uv.toml`), but are placed after any indexes in the current
project, matching our semantics for other array-based configuration
values.

You can mix `--index` and `--default-index` with the legacy
`--index-url` and `--extra-index-url` settings; the latter two are
merely treated as unnamed `[[tool.uv.index]]` entries.

### Index pinning

If an index includes a name (which is optional), it can then be
referenced via `tool.uv.sources`:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"

[tool.uv.sources]
torch = { index = "pytorch" }
```

If an index is marked as `explicit = true`, it can _only_ be used via
such references, and will never be searched implicitly:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
explicit = true

[tool.uv.sources]
torch = { index = "pytorch" }
```

Indexes defined outside of the current project (e.g., in the user-level
`uv.toml`) can _not_ be explicitly selected.

(As of now, we only support using a single index for a given
`tool.uv.sources` definition.)

### Default index

By default, we include PyPI as the default index. This remains true even
if the user defines a `[[tool.uv.index]]` -- PyPI is still used as a
fallback. You can mark an index as `default = true` to (1) disable the
use of PyPI, and (2) bump it to the bottom of the prioritized list, such
that it's used only if a package does not exist on a prior index:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"
default = true
```

### Name reuse

If a name is reused, the higher-priority index with that name is used,
while the lower-priority indexes are ignored entirely.

For example, given:

```toml
[[tool.uv.index]]
name = "pytorch"
url = "https://download.pytorch.org/whl/cu121"

[[tool.uv.index]]
name = "pytorch"
url = "https://test.pypi.org/simple"
```

The `https://test.pypi.org/simple` index would be ignored entirely,
since it's lower-priority than `https://download.pytorch.org/whl/cu121`
but shares the same name.

Closes #171.

## Future work

- Users should be able to provide authentication for named indexes via
environment variables.
- `uv add` should automatically write `--index` entries to the
`pyproject.toml` file.
- Users should be able to provide multiple indexes for a given package,
stratified by platform:
```toml
[tool.uv.sources]
torch = [
  { index = "cpu", markers = "sys_platform == 'darwin'" },
  { index = "gpu", markers = "sys_platform != 'darwin'" },
]
```
- Users should be able to specify a proxy URL for a given index, to
avoid writing user-specific URLs to a lockfile:
```toml
[[tool.uv.index]]
name = "test"
url = "https://private.org/simple"
proxy = "http://<omitted>/pypi/simple"
```
2024-10-15 18:24:23 -04:00

140 lines
4.4 KiB
YAML

site_name: uv
theme:
name: material
logo: assets/logo-letter.svg
favicon: assets/favicon.ico
features:
- navigation.instant
- navigation.instant.prefetch
- navigation.instant.progress
- navigation.sections
- navigation.indexes
- navigation.tracking
- content.code.annotate
- toc.follow
- navigation.footer
- navigation.top
- content.code.copy
- content.tabs.link
palette:
# Note: Using the system theme works with the insiders version
# https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#automatic-light-dark-mode
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
- media: "(prefers-color-scheme: light)"
scheme: astral-light
toggle:
icon: material/brightness-7
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: astral-dark
toggle:
icon: material/brightness-4
name: Switch to system preference
custom_dir: docs/.overrides
repo_url: https://github.com/astral-sh/uv
repo_name: uv
site_author: charliermarsh
site_url: https://docs.astral.sh/uv/
site_dir: site/uv
markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.snippets:
- pymdownx.magiclink:
- attr_list:
- toc:
anchorlink: true
anchorlink_class: "toclink"
- md_in_html:
- pymdownx.inlinehilite:
- pymdownx.superfences:
- markdown.extensions.attr_list:
- pymdownx.keys:
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.tabbed:
alternate_style: true
plugins:
- search
extra_css:
- stylesheets/extra.css
extra_javascript:
- js/extra.js
extra:
analytics:
provider: fathom
social:
- icon: fontawesome/brands/github
link: https://github.com/astral-sh/uv
- icon: fontawesome/brands/discord
link: https://discord.com/invite/astral-sh
- icon: fontawesome/brands/python
link: https://pypi.org/project/uv/
- icon: fontawesome/brands/x-twitter
link: https://x.com/astral_sh
nav:
- Introduction: index.md
- Getting started:
- getting-started/index.md
- Installation: getting-started/installation.md
- First steps: getting-started/first-steps.md
- Features: getting-started/features.md
- Getting help: getting-started/help.md
- Guides:
- guides/index.md
- Installing Python: guides/install-python.md
- Running scripts: guides/scripts.md
- Using tools: guides/tools.md
- Working on projects: guides/projects.md
- Publishing packages: guides/publish.md
- Concepts:
- concepts/index.md
- Projects: concepts/projects.md
- Dependencies: concepts/dependencies.md
- Workspaces: concepts/workspaces.md
- Tools: concepts/tools.md
- Python versions: concepts/python-versions.md
- Resolution: concepts/resolution.md
- Caching: concepts/cache.md
- Configuration:
- configuration/index.md
- Configuration files: configuration/files.md
- Environment variables: configuration/environment.md
- Authentication: configuration/authentication.md
- Package indexes: configuration/indexes.md
- Integration guides:
- guides/integration/index.md
- Docker: guides/integration/docker.md
- Jupyter: guides/integration/jupyter.md
- GitHub Actions: guides/integration/github.md
- GitLab CI/CD: guides/integration/gitlab.md
- Pre-commit: guides/integration/pre-commit.md
- FastAPI: guides/integration/fastapi.md
- Alternative indexes: guides/integration/alternative-indexes.md
- Dependency bots: guides/integration/dependency-bots.md
- The pip interface:
- pip/index.md
- Using environments: pip/environments.md
- Managing packages: pip/packages.md
- Inspecting packages: pip/inspection.md
- Declaring dependencies: pip/dependencies.md
- Locking environments: pip/compile.md
- Compatibility with pip: pip/compatibility.md
- Reference:
- reference/index.md
- Commands: reference/cli.md
- Settings: reference/settings.md
- Resolver: reference/resolver-internals.md
- Benchmarks: reference/benchmarks.md
- Versioning: reference/versioning.md
- Platform support: reference/platforms.md
validation:
omitted_files: warn
absolute_links: warn
unrecognized_links: warn