Commit graph

4471 commits

Author SHA1 Message Date
konsti
c09edf9854
More specific workspaces recommendation (#8478)
Workspaces should be used over editable installs if the packages are all
part of the same repository.
2024-10-22 20:45:53 -04:00
Ahmed Ilyas
82df00a917
Support --with-editable in uv tool install (#8472)
## Summary

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

## Test Plan

`cargo test`

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2024-10-23 00:06:33 +00:00
Ahmed Ilyas
21b9254949
Suggest --from command when executable is available for uvx (#8473)
## Summary

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

## Test Plan

`cargo test`

<img width="545" alt="Screenshot 2024-10-22 at 20 17 35"
src="https://github.com/user-attachments/assets/286e0168-7f25-4c85-86a3-23c8bb66a5ff">
2024-10-22 14:16:10 -05:00
Zanie Blue
76bcb89571
Use native Windows runner for trampoline checks (#8469)
As in https://github.com/astral-sh/uv/pull/8182 and #8468
2024-10-22 12:28:31 -05:00
Zanie Blue
2f6fa082c4
Add uv-dirs to consolidate directory lookup methods (#8453)
I need the executable directory outside `uv-tool` and figured I should
consolidate these to a central location.
2024-10-22 11:33:25 -05:00
Zanie Blue
dc32b26afb
Replace cargo xwin clippy with native clippy run on Windows again (#8468)
Adds #8181 again

This failure is taking up way too much time and cache misses are feeling
frequent.
2024-10-22 11:28:19 -05:00
Charlie Marsh
ff3ed3b797
Add type-based validation for index names (#8464)
## Summary

Also documents the normalization scheme.
2024-10-22 16:10:20 +00:00
Charlie Marsh
399d5ab50a
Replace dashes with underscores in index credential variables (#8452)
## Summary

Closes https://github.com/astral-sh/uv/issues/8448.
2024-10-22 09:37:55 -04:00
konsti
9a8ff85083
Don't build the maturin test (#8447) 2024-10-22 12:17:28 +00:00
konsti
e7ae0f50d2
Respect allow insecure host in publish (#8440) 2024-10-22 13:36:18 +02:00
konsti
614013ed58
Add help page for build failures (#8286) 2024-10-22 13:35:54 +02:00
konsti
0dd4d017e3
Link to Dependency specifiers instead of PEP 508 (#8411)
The canonical source is
https://packaging.python.org/en/latest/specifications/dependency-specifiers/,
not PEP 508 anymore, so we should link there and use the new name.
2024-10-21 14:43:38 -04:00
Ben Beasley
40f842df09
Switch from a git snapshot to released rust-netrc 1.1.2 (#8424)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Before this PR (and since 651fe6f4e6) `uv`
depends on a git snapshot of `rust-netrc` at
544f3890b6,
with fixes from https://github.com/gribouille/netrc/pull/3 for
https://github.com/astral-sh/uv/issues/8003.

Since `rust-netrc` 0.1.2 was just released, and it includes those fixes
– plus an additional [change to support
`~`-expansion](ca0860c0a0)
– `uv` can go back to depending on published crates from crates.io.

## Test Plan

<!-- How was it tested? -->

```
$ cargo build
$ cargo run python install
$ cargo test
```

I get

```

────────────────────────────────────────────────────────────────────────────────

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: sha
Source: crates/uv/tests/it/build.rs:1454
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Expression: snapshot
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   11    11 │ writing top-level names to src/project.egg-info/top_level.txt
   12    12 │ writing manifest file 'src/project.egg-info/SOURCES.txt'
   13    13 │ reading manifest file 'src/project.egg-info/SOURCES.txt'
   14    14 │ writing manifest file 'src/project.egg-info/SOURCES.txt'
         15 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         16 │+  import pkg_resources
   15    17 │ running sdist
   16    18 │ running egg_info
   17    19 │ writing src/project.egg-info/PKG-INFO
   18    20 │ writing dependency_links to src/project.egg-info/dependency_links.txt
┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
   35    37 │ copying src/project.egg-info/top_level.txt -> project-0.1.0/src/project.egg-info
   36    38 │ Writing project-0.1.0/setup.cfg
   37    39 │ Creating tar archive
   38    40 │ removing 'project-0.1.0' (and everything under it)
         41 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         42 │+  import pkg_resources
   39    43 │ Building wheel from source distribution...
   40    44 │ running egg_info
   41    45 │ writing src/project.egg-info/PKG-INFO
   42    46 │ writing dependency_links to src/project.egg-info/dependency_links.txt
   43    47 │ writing requirements to src/project.egg-info/requires.txt
   44    48 │ writing top-level names to src/project.egg-info/top_level.txt
   45    49 │ reading manifest file 'src/project.egg-info/SOURCES.txt'
   46    50 │ writing manifest file 'src/project.egg-info/SOURCES.txt'
         51 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         52 │+  import pkg_resources
   47    53 │ running bdist_wheel
   48    54 │ running build
   49    55 │ running build_py
   50    56 │ creating build
┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
   73    79 │ adding 'project-0.1.0.dist-info/WHEEL'
   74    80 │ adding 'project-0.1.0.dist-info/top_level.txt'
   75    81 │ adding 'project-0.1.0.dist-info/RECORD'
   76    82 │ removing build/bdist.linux-x86_64/wheel
         83 │+[CACHE_DIR]/builds-v0/[TMP]/pkg_resources.html
         84 │+  import pkg_resources
   77    85 │ Successfully built dist/project-0.1.0.tar.gz and dist/project-0.1.0-py3-none-any.whl
────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'build::sha' panicked at /home/ben/.cargo/registry/src/index.crates.io-6f17d22bba15001f/insta-1.40.0/src/runtime.rs:548:9:
snapshot assertion for 'sha' failed in line 1454
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    build::sha

test result: FAILED. 1299 passed; 1 failed; 4 ignored; 0 measured; 0 filtered out; finished in 101.18s

error: test failed, to rerun pass `-p uv --test it`
```

The sole failure looks unrelated to me, and I can reproduce it on `main`
(currently e8b8daf0fb), so I conclude that
it has nothing to do with this change.
2024-10-21 14:43:07 -04:00
Charlie Marsh
e8b8daf0fb
Fix cache-keys typo in tags = true (#8422)
Closes https://github.com/astral-sh/uv/issues/8421.
2024-10-21 17:35:22 +00:00
Amjith Ramanujam
351ad84eaf
Add support for system-level uv.toml configuration (#7851)
## Summary

Look for a system level uv.toml config file under `/etc/uv/uv.toml` or
`C:\ProgramData`.

This PR is to address #6742 and start a conversation. 

## Test Plan

This was tested locally manually on MacOS. I am happy to contribute
tests once we settle on the approach.

cc @thatch

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-21 17:33:02 +00:00
kkdamowang
ec8eee0fde
Fix navigators in crates/README.md (#8408) 2024-10-21 10:45:07 +02:00
Charlie Marsh
3542251c76
Apply narrowing with upper bounds (#8403)
## Summary

If the user has an upper-bound in a `requires-python`, we don't
correctly narrow it during resolution. We should be narrowing based on
the intersection.

Closes #8297.
2024-10-21 01:03:50 +00:00
Charlie Marsh
97eb6ab4aa
Bump version to v0.4.25 (#8402) 2024-10-21 00:37:50 +00:00
renovate[bot]
451e3578ca
Update Rust crate syn to v2.0.82 (#8400) 2024-10-21 00:18:58 +00:00
renovate[bot]
13ba40493e
Update pre-commit dependencies (#8401) 2024-10-21 00:18:36 +00:00
renovate[bot]
a372c8117f
Update Rust crate proc-macro2 to v1.0.88 (#8398) 2024-10-21 00:14:02 +00:00
renovate[bot]
4d2f31cb75
Update Rust crate serde_json to v1.0.132 (#8399) 2024-10-21 00:13:41 +00:00
renovate[bot]
12fbd37cd0
Update Rust crate async-compression to v0.4.17 (#8396) 2024-10-21 00:12:40 +00:00
renovate[bot]
159b664f95
Update Rust crate anyhow to v1.0.90 (#8395) 2024-10-21 00:10:22 +00:00
Alexander Gherm
823ee8fcb0
Modify pip list and tree to print to stdout regardless of the --quiet flag (#8392)
## Summary

The desired behavior for `uv tree` and `uv pip list` with `-q | --quiet`
flag is
https://github.com/astral-sh/uv/issues/8379#issuecomment-2425093709 to
still produce output. This is implemented here.

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

## Test Plan

Use `uv tree -q` or `uv pip list -q` on any uv project setup and expect
the corresponding output.
Added tests for that as well.

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-20 23:24:34 +00:00
Charlie Marsh
6ff674f5bf
Use correct indentation when project table contains open bracket comment (#8387)
## Summary

Now, we use four space (rather than one space) for cases like:

```toml
dependencies = [ # comment 0
    # comment 1
    "anyio==3.7.0", # comment 2
    # comment 3
]
```
2024-10-20 15:56:36 -04:00
Charlie Marsh
7e2822d694
Avoid panic when Git dependencies are included in fork markers (#8388)
## Summary

Rather than relying on the distribution and package URL being the same
(which isn't true for Git dependencies), we can just use the
intersection of the markers directly.

Closes https://github.com/astral-sh/uv/issues/8381.
2024-10-20 18:42:21 +00:00
Zanie Blue
ab16bf0a8c
Set UV_LINK_MODE=copy for Windows test runs (#8350)
Cherry-picked from #8347 

Might fix https://github.com/astral-sh/uv/issues/6940 — I'm not seeing a
failure over there after this change. I think there may be some problem
with concurrent reads of junctioned files on the DevDrive? It's really
hard to say.

We might lose some important test coverage with this change. I'm not
sure what to do about that either.
2024-10-20 13:37:41 -05:00
Zanie Blue
be26e47d2f
Log unfiltered snapshots on failure (#8349)
Cherry-picked from https://github.com/astral-sh/uv/pull/8347

Seems generally really helpful to see the unfiltered snapshot when a
test fails. Especially when debugging filters on Windows.
2024-10-20 13:37:29 -05:00
InSync
93f3316c88
Fix typos in new uv self help messages (#8376)
[Originally
reported](1297405236)
by dice on Discord.
2024-10-20 13:20:04 -04:00
Alexander Gherm
20053f3aa7
Fix to respect comments positioning in pyproject.toml on change (#8384)
## Summary

This PR is is to address the problem when the same-line comments in
`pyproject.toml` could be found in unpredictable positions after `uv
add` or `remove` reformats the `pyproject.toml` file.

Introduced the `Comment` structure in `pyproject_mut` module to
distinguish "same-line" comments and "full-line" comments while
reformatting, because logic for them differs.
Sorry, the implementation could be clumsy, I'm just learning Rust, but
it seems to work 😅

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

## Test Plan

Added the new test:
`add_preserves_comments_indentation_and_sameline_comments`

To test followed the actions from the issue ticket
https://github.com/astral-sh/uv/issues/8343

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-10-20 17:16:13 +00:00
Charlie Marsh
e9f1161b95
Modify cache versioning to support backwards compatibility (#8386)
## Summary

Going forward, we're going to provide better versioning guarantees
around using the same cache across multiple uv versions, so this PR
updates the docs to reflect that. It also bumps the `sdists-` version to
fix the inconvenience demonstrated in
https://github.com/astral-sh/uv/issues/8367.

Closes https://github.com/astral-sh/uv/issues/8367.
2024-10-20 16:48:04 +00:00
Jo
842ef12017
Log netrc parsing error (#8364)
## Summary

Resolves #7685

## Test Plan

```console
$ echo "this is an invalid netrc" > .netrc
$ NETRC=.netrc cargo run -- pip install anyio --index-url https://pypi-proxy.fly.dev/basic-auth/simple --strict -v
DEBUG uv 0.4.24 (f4d5fba61 2024-10-19)
DEBUG Searching for default Python interpreter in system path or `py` launcher
DEBUG Found `cpython-3.11.2-windows-x86_64-none` at `D:\Projects\Rust\uv\.venv\Scripts\python.exe` (virtual environment)
DEBUG Using Python 3.11.2 environment at .venv
DEBUG Acquired lock for `.venv`
DEBUG At least one requirement is not satisfied: anyio
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.11.2
DEBUG Solving with target Python version: >=3.11.2
DEBUG Adding direct dependency: anyio*
DEBUG No cache entry for: https://pypi-proxy.fly.dev/basic-auth/simple/anyio/
WARN Error reading netrc file: parsing error: bad toplevel token 'this' (line 1) in the file '.netrc'
DEBUG Searching for a compatible version of anyio (*)
DEBUG No compatible version found for: anyio
  × No solution found when resolving dependencies:
  ╰─▶ Because anyio was not found in the package registry and you require anyio, we can conclude that your
      requirements are unsatisfiable.

      hint: An index URL (https://pypi-proxy.fly.dev/basic-auth/simple) could not be queried due to a lack of valid
      authentication credentials (401 Unauthorized).
DEBUG Released lock at `D:\Projects\Rust\uv\.venv\.lock`
error: process didn't exit successfully: `target\debug\uv.exe pip install anyio --index-url https://pypi-proxy.fly.dev/basic-auth/simple --strict -v` (exit code: 1)

```
2024-10-20 12:27:44 -04:00
Zanie Blue
fff2094a35
Use a dedicated message for incompatible Python versions in wheel ABI tags (#8363)
Part of https://github.com/astral-sh/uv/issues/2777

I noticed we're seeing "Python ABI" _a lot_ in error messages which I
did not expect. This improves a common case by being a little more
specific.
2024-10-20 12:14:11 -04:00
Jo
bcc52ed108
Add uv pip show --files (#8369)
## Summary

Resolves #8357
2024-10-20 12:13:41 -04:00
Zanie Blue
05a56dab61
Copy the workspace examples into test contexts (#8348)
Cherry-picked from https://github.com/astral-sh/uv/pull/8347

Per [this
flake](3175705352)
it doesn't solve the problem unfortunately. Still seems like best
practice.
2024-10-20 12:11:52 -04:00
Jo
e980c1b0f8
Only remove a source from [tool.uv.sources] if it is no long being referenced (#8366)
## Summary

Resolves #8361
2024-10-19 10:52:01 -05:00
Jo
ca55793a90
Remove tool.uv.sources table if it is empty (#8365)
## Summary

Resolves #8362
2024-10-19 15:20:45 +00:00
Zanie Blue
4355392c82
Add a uv remove test where a dependency is repeated (#8360) 2024-10-19 14:33:54 +00:00
Jo
ac451af1bd
Check existing source by normalized name before add and remove (#8359)
Resolves #8328
Resolves #8330
2024-10-19 08:26:01 -05:00
Zanie Blue
4b0a4dadb7
Fix bug where username from authentication cache could be ignored (#8345)
Basically, if username-only authentication came from the _cache_ instead
of being present on the _request URL_ to start, we'd end up ignoring it
during password lookups which breaks keyring.

Includes some cosmetic changes to the logging and commentary in the
middleware, because I was confused when reading the code and logs.
2024-10-18 18:45:31 -05:00
konsti
e26eed10e4
Better missing self update feature (#8337) 2024-10-18 17:38:34 +00:00
Charlie Marsh
d53d580221
Add support for UV_FROZEN and UV_LOCKED (#8340)
## Summary

Closes https://github.com/astral-sh/uv/issues/8321.
2024-10-18 13:37:49 -04:00
Vini Brasil
69d5e084d5
Allow dashes and underscores in custom index names (#8339)
Previously, `uv add --index` command threw an error when the index name
included characters like hyphens or underscores.

Closes #8315
2024-10-18 13:24:16 -04:00
konsti
c162078050
Add cfg for other external resources tests (#8320)
Fixes #8295
2024-10-18 12:30:11 -04:00
Zanie Blue
42dac85bf7
Remove commands available in the top-level from the suggested subcommand error (#8316)
Part of https://github.com/astral-sh/uv/issues/8313

I think we'll need to open an issue upstream to add more context to the
error here, because there's not sufficient information about the parent
command to provide a good error message. As a first step, let's avoid
giving these suggestions for subcommands that overlap with our top-level
commands.. because that's just confusing.

Here's all the information we have here

```rust
[crates/uv/src/lib.rs:1530:13] &err = ErrorInner {
    kind: InvalidSubcommand,
    context: FlatMap {
        keys: [
            InvalidSubcommand,
            Usage,
        ],
        values: [
            String(
                "remove",
            ),
            StyledStr(
                StyledStr(
                    "\u{1b}[1m\u{1b}[32mUsage:\u{1b}[0m \u{1b}[1m\u{1b}[36muv python\u{1b}[0m \u{1b}[36m[OPTIONS]\u{1b}[0m \u{1b}[36m<COMMAND>\u{1b}[0m",
                ),
            ),
        ],
    },
    message: None,
    source: None,
    help_flag: Some(
        "--help",
    ),
    styles: Styles {
        header: Style {
            fg: Some(
                Ansi(
                    Green,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        error: Style {
            fg: Some(
                Ansi(
                    Red,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        usage: Style {
            fg: Some(
                Ansi(
                    Green,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        literal: Style {
            fg: Some(
                Ansi(
                    Cyan,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(BOLD),
        },
        placeholder: Style {
            fg: Some(
                Ansi(
                    Cyan,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(),
        },
        valid: Style {
            fg: Some(
                Ansi(
                    Green,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(),
        },
        invalid: Style {
            fg: Some(
                Ansi(
                    Yellow,
                ),
            ),
            bg: None,
            underline: None,
            effects: Effects(),
        },
    },
    color_when: Auto,
    color_help_when: Auto,
    backtrace: None,
}
```
2024-10-18 10:57:07 -05:00
konsti
6b8f447387
Make lock_multiple_sources stable over time (#8336) 2024-10-18 15:51:51 +00:00
Charlie Marsh
a459052f44
Redact index sources in uv.lock (#8333)
## Summary

Closes https://github.com/astral-sh/uv/issues/8296.
2024-10-18 11:20:15 -04:00
konsti
23c80c547c
Remove trailing newlines in error messages (#8322) 2024-10-18 17:17:41 +02:00
Zanie Blue
d296e7270a
Run release builds for macos-x86_64 on macos-14 runners (#8327) 2024-10-18 11:01:52 -04:00