Commit graph

356 commits

Author SHA1 Message Date
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
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
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
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
Ahmed Ilyas
ff9f3dede1
Support build constraints (#5639)
## Summary

Partially resolves #5561. Haven't added overrides support yet but I can
add it tomorrow if the current approach for constraints is ok.

## Test Plan

`cargo test`

Manually checked trace logs after changing the constraints.
2024-08-02 02:15:58 +00:00
Charlie Marsh
499c368f1e
Use "pre-release" in prose and Prerelease in code (#5697)
## Summary

Closes https://github.com/astral-sh/uv/issues/5630.
2024-08-01 20:56:29 +00:00
Zanie Blue
6797caccdb
Update top-level command descriptions (#5706)
Addresses feedback in https://github.com/astral-sh/uv/pull/5700
2024-08-01 20:29:26 +00:00
Zanie Blue
34f657c964
Unhide the experimental top-level commands (#5700) 2024-08-01 14:06:07 -05:00
Zanie Blue
159108b728
Move --python and --python-version into the "Python options" help (#5691)
Part of #4454 

e.g. for `uv help pip compile`

```
Python options:
      --python <PYTHON>
          The Python interpreter against which to compile the requirements.
          
          By default, uv uses the virtual environment in the current working directory or any parent
          directory, falling back to searching for a Python executable in `PATH`. The `--python`
          option allows you to specify a different interpreter.
          
          Supported formats:
          - `3.10` looks for an installed Python 3.10 using `py --list-paths` on Windows, or
            `python3.10` on Linux and macOS.
          - `python3.10` or `python.exe` looks for a binary with the given name in `PATH`.
          - `/home/ferris/.local/bin/python3.10` uses the exact Python at the given path.

  -p, --python-version <PYTHON_VERSION>
          The minimum Python version that should be supported by the resolved requirements (e.g., `3.8` or `3.8.17`).
          
          If a patch version is omitted, the minimum patch version is assumed. For example, `3.8` is mapped to `3.8.0`.

      --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: Only use managed Python installations; never use system Python installations
          - managed:      Prefer managed Python installations over system Python installations
          - system:       Prefer system Python installations over managed Python installations
          - only-system:  Only use system Python installations; never use managed Python installations

      --python-fetch <PYTHON_FETCH>
          Whether to automatically download Python when required

          Possible values:
          - automatic: Automatically fetch managed Python installations when needed
          - manual:    Do not automatically fetch managed Python installations; require explicit installation
 ```
2024-08-01 11:55:11 -05:00
eth3lbert
9788496c51
Grouping GlobalArgs to dedicated heading (#5665)
## Summary

Part of #4454 .

## Test Plan

test cases included.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-08-01 10:01:22 -05:00
eth3lbert
54398fa7bc
Show help specific options in uv help (#5516)
## Summary

Resolves #5221 

## Test Plan

Test case included.
2024-07-31 12:10:57 -05:00
Charlie Marsh
176e9c4deb
Add --package to uv sync (#5656)
## Summary

Closes https://github.com/astral-sh/uv/issues/5008.
2024-07-31 15:16:48 +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
Charlie Marsh
67b3bfa213
Add --isolated support to uv run (#5471)
## Summary

The culmination of #4730. We now have `uv run --isolated` which always
uses a fresh environment (but includes the workspace dependencies as
needed). This enables you to test with strict isolation (e.g., `uv run
--isolated -p foo` will ensure that `foo` is unable to import anything
that isn't an actual dependency).

Closes #5430.
2024-07-30 19:27:47 +00:00
Charlie Marsh
ff3bcbb639
Reframe use of --isolated in tool run (#5470)
## Summary

This PR gets rid of the global `--isolated` flag (which serves a bunch
of independent responsibilities right now) on `uv tool run` in favor of
a dedicated `--isolated` flag, which tells uv to avoid re-using an
existing tool environment for this invocation. We'll add the same thing
to `uv run`, to avoid using the base project environment.

This will become a bit clearer in #5466, when we deprecate the
`--isolated` flag on the preview APIs.
2024-07-30 15:09:53 -04:00
Charlie Marsh
d6c319a368
Suppress resolver output by default in uv run and uv tool run (#5580)
## Summary

The idea here is that we hide all resolver output (the grayed out
resolver messages, plus the list of environment modifications) by
default in `uv run` and `uv tool run`. You can pass `--show-resolution`
to re-enable them.

Closes https://github.com/astral-sh/uv/issues/5458.
2024-07-30 18:11:52 +00:00
Charlie Marsh
f7494f24cf
Remove --isolated usages from the uv python API (#5468) 2024-07-30 17:52:53 +00:00
Charlie Marsh
f1b3d2e1e1
Add --no-workspace and --no-project in lieu of --isolated (#5465)
## Summary

Right now, `--isolated` is read from `uv run` and `uv init` to avoid
discovering the current workspace (or project). This PR moves that
behavior to a dedicated `--no-workspace` flag for `uv init`, and
`--no-project` for `uv run`. They could use the same flag, but
`--no-project` feels confusing for `uv init`, and `--no-workspace` seems
confusing for `uv run` (especially so once you read the documentation,
where we refer to the thing you're omitting as the project).

Closes https://github.com/astral-sh/uv/issues/5429.
2024-07-30 13:40:35 -04:00
eth3lbert
fc78561fa1
Add git-ref group for uv add (#5502)
## Summary

This PR allows us to reject specifying more than one git-ref at the cli
level.

## Test Plan

Test cases included.
2024-07-30 09:40:28 -05:00
Charlie Marsh
c46adee48d
Make --directory a global argument (#5579)
## Summary

Cargo makes this global (and uses the same technique). It's still hidden
so we can always decide to remove it.
2024-07-29 19:43:55 -04:00
eth3lbert
3e329029bc
List installed tools when no command is provided to uv tool run (#5553)
## Summary

Part of #4024 

## Test Plan

Test cases included.
2024-07-29 22:12:31 +00:00
bluss
e46c24d3cf
Implement uv run --directory (#5566)
## Summary

uv run --directory <path> means that one doesn't have to change to a
project's directory to run programs from it. It makes it possible to use
projects as if they are tool installations.

To support this, first the code reading .python-version was updated so
that
it can read such markers outside the current directory. Note the minor
change this causes (if I'm right), described in the commit.

## Test Plan

One test has been added.

## --directory

Not sure what the name of the argument should be, but it's following uv
sync's directory for now.

Other alternatives could be "--project". Uv run and uv tool run should
probably find common agreement on this (relevant for project-locked
tools).

I've implemented this same change in Rye, some time ago, and then we
went
with --pyproject `<`path to pyproject.toml file`>`. I think using
pyproject.toml file path and not directory was probably a mistake, an
overgeneralization one doesn't need.
2024-07-29 15:53:10 -04:00
Pavel Dikov
cb47aed9de
feat(venv): add relocatable flag (#5515)
## Summary

Adds a `--relocatable` CLI arg to `uv venv`. This flag does two things:

* ensures that the associated activation scripts do not rely on a
hardcoded
absolute path to the virtual environment (to the extent possible; `.csh`
and
  `.nu` left as-is)
* persists a `relocatable` flag in `pyvenv.cfg`.

The flag in `pyvenv.cfg` in turn instructs the wheel `Installer` to
create script
entrypoints in a relocatable way (use `exec` trick + `dirname $0` on
POSIX;
use relative path to `python[w].exe` on Windows).

Fixes: #3863

## Test Plan

* Relocatable console scripts covered as additional scenarios in
existing test cases.
* Integration testing of boilerplate generation in `venv`.
* Manual testing of `uv venv` with and without `--relocatable`
2024-07-29 00:10:11 +00:00
Charlie Marsh
efbc9fb78d
Add support for benchmarking uv sync and uv lock (#5524)
## Summary

This PR adds support for `uv lock` and `uv sync` in the standardized
benchmarks script.

Part of: https://github.com/astral-sh/uv/issues/5263.

## Test Plan

For example:

```sh
python scripts/bench/__main__.py --uv-project --benchmark resolve-cold ./scripts/requirements/trio.in --verbose
```
2024-07-28 21:09:08 +00:00
Charlie Marsh
88340fbd0d
Remove some unused methods (#5512) 2024-07-28 17:20:12 +00:00
Jo
ae11317cc0
Make pip list --editable conflicts with --exlcude-editable (#5506)
## Summary

I think it makes no sense to allow `--editable` and `--exclude-editable`
at the same time.

## Test Plan
```console
$ cargo run -- pip list --editable --exclude-editable
error: the argument '--editable' cannot be used with '--exclude-editable'

Usage: uv.exe pip list --editable

For more information, try '--help'.

```
2024-07-27 08:26:46 -04:00
Ahmed Ilyas
e8d7c0cb58
Editable installs for uv tool (#5454)
## Summary

Resolves #5436. 

## Test Plan

`cargo test` 

```console
❯ ./target/debug/uv tool install -e ~/black
warning: `uv tool install` is experimental and may change without warning
Resolved 6 packages in 894ms
   Built black @ file:///Users/ahmedilyas/black
Prepared 1 package in 468ms
Installed 6 packages in 6ms
 + black==24.4.3.dev23+g7e2afc9 (from file:///Users/ahmedilyas/black)
 + click==8.1.7
 + mypy-extensions==1.0.0
 + packaging==24.1
 + pathspec==0.12.1
 + platformdirs==4.2.2
Installed 2 executables: black, blackd
```

venv has the `.pth` files.
```console
❯ eza /Users/ahmedilyas/Library/Application\ Support/uv/tools/black/lib/python3.12/site-packages/
_black.pth       _virtualenv.py                         click                  mypy_extensions-1.0.0.dist-info  packaging                 pathspec                   platformdirs
_virtualenv.pth  black-24.4.3.dev23+g7e2afc9.dist-info  click-8.1.7.dist-info  mypy_extensions.py               packaging-24.1.dist-info  pathspec-0.12.1.dist-info  platformdirs-4.2.2.dist-info
```

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-07-26 16:30:15 -04:00
Charlie Marsh
d51b429837
Add --no-config to replace --isolated (#5463)
## Summary

I'll deprecate `--isolated` separately, since it _is_ still used for
some other behaviors.

Closes #5428.
2024-07-25 19:58:36 -04:00
Charlie Marsh
d0919329fd
Make --reinstall imply --refresh (#5425)
## Summary

It's hard for me to imagine a scenario in which a user passed
`--reinstall`, but wanted us to keep respecting cached data for a
package. For example, to actually "rebuild and reinstall" an editable
today, you have to pass both `--reinstall` and `--refresh`.

This PR makes `--reinstall` imply `--refresh`, so we always validate
that the cached data is fresh.

Closes https://github.com/astral-sh/uv/issues/5424.
2024-07-25 09:45:58 -04:00
Charlie Marsh
4bc04f91e9
Add --ci mode to uv cache prune (#5391)
## Summary

Users can now run `uv cache prune --ci` (open to feedback on the name of
that flag) to remove all pre-built wheels from the cache, leaving behind
zipped, built wheels (which tend to be the most expensive assets to
re-create). This should greatly increase cache performance in CI
environments, since uploading unzipped wheels can actually hurt
performance if you're persisting the uv cache.

Closes https://github.com/astral-sh/uv/issues/5282.
2024-07-24 19:34:19 +00:00
Jo
7bcafec778
Add uv init --virtual (#5396)
## Summary

Add `uv init --virtual` to create an explicit virtual workspace.

Relates to #5338
2024-07-24 18:52:33 +00:00
Charlie Marsh
8942ec36c0
Mark --raw-sources as conflicting with sources-specific arguments (#5378)
## Summary

We should error on, e.g., `--raw-sources --tag 0.0.1`.
2024-07-23 22:03:01 +00:00
Charlie Marsh
76566b09be
Reject Git CLI arguments with non-Git sources (#5377)
## Summary

Closes https://github.com/astral-sh/uv/issues/5335.
2024-07-23 21:48:50 +00:00
Charlie Marsh
2cdcc61da9
Support requirements.txt files in uv tool install and uv tool run (#5362)
## Summary

Closes https://github.com/astral-sh/uv/issues/5347.
Closes https://github.com/astral-sh/uv/issues/5348.
2024-07-23 20:06:17 +00:00
Zanie Blue
5f1f9c8293
Add support for requirements files in uv run (#4973)
Closes https://github.com/astral-sh/uv/issues/4824.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-07-23 12:51:09 -04:00
Charlie Marsh
0f8186d9ad
Add requires-python to uv init (#5322)
## Summary

Prefers, in order:

- The major-minor version of an interpreter discovered via `--python`.
- The `requires-python` from the workspace.
- The major-minor version of the default interpreter.

If the `--python` request is a version or a version range, we use that
without fetching an interpreter.

Closes https://github.com/astral-sh/uv/issues/5299.
2024-07-23 16:02:40 +00:00
Chan Kang
12518a01a4
Implement --show-version-specifiers for tree (#5240)
## Summary
resolves https://github.com/astral-sh/uv/issues/5217

## Test Plan
existing tests pass (should be perfectly backwards compatible) + added a
few tests to cover the new functionality. in particular, in addition to
the simple use of `--show-version-specifiers`, its interaction with
`--invert` and `--package` flags are tested.
2024-07-20 18:31:16 +00:00
Jo
0611c7b59e
Add uv add --no-editable (#5246)
## Summary

Resolves #5241

## Test Plan

```sh
# create a workspace with sub-packages `pkg-a` and `pkg-b`

$ cd ./pkg-b
$ cargo run -- add ./pkg-a --no-editable

$ cat ./pyproject.toml
[project]
name = "pkg-b"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = [
    "pkg-a",
]

[tool.uv]
dev-dependencies = []

[tool.uv.sources]
pkg-a = { workspace = true, editable = false }
```
2024-07-20 09:11:34 -04:00
Ibraheem Ahmed
12dd450a8e
Implement uv init (#4791)
## Summary

Implements the `uv init` command, which initializes a project
(`pyproject.toml`, `README.md`, `src/__init__.py`) in the current
directory, or in the given path. `uv init` also does workspace
discovery.

Resolves https://github.com/astral-sh/uv/issues/1360.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-07-19 15:11:48 +00:00
Charlie Marsh
ed9b820815
Remove trailing period from user-facing messages (#5218)
## Summary

Per #5209, we only show periods in messages when the message itself
spans more than a single sentence.
2024-07-19 10:43:49 -04:00
Charlie Marsh
729148dac9
Add --frozen to uv add, uv remove, and uv tree (#5214)
## Summary

E.g., `uv add foo --frozen` will avoid updating or even creating a
`uv.lock`.
2024-07-19 13:18:32 +00:00
Charlie Marsh
dfe2faa71e
Add --locked and --frozen to uv run CLI (#5196)
## Summary

You can now use `uv run --locked` to assert that the lockfile doesn't
change, or `uv run --frozen` to run without attempting to update the
lockfile at all.

Closes https://github.com/astral-sh/uv/issues/5185.
2024-07-18 18:55:17 +00:00
Charlie Marsh
36a0ee9822
Remove executable alias; import anstream (#5187)
Post-push review from https://github.com/astral-sh/uv/pull/5160.
2024-07-18 14:09:29 +00:00
Charlie Marsh
622e9e8799
Add uv tool list --show-paths to show install paths (#5164)
## Summary

Closes https://github.com/astral-sh/uv/issues/4823.
2024-07-17 19:11:13 -04:00
Charlie Marsh
82d94838cb
Implement a --verify-hashes hash-checking mode (#4007)
## Summary

This is an alternative to `--require-hashes` which will validate a hash
if it's present, but ignore requirements that omit hashes or are absent
from the lockfile entirely.

So, e.g., transitive dependencies that are missing will _not_ error; nor
will dependencies that are included but lack a hash.

Closes https://github.com/astral-sh/uv/issues/3305.
2024-07-17 21:25:31 +00:00
Charlie Marsh
eb24717a9b
Add uv tool dir --bin to show executable directory (#5160)
## Summary

Closes https://github.com/astral-sh/uv/issues/5159.
2024-07-17 16:30:45 -04:00
konsti
3e93255ac9
Document that --universal implies --no-strip-markers (#5121)
Prompted by
https://github.com/python-trio/trio/pull/3032#discussion_r1679435422.
2024-07-17 15:54:21 +00:00