Commit graph

4903 commits

Author SHA1 Message Date
Zanie Blue
aad39febe5
Address some feedback in the tools documentation (#5827) 2024-08-06 15:21:18 -05:00
Zanie Blue
f5b477aa4f
Update documentation index (#5824) 2024-08-06 15:01:59 -05:00
Zanie Blue
1f7961d6fb
Add "next steps" to some early documentation pages (#5825) 2024-08-06 13:48:04 -05:00
Zanie Blue
8cada6cbc9
Fix some console blocks in the environment doc (#5826) 2024-08-06 13:47:49 -05:00
Zanie Blue
12059340de
Update resolver reference documentation (#5823) 2024-08-06 13:18:23 -05:00
Charlie Marsh
9346946c7f
Allow downloading wheels for metadata with --no-binary (#5707)
## Summary

We allow the use of (e.g.) `.whl.metadata` files when `--no-binary` is
enabled, so it makes sense that we'd also also allow wheels to be
downloaded for metadata extraction. So now, we validate `--no-binary` at
install time, rather than metadata-fetch time.

Closes https://github.com/astral-sh/uv/issues/5699.
2024-08-06 18:14:12 +00:00
Charlie Marsh
3b75d8b6d6
Support uv add --dev in virtual workspaces (#5821)
## Summary

Closes https://github.com/astral-sh/uv/issues/5814.
2024-08-06 14:06:03 -04:00
Zanie Blue
83d6f59e2e
Update the resolution concept documentation (#5813) 2024-08-06 12:06:06 -05:00
Ibraheem Ahmed
e651e67f29
Support overlapping local and non-local requirements in forks (#5812)
## Summary

This fixes a bug introduced by
https://github.com/astral-sh/uv/pull/5232. It turns out that the
`universal_disjoint_base_or_local_requirement` test does not actually do
what it was meant to because of the incorrect python requirement. With a
valid python requirement, it fails on `main`. The problem is that we try
to exclude the original base version from the range of allowed versions
to try and prefer local versions. However, in the test, there is a
branch that depends on the non-local version, with no applicable local
in its fork. We should remove this exclusion as prioritization is
handled by the candidate resolver.
2024-08-06 12:04:35 -04:00
Charlie Marsh
089f50a845
Add --no-sources to avoid reading from tool.uv.sources (#5801)
## Summary

Closes https://github.com/astral-sh/uv/issues/5791.
2024-08-06 14:14:19 +00:00
Charlie Marsh
478d32c655
Strip URL fragments from lockfile (#5805)
## Summary

I noticed that we write entries like:

```
sdist = { url = "https://pkgs.dev.azure.com/astral-sh/_packaging/db3d73a9-2c37-40f9-8680-515ec6e132c4/pypi/download/iniconfig/2/iniconfig-2.0.0.tar.gz#sha256=2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3" }
```

(For registries that include hashes in the URLs, that is.)

This PR drops those unnecessary components from the lockfile (notice
that the hash is repeated).
2024-08-06 10:00:38 -04:00
Charlie Marsh
c59c8e080a
Use UrlString for Source struct (#5804)
I don't think this will save any time in serialization, but it should
save us some deserialization, since we only need to parse URLs for the
packages we use...
2024-08-06 12:58:09 +00:00
Delgan
3a24aecb2c
Fix invalid TOML syntax in examples of "config-settings" docs (#5809)
## Summary

The snippet generated TOML errors when I copy/pasted it in my config
file, I believe there was a typo. 👍

## Test Plan

N/A
2024-08-06 08:17:54 +00:00
Charlie Marsh
552c75cf49
Redact registry credentials in lockfile (#5803)
## Summary

Okay, I tested this against...

- Our public "private" proxy
- Fury
- AWS CodeArtifact
- Azure Artifacts

It took a long time.

All of them work as expected with this approach: we omit the credentials
from the lockfile, then wire them back up when the index URL is provided
during subsequent operations.

Closes https://github.com/astral-sh/uv/issues/5119.
2024-08-05 22:54:18 -04:00
Zanie Blue
dd20afdd43
Create help sections for build, install, resolve, and index (#5693)
Part of #4454 

e.g.

```
$ uv add --help
Add one or more packages to the project requirements

Usage: uv add [OPTIONS] <REQUIREMENTS>...

Arguments:
  <REQUIREMENTS>...  The packages to add, as PEP 508 requirements (e.g., `ruff==0.5.0`)

Options:
      --dev                  Add the requirements as development dependencies
      --optional <OPTIONAL>  Add the requirements to the specified optional dependency group
      --no-editable          Don't add the requirements as editables
      --raw-sources          Add source requirements to `project.dependencies`, rather than `tool.uv.sources`
      --rev <REV>            Specific commit to use when adding from Git
      --tag <TAG>            Tag to use when adding from git
      --branch <BRANCH>      Branch to use when adding from git
      --extra <EXTRA>        Extras to activate for the dependency; may be provided more than once
      --locked               Assert that the `uv.lock` will remain unchanged
      --frozen               Add the requirements without updating the `uv.lock` file
      --package <PACKAGE>    Add the dependency to a specific package in the workspace
  -p, --python <PYTHON>      The Python interpreter into which packages should be installed. [env: UV_PYTHON=]

Index options:
  -i, --index-url <INDEX_URL>                The URL of the Python package index (by default: <https://pypi.org/simple>) [env: UV_INDEX_URL=]
      --extra-index-url <EXTRA_INDEX_URL>    Extra URLs of package indexes to use, in addition to `--index-url` [env: UV_EXTRA_INDEX_URL=]
  -f, --find-links <FIND_LINKS>              Locations to search for candidate distributions, in addition to those found in the registry indexes
      --no-index                             Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those provided via `--find-links`
      --index-strategy <INDEX_STRATEGY>      The strategy to use when resolving against multiple index URLs [env: UV_INDEX_STRATEGY=] [possible values: first-index, unsafe-first-match, unsafe-best-match]
      --keyring-provider <KEYRING_PROVIDER>  Attempt to use `keyring` for authentication for index URLs [env: UV_KEYRING_PROVIDER=] [possible values: disabled, subprocess]

Resolver options:
  -U, --upgrade                            Allow package upgrades, ignoring pinned versions in any existing output file
  -P, --upgrade-package <UPGRADE_PACKAGE>  Allow upgrades for a specific package, ignoring pinned versions in any existing output file
      --resolution <RESOLUTION>            The strategy to use when selecting between the different compatible versions for a given package requirement [env: UV_RESOLUTION=] [possible values: highest, lowest, lowest-direct]
      --prerelease <PRERELEASE>            The strategy to use when considering pre-release versions [env: UV_PRERELEASE=] [possible values: disallow, allow, if-necessary, explicit, if-necessary-or-explicit]
      --exclude-newer <EXCLUDE_NEWER>      Limit candidate packages to those that were uploaded prior to the given date [env: UV_EXCLUDE_NEWER=]

Installer options:
      --reinstall                              Reinstall all packages, regardless of whether they're already installed. Implies `--refresh`
      --reinstall-package <REINSTALL_PACKAGE>  Reinstall a specific package, regardless of whether it's already installed. Implies `--refresh-package`
      --link-mode <LINK_MODE>                  The method to use when installing packages from the global cache [env: UV_LINK_MODE=] [possible values: clone, copy, hardlink, symlink]
      --compile-bytecode                       Compile Python files to bytecode after installation

Build options:
  -C, --config-setting <CONFIG_SETTING>        Settings to pass to the PEP 517 build backend, specified as `KEY=VALUE` pairs
      --no-build                               Don't build source distributions
      --no-build-package <NO_BUILD_PACKAGE>    Don't build source distributions for a specific package
      --no-binary                              Don't install pre-built wheels
      --no-binary-package <NO_BINARY_PACKAGE>  Don't install pre-built wheels for a specific package

Cache options:
  -n, --no-cache                           Avoid reading from or writing to the cache, instead using a temporary directory for the duration of the operation [env: UV_NO_CACHE=]
      --cache-dir <CACHE_DIR>              Path to the cache directory [env: UV_CACHE_DIR=]
      --refresh                            Refresh all cached data
      --refresh-package <REFRESH_PACKAGE>  Refresh cached data for a specific package

Python options:
      --python-preference <PYTHON_PREFERENCE>  Whether to prefer using Python installations that are already present on the system, or those that are downloaded and installed by uv [possible values: only-managed, managed, system, only-system]
      --python-fetch <PYTHON_FETCH>            Whether to automatically download Python when required [possible values: automatic, manual]

Global options:
  -q, --quiet                      Do not print any output
  -v, --verbose...                 Use verbose output
      --color <COLOR_CHOICE>       Control colors in output [default: auto] [possible values: auto, always, never]
      --native-tls                 Whether to load TLS certificates from the platform's native certificate store [env: UV_NATIVE_TLS=]
      --offline                    Disable network access, relying only on locally cached data and locally available files
      --no-progress                Hides all progress outputs when set
      --config-file <CONFIG_FILE>  The path to a `uv.toml` file to use for configuration [env: UV_CONFIG_FILE=]
      --no-config                  Avoid discovering configuration files (`pyproject.toml`, `uv.toml`) in the current directory, parent directories, or user configuration directories [env: UV_NO_CONFIG=]
  -h, --help                       Print help
  -V, --version                    Print version

Use `uv help add` for more details.
```
2024-08-05 21:28:35 +00:00
Zanie Blue
f08cd2b9dc
Add a guide for publishing packages (#5794)
Closes https://github.com/astral-sh/uv/issues/5793
2024-08-05 16:12:37 -05:00
Charlie Marsh
82c3b12b27
Avoid using already-installed tools on --upgrade or --reinstall (#5799)
## Summary

See: https://github.com/astral-sh/uv/issues/5797. This isn't great but
is _probably_ more intuitive than using the existing tool.
2024-08-05 20:48:36 +00:00
Charlie Marsh
801797e7bf
Don't show deprecated warning in uvx --isolated (#5798)
## Summary

An oversight.
2024-08-05 16:32:22 -04:00
Charlie Marsh
33ec6f063d
Remove interpreter from BuildContext trait (#5800) 2024-08-05 16:32:10 -04:00
Charlie Marsh
92a2996e8e
Show extras and dev dependencies in uv tree (#5768)
## Summary

Closes https://github.com/astral-sh/uv/issues/5759.
2024-08-05 19:15:02 +00:00
Charlie Marsh
6b45baf7be
Support --python-platform in uv tree (#5764)
## Summary

This allows you to set (e.g.) `--python-platform windows` to view the
resolved dependencies on Windows.

Closes https://github.com/astral-sh/uv/issues/5760.
2024-08-05 19:02:35 +00:00
Charlie Marsh
3156fccc85
Filter uv tree to current platform by default (#5763)
## Summary

`uv tree` will now filter to the current platform by default. You can
pass `--universal` to show the entire tree.

Closes https://github.com/astral-sh/uv/issues/5760.
2024-08-05 18:51:18 +00:00
Zanie Blue
865f9eeef7
Collapse policies section into reference (#5696) 2024-08-05 17:44:26 +00:00
Zanie Blue
77430a0972
Use uvx in docs serve contributing command (#5795) 2024-08-05 12:41:22 -05:00
Charlie Marsh
ce30bffaab
Make some minor tweaks to the docs (#5786)
## Summary

Small stuff from a first scan.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-05 13:54:06 +00:00
Charlie Marsh
823c17723b
Remove top-level bar from Python installs (#5788) 2024-08-05 02:37:39 +00:00
Charlie Marsh
bb6ac67df3
Use cache for Python install temporary directories (#5787)
## Summary

It's fine for this to be in the cache, I think, since we don't
necessarily need to colocate it with the Python directory.

Closes https://github.com/astral-sh/uv/issues/5747.
2024-08-05 02:32:24 +00:00
renovate[bot]
02eba290f6
Update Rust crate tempfile to v3.11.0 (#5784) 2024-08-05 01:46:44 +00:00
renovate[bot]
b4cb3f2266
Update Rust crate indexmap to v2.3.0 (#5783) 2024-08-05 01:43:29 +00:00
renovate[bot]
de589af83b
Update pre-commit dependencies (#5782) 2024-08-05 01:42:30 +00:00
renovate[bot]
c14d84609d
Update Rust crate winsafe to 0.0.22 (#5780) 2024-08-05 01:13:37 +00:00
renovate[bot]
77141464fe
Update Rust crate which to v6.0.2 (#5779) 2024-08-05 01:08:55 +00:00
renovate[bot]
03b033f828
Update Rust crate toml to v0.8.19 (#5777) 2024-08-05 01:01:56 +00:00
renovate[bot]
0c3ac4eafe
Update Rust crate target-lexicon to v0.12.16 (#5776) 2024-08-05 00:57:41 +00:00
Charlie Marsh
6a80f176a3
Remove some trailing backticks from the docs (#5781) 2024-08-05 00:56:03 +00:00
renovate[bot]
e16ba6ed51
Update Rust crate serde_json to v1.0.122 (#5775) 2024-08-05 00:53:28 +00:00
renovate[bot]
28aa720e29
Update Rust crate regex to v1.10.6 (#5774) 2024-08-05 00:52:47 +00:00
renovate[bot]
96b52510e1
Update Rust crate flate2 to v1.0.31 (#5773) 2024-08-05 00:49:10 +00:00
renovate[bot]
f38fd25e95
Update Rust crate dunce to v1.0.5 (#5772) 2024-08-05 00:46:43 +00:00
renovate[bot]
09b227ce86
Update Rust crate clap to v4.5.13 (#5771) 2024-08-05 00:45:52 +00:00
Delgan
260d1f546f
Fix broken anchor links in docs about dependencies (#5769) 2024-08-05 00:42:48 +00:00
Charlie Marsh
0b259c8cea
Remove lock from TreeDisplay (#5770) 2024-08-05 00:34:58 +00:00
Charlie Marsh
7567039b80
Avoid lingering dev and optional dependencies in uv tree (#5766)
## Summary

Dev and optional dependencies were appearing at the top-level.
2024-08-04 20:37:01 +00:00
Charlie Marsh
a9a535da14
Use lockfile directly in uv tree (#5761)
## Summary

Ensures that we properly handle (1) duplicated packages and (2) packages
that aren't relevant to the current platform.

Closes https://github.com/astral-sh/uv/issues/5716.
Closes https://github.com/astral-sh/uv/issues/5253.
2024-08-04 14:33:13 -04:00
Charlie Marsh
c5052bc36c
Respect malformed .dist-info directories in tool installs (#5756)
## Summary

Closes https://github.com/astral-sh/uv/issues/5749.
2024-08-03 19:43:03 -04:00
FishAlchemist
26b3bfbedb
Fix the default value of python-preference in docs/reference/settings.md (#5755)
## Summary
After referring to https://github.com/astral-sh/uv/pull/5637 and doing
additional testing.
The default value in a stable state seems more reasonable to be
``only-system``. ``managed`` in preview.
```
cpython-3.11.9-windows-x86_64-none     C:\Users\name\AppData\Local\Programs\Python\Python311\python.exe

cpython-3.10.14-windows-x86_64-none    C:\Users\name\AppData\Roaming\uv\data\python\cpython-3.10.14-windows-x86_64-none\install\python.exe
cpython-3.10.11-windows-x86_64-none    C:\Users\name\AppData\Local\Programs\Python\Python310\python.exe

cpython-3.9.19-windows-x86_64-none     C:\Users\name\AppData\Roaming\uv\data\python\cpython-3.9.19-windows-x86_64-none\python.exe
```
test on uv 0.2.33 (build from
257007ccaf)
### Stable version
``uv venv -p 3.10`` is ``3.10.11`` (System Python)
``uv venv -p 3.9`` is ``No interpreter found``(3.9.19 for managed
Python)
``uv venv -p 3.9 --python-preference only-system`` is ``No interpreter
found``(fail)
``uv venv -p 3.9 --python-preference only-managed`` is
``3.9.19``(success)
Do not use managed Python, only use the system Python, so it can be
determined as ``only-system``.
### Preview mode
**Note:**  ``3.10.14`` is managed python, ``3.10.11`` is system python.
``uv venv -p 3.11 --preview`` is ``3.11.9`` (System Python)
``uv venv -p 3.10 --preview`` is ``3.10.14``
``uv venv -p 3.10 --preview --python-preference only-managed`` is
``3.10.14``
``uv venv -p 3.10 --preview --python-preference managed`` is ``3.10.14``
``uv venv -p 3.10 --preview --python-preference system`` is ``3.10.11``
``venv -p 3.10 --preview --python-preference only-system`` is
``3.10.11``
Prioritize the managed Python and then select the system Python, so it
can be determined as ``managed``.

-----
fixed #5754 
## Test Plan
Run website in local.

![image](https://github.com/user-attachments/assets/02b81d44-1a99-4165-aca5-6ce46345b539)
2024-08-03 23:37:40 +00:00
Charlie Marsh
22dbb1741b
Avoid monomorphization of untar (#5743)
## Summary

This reduces the LLVM lines of the entire project by about 15%.

Before:

```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1742332                42054                (TOTAL)
    22384 (1.3%,  1.3%)     16 (0.0%,  0.0%)  tokio_tar::entry::EntryFields<R>::unpack::{{closure}}
    19113 (1.1%,  2.4%)     69 (0.2%,  0.2%)  alloc::raw_vec::RawVec<T,A>::grow_amortized
    18352 (1.1%,  3.4%)     80 (0.2%,  0.4%)  tokio_tar::entry::EntryFields<R>::unpack::{{closure}}::{{closure}}
    16871 (1.0%,  4.4%)    613 (1.5%,  1.9%)  core::result::Result<T,E>::map_err
    14747 (0.8%,  5.2%)    594 (1.4%,  3.3%)  <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
    12576 (0.7%,  6.0%)     16 (0.0%,  3.3%)  <tokio_tar::archive::Entries<R> as futures_core::stream::Stream>::poll_next
    12314 (0.7%,  6.7%)    226 (0.5%,  3.8%)  <alloc::boxed::Box<T,A> as core::ops::drop::Drop>::drop
    11895 (0.7%,  7.4%)    296 (0.7%,  4.5%)  std::panicking::try
    11718 (0.7%,  8.0%)     63 (0.1%,  4.7%)  alloc::raw_vec::RawVec<T,A>::try_allocate_in
    11152 (0.6%,  8.7%)     16 (0.0%,  4.7%)  uv_extract::stream::untar_in::{{closure}}
    10977 (0.6%,  9.3%)      1 (0.0%,  4.7%)  uv::run::{{closure}}::{{closure}}
    10859 (0.6%,  9.9%)     77 (0.2%,  4.9%)  <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
    10508 (0.6%, 10.5%)     18 (0.0%,  5.0%)  <core::iter::adapters::flatten::FlattenCompat<I,U> as core::iter::traits::iterator::Iterator>::size_hint
    10260 (0.6%, 11.1%)    138 (0.3%,  5.3%)  core::iter::traits::iterator::Iterator::try_fold
    10196 (0.6%, 11.7%)      8 (0.0%,  5.3%)  uv_extract::stream::unzip::{{closure}}
    10178 (0.6%, 12.3%)      7 (0.0%,  5.3%)  uv_client::cached_client::CachedClient::get_cacheable::{{closure}}::{{closure}}
     9698 (0.6%, 12.8%)    293 (0.7%,  6.0%)  tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
```

After:

```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1496463                37891                (TOTAL)
    14958 (1.0%,  1.0%)     54 (0.1%,  0.1%)  alloc::raw_vec::RawVec<T,A>::grow_amortized
    13997 (0.9%,  1.9%)    564 (1.5%,  1.6%)  <core::result::Result<T,E> as core::ops::try_trait::Try>::branch
    12776 (0.9%,  2.8%)    463 (1.2%,  2.9%)  core::result::Result<T,E>::map_err
    12381 (0.8%,  3.6%)    227 (0.6%,  3.5%)  <alloc::boxed::Box<T,A> as core::ops::drop::Drop>::drop
    11895 (0.8%,  4.4%)    296 (0.8%,  4.2%)  std::panicking::try
    10977 (0.7%,  5.1%)      1 (0.0%,  4.2%)  uv::run::{{closure}}::{{closure}}
    10859 (0.7%,  5.9%)     77 (0.2%,  4.4%)  <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
    10508 (0.7%,  6.6%)     18 (0.0%,  4.5%)  <core::iter::adapters::flatten::FlattenCompat<I,U> as core::iter::traits::iterator::Iterator>::size_hint
    10196 (0.7%,  7.3%)      8 (0.0%,  4.5%)  uv_extract::stream::unzip::{{closure}}
    10178 (0.7%,  7.9%)      7 (0.0%,  4.5%)  uv_client::cached_client::CachedClient::get_cacheable::{{closure}}::{{closure}}
     9698 (0.6%,  8.6%)    293 (0.8%,  5.3%)  tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
     9078 (0.6%,  9.2%)      9 (0.0%,  5.3%)  core::slice::sort::partition_in_blocks
     8928 (0.6%,  9.8%)     48 (0.1%,  5.4%)  alloc::raw_vec::RawVec<T,A>::try_allocate_in
     8288 (0.6%, 10.3%)    296 (0.8%,  6.2%)  std::panicking::try::do_catch
     8190 (0.5%, 10.9%)    108 (0.3%,  6.5%)  core::iter::traits::iterator::Iterator::try_fold
     7540 (0.5%, 11.4%)    466 (1.2%,  7.7%)  core::ops::function::FnOnce::call_once
     6612 (0.4%, 11.8%)    296 (0.8%,  8.5%)  std::panicking::try::do_call
     6513 (0.4%, 12.3%)     56 (0.1%,  8.7%)  tokio::runtime::task::core::Cell<T,S>::new
     6438 (0.4%, 12.7%)    269 (0.7%,  9.4%)  alloc::boxed::Box<T>::new
     6360 (0.4%, 13.1%)     20 (0.1%,  9.4%)  <toml_edit:🇩🇪:value::ValueDeserializer as serde:🇩🇪:Deserializer>::deserialize_any
```
2024-08-03 23:29:17 +00:00
Charlie Marsh
257007ccaf
Omit local segments when adding uv add bounds (#5753)
## Summary

Closes https://github.com/astral-sh/uv/issues/5752.
2024-08-03 17:35:53 +00:00
konsti
ba924d298f
Better workspace documentation (#5728)
Add more context around using workspaces.

Closes #5604.

Preview (ignore the glitchy navbar):


![image](https://github.com/user-attachments/assets/61b08a9c-958a-4529-8781-509597704350)
2024-08-03 08:49:09 -05:00
konsti
6e310f2702
Rewrite resolver docs (#5723)
This PR rewrites the resolver concept and adds a resolver internals page
targeted at power users.

The new resolution concept documentation has three parts:
* An introduction for people how never heard of "resolution" before, and
a motivating example what it does. I've also shoved the part about
equally valid resolutions in there.
* Features you commonly use: Non-universal vs. universal resolution,
lowest resolution amd pre-releases.
* Expert features, we don't advertise them, you'll only need them in
complex cases when you already know and i kept them to the reference
points you need in this case: Constraints, overrides and exclude-newer.

I intentionally didn't lay out any detail of the resolution itself, the
idea is that users get a vague sense of "uv has to select fitting
versions", but then they learn the options they have to use and some
common failure points without ever coming near SAT or even graphs.

The resolution internals reference page is targeted at power users who
need to understand what is going on behind the scenes. It assumes ample
prior knowledge and exists to explain the uv-specific behaviors for
someone who already understands dependency resolution conceptually and
has interacted with their dependency tree before. I had a section on the
lockfile but removed it because it found the lockfile to be too
self-documenting.

I haven't touched the readme.

Closes #5603
Closes #5238
Closes #5237

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-03 08:47:11 -05:00