Commit graph

4903 commits

Author SHA1 Message Date
Zanie Blue
daa8565a75
Bump version to 0.1.10 (#1923) 2024-02-23 11:40:36 -06:00
konsti
62023ead49
Fix uv-created venv detection (#1908)
Read the key read for uv from `pyenv.cfg` from `gourgeist` instead of
`uv`. I missed that we're also reading pyenv.cfg when reviewing #1852.
We could check for gourgeist for backwards compatibility, but i think
it's fine this way.
2024-02-23 11:11:22 -06:00
Zanie Blue
fe1847561c
Retain authentication when making range requests (#1902)
Needs https://github.com/prefix-dev/async_http_range_reader/pull/9
Closes https://github.com/astral-sh/uv/issues/1709
2024-02-23 15:21:10 +00:00
Jonathan Newnham
bd59076b18
Fix windows py spurious stderr failure (#1885)
<!--
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

On Windows `10.0.19045` the `py` command prints to `stderr` even when
working correctly. This means that uv should not treat this as a
failure.

Fixes https://github.com/astral-sh/uv/issues/1904

## Test Plan

I ran the modified code and it worked. I expect the pull request to run
automated tests.
2024-02-23 09:05:56 -06:00
Micha Reiser
829e14769d
Ignore Python 2 installations when querying for interpreters (#1905)
## Summary

Fixes https://github.com/astral-sh/uv/issues/1693

`uv` currently fails when a user has `python` 2 or older installed on
their system without a `python3` or `python3.exe` on their path because
the `get_interpreter_info.py` script fails executing (it uses some
Python 3+ APIs).

This PR fixes this by:

* Returning an explicit error code in `get_interpreter_info` if the
Python version isn't supported
* Skipping over this error in `python_query` if the user requested ANY
python version or a version >= 3.
* Error if the user requested a Python 2 version. 

## Test Plan

Error if the user requests a legacy python version. 

```
uv venv -p 2
  × Python 2 or older is not supported. Please use Python 3 or newer.
```


Ignore any python 2 installation when querying newer python
installations (using v4 here because I have python3 on the path and that
takes precedence over querying python)
```
 uv_interpreter::python_query::find_python selector=Major(4)
      0.005541s   0ms DEBUG uv_interpreter::interpreter Detecting markers for: /home/micha/.pyenv/shims/python
      0.059730s  54ms DEBUG uv_interpreter::python_query Found a Python 2 installation that isn't supported by uv, skipping.
      0.059983s  54ms DEBUG uv_interpreter::interpreter Using cached markers for: /usr/bin/python
  × No Python 4 In `PATH`. Is Python 4 installed?

```
2024-02-23 11:55:38 +01:00
Charlie Marsh
73ed0f0cf1
Omit --find-links from annotation header unless requested (#1898)
## Summary

Like #1835, but for `--find-links` (for consistency).
2024-02-23 04:05:53 +00:00
Charlie Marsh
3bd4ccad11
Write to stdout when --output-file is present (#1892)
## Summary

This matches `pip-compile` and is, I think, intuitive. If you want to
suppress output, you can always pipe it away.

Closes https://github.com/astral-sh/uv/issues/1895.
2024-02-22 22:29:14 -05:00
Charlie Marsh
eef3ca5367
Add #1835 to the changelog (#1894) 2024-02-23 02:25:21 +00:00
Evgeniy Dubovskoy
a7b5c55d8b
Hide index URLs from header if not emitted (#1835)
## Summary

Hey guys! The motivation described in #1834

## Test Plan

Changed snapshot of the existing tests. `--index-url` and
`--extra-index-url` occur pretty often, so no extra testing is required,
imo.
2024-02-23 01:48:15 +00:00
Charlie Marsh
0212cb72e9
Bump version to v0.1.9 (#1891) 2024-02-23 01:32:48 +00:00
Charlie Marsh
aa73a4f0ea
Add support for config_settings in PEP 517 hooks (#1833)
## Summary

Adds `--config-setting` / `-C` (with a `--config-settings` alias for
convenience) to the CLI.

Closes https://github.com/astral-sh/uv/issues/1460.
2024-02-23 00:53:45 +00:00
Zanie Blue
1103298e6c
Use rustls-tls-native-roots in uv crate (#1888)
I'm confused that we have this separate specification of `reqwests`? I'm
not sure this has any effect, but it seems like it should be done for
correctness.

Follows #1512
2024-02-22 19:46:11 -05:00
Zanie Blue
8a12b2ebf9
Ensure authentication is passed from the index url to distribution files (#1886)
Closes https://github.com/astral-sh/uv/issues/1709
Closes https://github.com/astral-sh/uv/issues/1371

Tested with the reproduction provided in #1709 which gets past the HTTP
401.

Reuses the same copying logic we introduced in
https://github.com/astral-sh/uv/pull/1874 to ensure authentication is
attached to file URLs with a realm that matches that of the index. I had
to move the authentication logic into a new crate so it could be used in
`distribution-types`.

We will want to something more robust in the future, like track all
realms with authentication in a central store and perform lookups there.
That's what `pip` does and it allows consolidation of logic like netrc
lookups. That refactor feels significant though, and I'd like to get
this fixed ASAP so this is a minimal fix.
2024-02-22 18:10:17 -06:00
Zanie Blue
3542a65fd0
Disable fail-fast during CI jobs (#1887)
Rarely is this important, its good to see the status of all the builds
2024-02-22 18:09:11 -05:00
Andrew Gallant
b7942164ee
pep440: fix version ordering (#1883)
A couple moons ago, I introduced an optimization for version comparisons
by devising a format where *most* versions would be represented by a
single `u64`. This in turn meant most comparisons (of which many are
done during resolution) would be extremely cheap.

Unfortunately, when I did that, I screwed up the preservation of
ordering as defined by the [Version Specifiers spec]. I think I messed
it up because I had originally devised the representation so that we
could pack things like `1.2.3.dev1.post5`, but later realized it would
be better to limit ourselves to a single suffix. However, I never
updated the binary encoding to better match "up to 4 release versions
and up to precisely 1 suffix." Because of that, there were cases where
versions weren't ordered correctly. For example, this fixes a bug where
`1.0a2 < 1.0dev2`, even though all dev releases should order before
pre-releases.

We also update a test so that it catches these kinds of bugs in the
future. (By testing all pairs of versions in a sequence instead of just
the adjacent versions.)

[Version Specifiers spec]:
https://packaging.python.org/en/latest/specifications/version-specifiers/#summary-of-permitted-suffixes-and-relative-ordering
2024-02-22 18:01:42 -05:00
Zanie Blue
4f129d2a98
Add changelog (#1881)
Closes #1774
2024-02-22 22:00:13 +00:00
Zanie Blue
8382f711bb
Allow skipping binary builds with no-build label (#1882)
It feels expensive to build binaries on changes where it's not critical.
2024-02-22 15:06:54 -06:00
samypr100
2fa67eae6f
feat: allow passing extra config k,v pairs for pyvenv.cfg when creating a venv (#1852)
<!--
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

This modifies `gourgeist` to allow passing additional k,v pairs to add
to the `pyvenv.cfg` file as proposed in #1697.
I made it allow an arbitrary set of pairs (to decouple from `uv` since
this is mainly a change to `gourgeist`) , but I can slim it down to just
allow just a name and version strings if that's desired.

The `pyvenv.cfg` will also have a `uv = <uv-crate-version>` when a venv
is created via `uv venv` ~~and `uv-build = <uv-build-crate-version>`
when it's created via `SourceBuild::setup`~~.

Example below via `uv venv`:

```ini
home = ...
implementation = CPython
version_info = 3.12
include-system-site-packages = false
base-prefix = ...
base-exec-prefix = ...
base-executable = ...
uv = 0.1.6
prompt = uv
```

Open to any suggestions, thanks!

Closes #1697 

## Test Plan

Added new test in `tests/venv.rs` called `verify_pyvenv_cfg` to verify
that it contains the right uv version string. I didn't see tests
configured in `gourgeist` itself, so I didn't add any there.
2024-02-22 20:39:37 +01:00
Zanie Blue
f0b39a36b4
Bump version to 0.1.8 (#1880) 2024-02-22 13:11:58 -06:00
Zanie Blue
54ddd0bd02
Avoid displaying "root" package when formatting terms (#1871)
We don't have test coverage for this, but a term can reference an
incompatibility with root and then we'll display the internal 'root'
package to the user.

Raised in https://github.com/astral-sh/uv/issues/1855
2024-02-22 18:04:19 +00:00
Zanie Blue
86052fba08
Retain authentication attached to URLs when making requests to the same host (#1874)
Closes https://github.com/astral-sh/uv/issues/1860


In https://github.com/astral-sh/uv/pull/1816, we started using the URL
attached to a response instead of the request URL for subsequent
requests — this fixes various bugs but has the side-effect of dropping
credentials from the URL. Here, we transfer credentials from the request
URL to the response URL. We perform RFC compliant checks for safety.
2024-02-22 17:56:38 +00:00
Charlie Marsh
6afbb02798
Allow duplicate URLs that resolve to the same canonical URL (#1877)
Closes https://github.com/astral-sh/uv/issues/1865.

Closes https://github.com/astral-sh/uv/issues/1866.
2024-02-22 16:44:36 +00:00
Micha Reiser
12a96ad422
Win Trampoline: Use Python executable path encoded in binary (#1803) 2024-02-22 16:10:02 +01:00
Bas Zalmstra
4e011b305f
fix: expose types to implement custom ResolverProvider (#1862)
<!--
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

To integrate `uv` into `pixi` I need to specify a custom
`ResolverProvider` to be able to specify that some packages are already
installed by conda and should not be touched. However, some of the types
required to implement your own `ResolverProvider` were not accessible
through the public API. This PR basically adds them.

## Test Plan

I didnt add an explicit test for this.
2024-02-22 08:59:03 -06:00
konsti
e97b094bc9
Add musl to python bootstrapping script (#1758)
Previously, only glibc builds were tracked in the bootstrap script. A
new field `libc` tracks if `gnu` or `musl` are used on linux, while it
is `"none"` everywhere else. I've confirmed that the updated script
works on ubuntu and alpine.
2024-02-22 10:46:48 +01:00
konsti
af06a6fe0a
Use more universal windows install instructions (#1811)
Recommend installing uv on windows with

```
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
```

instead of

```
irm https://astral.sh/uv/install.ps1 | iex
```

to support installing on cmd.exe, the classic non-powershell windows
command prompt.

See https://github.com/axodotdev/cargo-dist/issues/458 for background.
This will also be included in the next cargo-dist release.

I have confirmed this passes on
 * Command Prompt
 * Windows PowerShell
 * PowerShell
 * git bash

Closes #1750

CC @12932 this fixes the uv command prompt installation.
2024-02-22 09:25:33 +00:00
Micha Reiser
9f3ccf7fe1
Search PATH when python can't be found with py (#1711) 2024-02-22 08:47:33 +01:00
Charlie Marsh
12462e5730
Bump version to v0.1.7 (#1851) 2024-02-21 22:31:23 -05:00
Jane Lewis
da3a7ec801
Linker copies files as a fallback when ref-linking fails (#1773)
## Summary

Fixes #1444.

In situations where the installer fails to perform a reflink, a regular
file copy is also attempted, as a fallback. This circumvents issues with
linking files across filesystems or volumes.

## Test Plan
N/A
2024-02-21 21:57:31 -05:00
Charlie Marsh
1652844bd3
Don't expect pinned packages for editables with non-existent extras (#1847)
Closes https://github.com/astral-sh/uv/issues/1787.
2024-02-22 02:55:56 +00:00
Zanie Blue
d80eee1f8c
Add docs for git authentication (#1844)
[Rendered](https://github.com/astral-sh/uv/blob/zb/auth-docs/README.md#git-authentication)

Adds docs for
- #1781 
- #1717
2024-02-21 21:30:11 -05:00
Charlie Marsh
7eaed07f6c
Move conflicting dependencies into PubGrub (#1796)
## Summary

This revives a PR from long ago
(https://github.com/astral-sh/uv/pull/383 and
https://github.com/zanieb/pubgrub/pull/24) that modifies how we deal
with dependencies that are declared multiple times within a single
package.

To quote from the originating PR:

> Uses an experimental pubgrub branch (#370) that allows us to handle
multiple version ranges for a single dependency to the solver which
results in better error messages because the derivation tree contains
all of the relevant versions. Previously, the version ranges were merged
(by us) in the resolver before handing them to pubgrub since only one
range could be provided per package. Since we don't merge the versions
anymore, we no longer give the solver an empty range for conflicting
requirements; instead the solver comes to that conclusion from the
provided versions. You can see the improved error message for direct
dependencies in [this
snapshot](https://github.com/astral-sh/puffin/pull/383/files#diff-a0437f2c20cde5e2f15199a3bf81a102b92580063268417847ec9c793a115bd0).

The main issue with that PR was around its handling of URL dependencies,
so this PR _also_ refactors how we handle those. Previously, we stored
URL dependencies on `PubGrubPackage`, but they were omitted from the
hash and equality implementations of `PubGrubPackage`. This led to some
really careful codepaths wherein we had to ensure that we always visited
URLs before non-URL packages, so that the URL-inclusive versions were
included in any hashmaps, etc. I considered preserving this approach,
but it would require us to rely on lots of internal details of PubGrub
(since we'd now be relying on PubGrub to merge those packages in the
"right" order).

So, instead, we now _always_ set the URL on a given package, whenever
that package was _given_ a URL upfront. I think this is easier to reason
about: if the user provided a URL for `flask`, then we should just
always add the URL for `flask`. If we see some other URL for `flask`, we
error, like before. If we see some unknown URL for `flask`, we error,
like before.

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

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

Closes https://github.com/astral-sh/uv/issues/1615.
2024-02-21 21:27:58 -05:00
samypr100
b3be53bb46
[docs] Update README.md to include extras example (#1806)
## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
There was no example of to hint support for extras in the README.md.

I added one example in the install section that is used in the uv tests.
2024-02-21 20:13:07 -06:00
Charlie Marsh
831ab457f7
Treat ARM wheels as higher-priority than universal (#1843)
## Summary

We need to take care to keep wheel tags in "priority order" (e.g., we
should prefer ARM wheels over universal wheels). However... it looks
like we've had a `.sort()` in here all along, that risks throwing off
the ordering?

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

## Test Plan

ensure that `rlax` uses the ARM wheel rather than the universal wheel:

- `cargo run venv`
- `cargo run pip install rlax`
- `import rlax`
2024-02-22 01:38:56 +00:00
Zanie Blue
10be62e9d3
Improve error message when git ref cannot be fetched (#1826)
Follow-up to #1781 improving the error message when a ref cannot be
fetched
2024-02-22 01:22:00 +00:00
samypr100
f441f8fa9b
docs: update venv activation for windows (#1836)
## Summary

Follow on to PR https://github.com/astral-sh/uv/pull/1811 as part of
issue https://github.com/astral-sh/uv/issues/1750. This change updates
the windows venv activation to work for both Powershell and Command
Prompt instead of just Powershell. This also aligns with what `uv venv`
displays.
2024-02-21 22:16:40 +00:00
Charlie Marsh
3a34918480
Add fixup for prefect<1.0.0 (#1825)
Closes https://github.com/astral-sh/uv/issues/1798.
2024-02-21 19:47:34 +00:00
Zanie Blue
71ec568d0f
Use git command to fetch repositories instead of libgit2 for robust SSH support (#1781)
Closes https://github.com/astral-sh/uv/issues/1775
Closes https://github.com/astral-sh/uv/issues/1452
Closes https://github.com/astral-sh/uv/issues/1514
Follows https://github.com/astral-sh/uv/pull/1717

libgit2 does not support host names with extra identifiers during SSH
lookup (e.g. [`github.com-some_identifier`](

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/managing-deploy-keys#using-multiple-repositories-on-one-server))
so we use the `git` command instead for fetching. This is required for
`pip` parity.

See the [Cargo
documentation](https://doc.rust-lang.org/nightly/cargo/reference/config.html#netgit-fetch-with-cli)
for more details on using the `git` CLI instead of libgit2. We may want
to try to use libgit2 first in the future, as it is more performant
(#1786).

We now support authentication with:

```
git+ssh://git@<hostname>/...
git+ssh://git@<hostname>-<identifier>/...
```

Tested with a deploy key e.g.

```
cargo run -- \
    pip install uv-private-pypackage@git+ssh://git@github.com-test-uv-private-pypackage/astral-test/uv-private-pypackage.git \
    --reinstall --no-cache -v
```

and

```
cargo run -- \
    pip install uv-private-pypackage@git+ssh://git@github.com/astral-test/uv-private-pypackage.git \
    --reinstall --no-cache -v     
```

with a ssh config like

```
Host github.com
        Hostname github.com
        IdentityFile=/Users/mz/.ssh/id_ed25519

Host github.com-test-uv-private-pypackage
        Hostname github.com
        IdentityFile=/Users/mz/.ssh/id_ed25519
```

It seems quite hard to add test coverage for this to the test suite, as
we'd need to add the SSH key and I don't know how to isolate that from
affecting other developer's machines.
2024-02-21 12:44:32 -06:00
Charlie Marsh
b4bc40627c
Sort output when installing seed packages (#1822)
This output is technically non-deterministic right now.
2024-02-21 18:33:06 +00:00
Micha Reiser
39ee3969d9
Upgrade to Rust 1.76 (#1820) 2024-02-21 17:53:41 +00:00
Andrew Gallant
deef6c102d
platform-host: check /bin/sh, then /bin/dash and then /bin/ls (#1818)
Previously, we were only checking /bin/sh. While that works in most
cases, it seems like there are still scenarios where /bin/sh isn't an
executable itself, and is instead just a shell script that calls
/bin/dash. (See #1810 for example.)

In this PR, we make the `ld` detection a bit more robust by trying
multiple paths. As with previous changes, we emit copious logs to help
debug this in the future.

It's not totally clear how to test this. I'm not sure how to reproduce
the environment mentions in #1810 specifically since it seems like an
internal variant of WSL Ubuntu.

Fixes #1810
2024-02-21 11:49:28 -05:00
Micha Reiser
fac9d843dc
Normalize VIRTUAL_ENV path in activation scripts (#1817) 2024-02-21 15:52:32 +00:00
Charlie Marsh
cff16f5736
Use redirected URL as base for relative paths (#1816)
## Summary

If you review the setup in https://github.com/astral-sh/uv/issues/1747,
when we fetch `http://localhost:8000/simple/wheel/`, it gets redirected
to `http://localhost:8000/index/wheel/`. So any relative paths returned
need to be resolved relative to `http://localhost:8000/index/wheel/`.

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

## Test Plan

- Install `proxpi gunicorn pypiserver`
- `gunicorn proxpi.server:app --bind 0.0.0.0:8000`
- `pypi-server run -p 8080 ~/packages --fallback-url
"http://localhost:8000/index" --verbose`
- `echo "wheel" | cargo run pip compile - --index-url
http://localhost:8080/simple --verbose --no-cache`
2024-02-21 15:10:25 +00:00
Charlie Marsh
c2b75b64d2
Wait for distribution metadata with --no-deps (#1812)
## Summary

We still need to wait for the distribution metadata (for direct
dependencies), even when resolving with `--no-deps`, since we rely on it
to report diagnostics to the user.

Closes https://github.com/astral-sh/uv/issues/1801.
2024-02-21 14:45:09 +00:00
Charlie Marsh
19890feb77
Preserve executable bit when untarring archives (#1790)
## Summary

Closes https://github.com/astral-sh/uv/issues/1767.
2024-02-21 14:18:44 +00:00
Charlie Marsh
88a0c13865
Use async unzip for local source distributions (#1809)
## Summary

We currently maintain separate untar methods for sync and async, but we
only use the sync version when the user provides a local source
distribution. (Otherwise, we untar as we download the distribution.) In
my testing, this is actually slower anyway:

```
❯ python -m scripts.bench \
        --uv-path ./target/release/main \
        --uv-path ./target/release/uv \
        ./requirements.in --benchmark resolve-cold --min-runs 50
Benchmark 1: ./target/release/main (resolve-cold)
  Time (mean ± σ):     835.2 ms ± 107.4 ms    [User: 346.0 ms, System: 151.3 ms]
  Range (min … max):   639.2 ms … 1051.0 ms    50 runs

Benchmark 2: ./target/release/uv (resolve-cold)
  Time (mean ± σ):     750.7 ms ±  91.9 ms    [User: 345.7 ms, System: 149.4 ms]
  Range (min … max):   637.9 ms … 905.7 ms    50 runs

Summary
  './target/release/uv (resolve-cold)' ran
    1.11 ± 0.20 times faster than './target/release/main (resolve-cold)'
```
2024-02-21 14:11:37 +00:00
Charlie Marsh
a2a1b2fb0f
Avoid enforcing URL correctness for installed distributions (#1793)
## Summary

Allows the corresponding `pypi_types` struct to use any URL, since other
installers can put those into the environment, and Poetry seems to write
invalid URLs.

If we see a distribution with an invalid URL, we just treat it as a
registry distribution, which isn't ideal, but is better than (1)
erroring, and (2) changing `Url` to `String` everywhere internally. (I'm
torn on this second option.)

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

## Test Plan

- Added `flask = { git = "git@github.com:pallets/flask.git", rev =
"b90a4f1f4a370e92054b9cc9db0efcb864f87ebe" }` to
`scripts/editable-installs/poetry_editable/pyproject.toml`.
- Ran `poetry install`.
- Ran `cargo pip freeze`. Verified that it errored on `main`, but passed
here.
- Ran `cargo run pip install "flask==3.0.0"`. Verified that it
uninstalled the existing Flask, and installed a new version from the
registry.
2024-02-21 09:06:31 -05:00
konsti
0f520d8716
Configurable bootstrap dir (#1772)
Add a `UV_BOOTSTRAP_DIR` option to configure the python bootstrap
directory. This is helpful when working across multiple platforms in a
single IDE session.
2024-02-21 13:46:23 +01:00
Charlie Marsh
5d53040465
Stream zip archive when fetching non-range-request metadata (#1792)
## Summary

If a registry doesn't support range requests, then today, we download
the entire wheel to disk and then read the metadata from the downloaded
archive. This PR instead modifies the registry client to stream the
zipfile and stop as soon as it's seen the metadata, which should be more
efficient.

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

## Test Plan

Made this the _only_ path for downloading metadata; verified that the
test suite passed.
2024-02-20 22:12:21 -05:00
Evgeniy Dubovskoy
31752bf4be
feat: Implement --annotation-style parameter for uv pip compile (#1679)
## Summary

Hello there! The motivation for this feature is described here #1678 

## Test Plan

I've added unit tests and also tested this manually on my work project
by comparing it to the original `pip-compile` output - it looks much
like the `pip-compile` generated lock file.
2024-02-21 02:08:34 +00:00