Commit graph

86 commits

Author SHA1 Message Date
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
Charlie Marsh
46a0ed7fa2
Use comma-separated values for UV_FIND_LINKS (#8061)
## Summary

These values can include spaces when passed on the command-line... Clap
doesn't give us a way to provide a value separator for _only_ an
environment variable (as is pip's behavior), so I think we're stuck
using comma-separated for here right now.

See, e.g., https://github.com/clap-rs/clap/discussions/3796.

Closes #8057.
2024-10-09 23:05:51 +00:00
Seth Morton
c591636dbe
Add UV_FIND_LINKS environment variable support for the --find-links command-line option (#7912)
## Summary

This PR adds support for the `UV_FIND_LINKS` environment variable as an
alternative to the `--find-links` command-line option, as requested in
#1839.

## Test Plan

A unit test was added to validate that setting `UV_FIND_LINKS` provided
the same result as a link provided with the `--find-links` command-line
option.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-04 11:30:49 +00:00
adisbladis
9f981c934a
Add UV_NO_SYNC environment variable (#7752)
## Summary

I have a workflow where I want use `uv` as a dependency solver only, and
manage my environments with external tooling (Nix).

## Test Plan

Manually tested. Automated testing seems excessive for such a trivial
change.

## Problems

It's still not as useful as I'd like it to be.
`uv` uncondtionally creates a virtual environment, something I would
expect that `--no-sync` should disable.
This looks a bit more tricky to achieve and I'm not sure about how to
best structure it.
2024-09-28 12:03:45 -04:00
konsti
1995d20298
Add uv publish: Basic upload with username/password or keyring (#7475)
Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-09-24 15:33:06 +00:00
Nick Murphy
49ae3dd94d
Document environment variable that disables printing of virtual environment name in prompt (#7648)
This PR adds a line to `docs/configuration/environment.md` that
documents `VIRTUAL_ENV_DISABLE_PROMPT`. If set to `1` when the virtual
environment is activated, then the virtual environment name will not be
prepended to a terminal prompt.

So far I've tested this in bash, but from the various activation
scripts, it looks like it is respected for a variety of shells.

Maintainers should please feel free to edit this PR directly. Thank you!
2024-09-23 14:48:21 -05:00
Zanie Blue
5ca3ded53b
Touchup to the project environment config section (#7038) 2024-09-04 15:02:35 -05:00
Mathieu Kniewallner
5cc76679e9
docs(configuration): clarify uv.toml precedence (#6986)
## Summary

Add a note in the documentation to clarify that `uv.toml` files take
precedence over `[tool.uv]` section in `pyproject.toml`, based on the
warning shown in the CLI:

```console
$ uv version
warning: Found both a `uv.toml` file and a `[tool.uv]` section in an adjacent `pyproject.toml`. The `[tool.uv]` section will be ignored in favor of the `uv.toml` file.
uv 0.4.2 (Homebrew 2024-09-01)
```
2024-09-04 15:57:41 +00:00
Zanie Blue
88ba1e90a0
Add docs for UV_PROJECT_ENVIRONMENT (#6987) 2024-09-03 19:47:05 -04:00
Zanie Blue
3e8d53c8eb
Document use of the file:// scheme in Python installation mirrors (#6984)
Documenting https://github.com/astral-sh/uv/pull/6950
2024-09-03 18:38:16 -05:00
Ed Morley
d2df51f5f5
Fix missing word in config files docs (#6901) 2024-08-31 22:33:59 +01:00
Charlie Marsh
f2ce80589f
Omit [pip] section from configuration file docs (#6814)
## Summary

Closes https://github.com/astral-sh/uv/issues/6800.
2024-08-29 12:57:13 -04:00
Charlie Marsh
d86075fc1e
Add support for --trusted-host (#6591)
## Summary

This PR revives https://github.com/astral-sh/uv/pull/4944, which I think
was a good start towards adding `--trusted-host`. Last night, I tried to
add `--trusted-host` with a custom verifier, but we had to vendor a lot
of `reqwest` code and I eventually hit some private APIs. I'm not
confident that I can implement it correctly with that mechanism, and
since this is security, correctness is the priority.

So, instead, we now use two clients and multiplex between them.

Closes https://github.com/astral-sh/uv/issues/1339.

## Test Plan

Created self-signed certificate, and ran `python3 -m http.server --bind
127.0.0.1 4443 --directory . --certfile cert.pem --keyfile key.pem` from
the packse index directory.

Verified that `cargo run pip install
transitive-yanked-and-unyanked-dependency-a-0abad3b6 --index-url
https://127.0.0.1:8443/simple-html` failed with:

```
error: Request failed after 3 retries
  Caused by: error sending request for url (https://127.0.0.1:8443/simple-html/transitive-yanked-and-unyanked-dependency-a-0abad3b6/)
  Caused by: client error (Connect)
  Caused by: invalid peer certificate: Other(OtherError(CaUsedAsEndEntity))
```

Verified that `cargo run pip install
transitive-yanked-and-unyanked-dependency-a-0abad3b6 --index-url
'https://127.0.0.1:8443/simple-html' --trusted-host '127.0.0.1:8443'`
failed with the expected error (invalid resolution) and made valid
requests.

Verified that `cargo run pip install
transitive-yanked-and-unyanked-dependency-a-0abad3b6 --index-url
'https://127.0.0.1:8443/simple-html' --trusted-host '127.0.0.2' -n` also
failed.
2024-08-27 09:36:50 -04:00
Mathieu Kniewallner
fd17f6d902
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.

![Screenshot from 2024-08-23
23-23-05](https://github.com/user-attachments/assets/38c92ef7-1f5e-40eb-8ea4-7024c8180bc4)

![Screenshot from 2024-08-23
23-23-31](https://github.com/user-attachments/assets/940dc7d5-22a8-4cd8-b54a-d56542d4345c)

Also using more content tabs for cases where we need to differentiate
macOS/Linux from Windows.

## Test Plan

Local run of the documentation.
2024-08-27 06:05:14 -05:00
Charlie Marsh
9d1cd8e48c
Add UV_COMPILE_BYTECODE environment variable (#6530)
## Summary

Closes https://github.com/astral-sh/uv/issues/6493.
2024-08-23 18:05:32 +00:00
Zanie Blue
7502a963e1
Add support for configuring python-downloads with UV_PYTHON_DOWNLOADS (#6436)
Part of https://github.com/astral-sh/uv/issues/6406

Replaces #6416
2024-08-22 23:19:03 +00:00
Zanie Blue
0c8661340e
Add support for configuring the python-preference with UV_PYTHON_PREFERENCE (#6432)
Part of https://github.com/astral-sh/uv/issues/6406
2024-08-22 10:57:36 -05:00
Zanie Blue
fc9fdd2dbb
Revert "Env variables for python downloads" (#6431)
This reverts commit bbd9adaa40 from #6416
— the Python download variable is not aligned with the setting.
2024-08-22 13:29:09 +00:00
Ahmed Ilyas
bbd9adaa40
Env variables for python downloads (#6416)
## Summary

Resolves #6406

## Test Plan

```
❯ UV_PYTHON_PREFERENCE=only-managed cargo run -q -- sync --show-settings | rg python_preference
    python_preference: OnlyManaged,
❯ UV_PYTHON_PREFERENCE=system cargo run -q -- sync --show-settings | rg python_preference
    python_preference: System,
❯ UV_NO_PYTHON_DOWNLOADS=1 cargo run -q -- sync --show-settings | rg python_downloads
    python_downloads: Never,
❯ UV_ALLOW_PYTHON_DOWNLOADS=1 cargo run -q -- sync --show-settings | rg python_downloads
    python_downloads: Automatic,
```
2024-08-22 08:52:52 -04:00
Jo
67360cf5f2
Update env vars doc about XDG_* variables on macOS (#6337)
After #5806, `uv` respects `XDG_*` env vars on macOS as well.
2024-08-21 10:09:26 -05:00
Zanie Blue
e5bebe06b6
Document the uv.pip section semantics (#6225)
Explains semantics for `[uv.pip]` settings.
2024-08-19 21:26:09 +00:00
Zanie Blue
6bc8639ce8
Allow customizing the tool install directory with UV_TOOL_BIN_DIR (#6207)
Requested in #6067
2024-08-19 15:02:10 +00:00
Jo
f2d6718038
Update environment variables doc (#5994)
## Summary

This PR adds descriptions for the `UV_TOOL_DIR`, `UV_PYTHON_INSTALL_DIR`
and `XDG_*` environment variables.

Additionally, it moves some env vars that are not command-line arguments
to the below "uv respects" section.

Closes #5746
2024-08-16 08:13:40 -05:00
Charlie Marsh
88ece8b791
Search beyond workspace root when discovering configuration (#5931)
## Summary

Previously, we wouldn't respect configuration files in directories
_above_ a workspace root. But this is somewhat problematic, because any
`pyproject.toml` will define a workspace root...

Instead, I think we should _start_ the search at the workspace root, but
go above it if necessary.

Closes: #5929.

See: https://github.com/astral-sh/uv/pull/4295.
2024-08-08 17:05:02 -04:00
Charlie Marsh
dd1bcf8ab9
Ignore local configuration in tool commands (#5923)
## Summary

If you're running a user-level command, we shouldn't respect the local
`pyproject.toml` or `uv.toml`.
2024-08-08 14:25:12 -04:00
Charlie Marsh
f7110e0a07
Enable mirror for python-build-standalone downloads (#5719)
## Summary

This came up again recently, so decided to do it real quick.

Closes https://github.com/astral-sh/uv/issues/5224.
2024-08-07 21:34:19 -04:00
konsti
db371560bc
Use prettier to format the documentation (#5708)
To enforce the 100 character line limit in markdown files introduced in
https://github.com/astral-sh/uv/pull/5635, and to automate the
formatting of markdown files, i've added prettier and formatted our
markdown files with it.

I've excluded the changelog and the generated references documentation
from this for having too many changes, but we can also include them.

I'm not particular on which style we use. My main motivations are
(major) not having to reflow markdown files myself anymore and (minor)
consistence between all markdown files. I've chosen prettier for similar
reason as we chose black, it's a single good style that's automated and
shared in the community. I do prefer prettier's style of not breaking
inside of a link name though.

This PR is in two parts, the first adds prettier to CI and documents
using it, while the second actually formats the docs. When merge
conflicts arise, we can drop the last commit and regenerate it with `npx
prettier --prose-wrap always --write BENCHMARKS.md CONTRIBUTING.md
README.md STYLE.md docs/*.md docs/concepts/**/*.md docs/guides/**/*.md
docs/pip/**/*.md`.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-02 08:58:31 -05:00
Zanie Blue
0f30c69624
Move settings reference to reference section (#5689)
Joining #5685 in a dedicated reference section
2024-08-01 16:20:30 +00:00
Charlie Marsh
5d727cb0af
Deprecate the --isolated flag (#5466)
## Summary

This PR deprecates the `--isolated` flag. The treatment varies across
the APIs:

- For non-preview APIs, we warn but treat it as equivalent to
`--no-config`.
- For preview APIs, we warn and ignore it, with two exceptions...
- For `tool run` and `run` specifically, we don't even warn, because we
can't differentiate the command-specific `--isolated` from the global
`--isolated`.
2024-07-30 22:40:38 +00:00
Zanie Blue
f971631adf
Wrap documentation at 100 characters (#5635)
Basically sick of dealing with mixed formatting here. Going with the
number at
7c08e61b73/.editorconfig (L20)
2024-07-30 22:17:58 +00:00
Zanie Blue
6eb8f85668
Update documentation sections (#5452)
Reframes "the low-level interface" as "the pip interface"
Adds indexes to all sections
Renames "commercial indexes" to "alternative indexes"
2024-07-25 12:37:22 -05:00
Zanie Blue
dac696e950
Bundle of documentation changes (#5307)
Following #5239
2024-07-23 13:29:59 -05:00
Zanie Blue
61a81da760
Move integration guide docs and edit Azure integration guide (#5117) 2024-07-18 03:47:32 +00:00
Mathieu Kniewallner
c9637f00f0
docs: bunch of fixes and improvements (#5136)
## Summary

A bunch of fixes and improvements on different parts of the
documentation. For Docker documentation changes, links to the relevant
documentations have been included in the commit messages.
2024-07-16 20:41:45 -04:00
Charlie Marsh
e61a221fef
Migrate from MdBook to MkDocs (#5062)
## Summary

We want to have consistency between the Ruff and uv documentation for
the upcoming release. We don't love the Ruff docs, but we'd rather have
consistency and then work towards improving them both, rather than have
two very-different documentation sites that both have weaknesses.

The setup here is simpler than in Ruff as: (1) we don't yet generate any
docs from Rust and (2) we don't try to reuse the README in the uv
documentation (which adds a lot of complexity in Ruff). So the change
here is mostly a 1-to-1 port to MkDocs.

## Test Plan

![Screenshot 2024-07-14 at 9 49
15 PM](https://github.com/user-attachments/assets/8bfb5b06-08ff-4329-b368-d9087b78996e)
2024-07-15 22:22:07 +00:00
Zanie Blue
1ee201da5a
Add structured documentation (#4426)
A ton of work remaining here, pushing so I can preview things rendered.

Here's the [latest rendered
documentation](https://astral-sh.github.io/uv/).
2024-06-26 11:28:42 -05:00