Commit graph

3331 commits

Author SHA1 Message Date
Zanie Blue
8dad1ac2d4
Use a larger runner for Windows test jobs (#5873)
From 8 to 16 cores, 32 to 64 GB ram. Testing on Windows first because
it's the bottleneck.

Previously tested in #2515 to no effect, maybe better now that we have a
development drive?
2024-08-07 12:31:59 -05:00
Zanie Blue
c95bf76dfe
Replace uv help python references in CLI documentation with links (#5871)
Following #5869, the documentation has some less-than-helpful
suggestions to use `uv help python` for details — we should link to the
`uv python` section instead.
2024-08-07 12:21:09 -05:00
Zanie Blue
fe2849af6a
Improve CLI documentation for uv tree (#5870) 2024-08-07 16:59:27 +00:00
Zanie Blue
2df2092084
Improve --python CLI documentation (#5869)
Closes #4400
2024-08-07 16:37:10 +00:00
Zanie Blue
32d8ea1698
Improve documentation for uv init CLI (#5862) 2024-08-07 11:26:00 -05:00
Charlie Marsh
f29bdcb9e3
Fix add_git_implicit test (#5872) 2024-08-07 16:23:47 +00:00
Charlie Marsh
9a80dfeed4
Assume git+ prefix when URLs end in .git (#5868)
## Summary

Right now, this applies _everywhere_, so the following also works:

```
pip install "elmer-circuitbuilder @ https://github.com/ElmerCSC/elmer_circuitbuilder.git"
```

I actually think that's ok?

Closes https://github.com/astral-sh/uv/issues/5866.
2024-08-07 15:50:36 +00:00
Charlie Marsh
dceba77ff7
Avoid mismatch in --locked with Git dependencies (#5865)
## Summary

We were dropping the query and fragment in the wrong place, so the URLs
didn't match up after resolving from an existing lockfile.

Closes https://github.com/astral-sh/uv/issues/5851.
2024-08-07 15:47:48 +00:00
Charlie Marsh
e4ec6e4025
Avoid panic when re-locking with precise commit (#5863)
## Summary

Very subtle bug. The scenario is as follows:

- We resolve: `elmer-circuitbuilder = { git =
"https://github.com/ElmerCSC/elmer_circuitbuilder.git" }`

- The user then changes the request to: `elmer-circuitbuilder = { git =
"https://github.com/ElmerCSC/elmer_circuitbuilder.git", rev =
"44d2f4b19d6837ea990c16f494bdf7543d57483d" }`

- When we go to re-lock, we note two facts:

1. The "default branch" resolves to
`44d2f4b19d6837ea990c16f494bdf7543d57483d`.
2. The metadata for `44d2f4b19d6837ea990c16f494bdf7543d57483d` is
(whatever we grab from the lockfile).

- In the resolver, we then ask for the metadata for
`44d2f4b19d6837ea990c16f494bdf7543d57483d`. It's already in the cache,
so we return it; thus, we never add the
`44d2f4b19d6837ea990c16f494bdf7543d57483d` ->
`44d2f4b19d6837ea990c16f494bdf7543d57483d` mapping to the Git resolver,
because we never have to resolve it.

This would apply for any case in which a requested tag or branch was
replaced by its precise SHA. Replacing with a different commit is fine.

It only applied to `tool.uv.sources`, and not PEP 508 URLs, because the
underlying issue is that we aren't consistent about "automatically"
extracting the precise commit from a Git reference.

Closes https://github.com/astral-sh/uv/issues/5860.
2024-08-07 10:56:15 -04:00
Charlie Marsh
3ae75a21aa
Support empty dependencies in PEP 723 scripts (#5864)
## Summary

Closes https://github.com/astral-sh/uv/issues/5859.
2024-08-07 10:56:05 -04:00
Zanie Blue
8998149ac1
Improve CLI documentation for uv run (#5841)
Adds more long-form help to `uv run`, which renders in `uv help run` and
the CLI reference on the website.
2024-08-07 13:26:24 +00:00
Zanie Blue
c34681a74c
Use uv installer during build (#5854) 2024-08-07 08:25:26 -05:00
konsti
54989f1376
Replace unreachable todo!() with unreachable!() in locking (#5857)
Replace a `todo!()` that was unreachable with an `unreachable!()` and a
proper comment.
2024-08-07 13:22:56 +00:00
konsti
68f186c409
Resolver internals docs touchups (#5850) 2024-08-07 08:32:31 +00:00
samypr100
2cd63f06dc
feat: more rust in trampoline (#5750)
## Summary

This is an experimental PR to replace more unsafe calls with more rust
while still trying to keep the binary size small enough. These changes
roughly increase the size of the trampolines to about 40kb~. This is a
alternate PR to https://github.com/astral-sh/uv/pull/5751.

The primary changes here include
* Switch to use rust path components for ease of path management
* Leverage `std::process::exit` for process exit and cleanup
* Use `std::io::Error::last_os_error` for IO Errors to remove
`FormatMessage` complexity
* Use `std::env::current_exe` to get the current executable instead of
`GetModuleFileNameA`

## Test Plan

Added one more existing test case to trampoline tests.
Still need to verify dunce::canonicalize is desired or not on
find_python_exe.

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-08-07 08:19:38 +00:00
Charlie Marsh
d0b16f9018
Ensure python-to-pythonX.Y symlink exists in downloaded Pythons (#5849)
## Summary

After installing:

```
❯ readlink "/Users/crmarsh/Library/Application Support/uv/python/cpython-3.12.4-macos-aarch64-none/bin/python"
python3.12

❯ readlink "/Users/crmarsh/Library/Application Support/uv/python/cpython-3.9.5-macos-aarch64-none/bin/python"
python3.9
```

Closes https://github.com/astral-sh/uv/issues/5838.
2024-08-06 23:03:22 -04:00
Charlie Marsh
e58c503f65
Reuse existing virtualenvs with --no-project (#5846)
## Summary

Closes https://github.com/astral-sh/uv/issues/5840.
2024-08-07 02:52:15 +00:00
Zanie Blue
345c167774
Fix GitHub cache integration link (#5847)
Unclear why mkdocs does not error on this 404
2024-08-07 02:08:45 +00:00
Zanie Blue
d1614c8f10
Improve CLI documentation for global options (#5834)
Slowly auditing our CLI help text
2024-08-06 20:50:29 -05:00
Charlie Marsh
0f63173400
Add --python argument to benchmark script (#5844)
## Summary

Makes it easy to benchmark on different Python versions. Used this for
transformers, where some projects don't support Python 3.12.
2024-08-06 21:45:46 -04:00
Charlie Marsh
cccb6820db
Avoid reusing incompatible distributions across lock and sync (#5845)
## Summary

We need to avoid using incompatible versions for build dependencies that
are also part of the resolved
environment. This is a very subtle issue, but: when locking, we don't
enforce platform
compatibility. So, if we reuse the resolver state to install, and the
install itself has to
preform a resolution (e.g., for the build dependencies of a source
distribution), that
resolution may choose incompatible versions.

The key property here is that there's a shared package between the build
dependencies and the
project dependencies.

Closes https://github.com/astral-sh/uv/issues/5836.
2024-08-07 00:54:51 +00:00
Charlie Marsh
f3cc8e4790
Minor improvements to benchmarking setup (#5843) 2024-08-06 23:47:45 +00:00
Charlie Marsh
9b06b3905d
Reject pyproject.toml in --config-file (#5842)
This already rejects `pyproject.toml`... but because the schema
validation is relaxed (we allow unknown fields, and all fields are
optional), a `pyproject.toml` doesn't get properly rejected here.

This PR makes the schema stricter, but in a safe way (by adding the
other `tool.uv` fields, like `workspace`, as any).

Closes #5832.
2024-08-06 23:40:59 +00:00
Charlie Marsh
fae9a70ca0
Add help heading for --no-sources (#5833) 2024-08-06 21:29:56 +00:00
Zanie Blue
c0c26cc542
Improve display order of top-level commands (#5830)
Closes https://github.com/astral-sh/uv/issues/5702

Since Clap 4, the default order follows the declarations.

Also improves some descriptions.
2024-08-06 16:18:05 -05:00
Charlie Marsh
d8d9b02512
Add --no-build-isolation to uv lock et al (#5829)
## Summary

Closes https://github.com/astral-sh/uv/issues/5742.
2024-08-06 21:11:48 +00:00
Zanie Blue
91792674da
Link to the GitHub integration guide from the cache concept (#5828) 2024-08-06 15:48:19 -05:00
Zanie Blue
6a31c80c7e
Update the override section with some content from the README (#5820) 2024-08-06 20:23:58 +00:00
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