Commit graph

1989 commits

Author SHA1 Message Date
Charlie Marsh
c666e43b90
Move dry-run method to the top-level (#3567)
Trying to pull out some small, no-op refactors.
2024-05-14 02:28:39 +00:00
konsti
025368965e
Reduce GitSourceDist URL usage (#3458)
Refactor the easy-to-remove usage of the `VerbatimUrl` on
`GitSourceDist`
2024-05-14 02:03:55 +00:00
Charlie Marsh
66eea7a5fb
Remove unused installed field from Plan (#3566) 2024-05-14 01:53:48 +00:00
konsti
b263fcff9c
Preserve parsed url in ResolvedDist -> Requirement (#3457)
Lose less information in the `ResolvedDist` -> `Requirement` conversion.
2024-05-14 01:47:20 +00:00
konsti
a24124571a
Use the term path instead of local file consistently (#3430)
Rename `ParsedLocalFileUrl` to `ParsedPathUrl`, eliminating the term
`LocalFile` in favor of path.
2024-05-14 01:35:52 +00:00
Charlie Marsh
325265ec16
Move pip commands into their own module (#3565)
## Summary

Matching the structure of the `project` module and API.
2024-05-14 01:34:14 +00:00
konsti
c22c7cad4c
Add parsed URL fields to Dist variants (#3429)
Avoid reparsing urls by storing the parsed parts across resolution on
`Dist`.

Part 2 of https://github.com/astral-sh/uv/issues/3408 and part of #3409

Closes #3408
2024-05-14 01:23:27 +00:00
konsti
0010954ca7
Add parsed URL to PubGrubPackage (#3426)
Avoid reparsing urls by storing the parsed parts across resolution on
`PubGrubPackage`.

Part 1 of #3408
2024-05-14 00:55:21 +00:00
Charlie Marsh
5132c6a6e2
Bump version to v0.1.43 (#3564) 2024-05-14 00:38:11 +00:00
Charlie Marsh
8cec217eff
Avoid attempting to build editables when fetching metadata (#3563)
## Summary

If we see an editable as a dependency, we currently attempt to fetch its
metadata, when we shouldn't.

Closes https://github.com/astral-sh/uv/issues/3562.
2024-05-14 00:03:53 +00:00
Zanie Blue
88069e1c43
Add test case demonstrating failure with --only-binary and dependent editables (#3561)
As discussed at
https://github.com/astral-sh/uv/issues/3513#issuecomment-2108572246

See https://github.com/astral-sh/uv/issues/3562
2024-05-13 19:55:28 -04:00
Charlie Marsh
7ed14fa124
Make isolated a global argument (#3558)
Closes https://github.com/astral-sh/uv/issues/3557.
2024-05-13 17:51:32 +00:00
Charlie Marsh
44363d25c2
Respect constraints on editable dependencies (#3554)
## Summary

Ensures that constraints are enforced for editable requirements.

Closes #3548.
2024-05-13 17:06:27 +00:00
Charlie Marsh
10ec48299e
Add a PubGrubRequirement struct (#3553)
## Summary

Formalize some of the patterns in here. No behavior changes, just moving
this method onto a struct.
2024-05-13 16:59:10 +00:00
Charlie Marsh
eb8e733790
Rename "constraints" to "dependencies" in resolver (#3552)
## Summary

It's confusing that we use `constraints` here because constraints mean
something else for us (e.g., `--constraint constraints.txt`). These are
really the dependencies of a given `PubGrubPackage` -- the type is even
called `PubGrubDependencies`.
2024-05-13 16:30:16 +00:00
samypr100
790206beb1
feat: speed up windows jobs using ReFS (#3522)
## Summary

Switch to using Virtual HD + ReFS to speed up windows jobs.

Closes #3508
2024-05-13 11:15:54 -05:00
Bas Schoenmaeckers
1218766ea5
Clone individual files on windows ReFS (#3551)
Windows does not support cloning whole directories so clone each file
instead.

closes #3547 

## Test Plan

Ran ` uv pip install setuptools --link-mode=clone` manually
2024-05-13 12:03:39 -04:00
Zanie Blue
b596b460a8
Increase verbosity of credential fetch logs (#3550)
So users do not need to turn on trace logging to see fetch results e.g.
https://github.com/astral-sh/uv/issues/3542

This is more reasonable now that we cache fetches.
2024-05-13 15:55:57 +00:00
Charlie Marsh
9a92a3ad37
Apply advisory locks when building source distributions (#3525)
## Summary

I don't love this, but it turns out that setuptools is not robust to
parallel builds: https://github.com/pypa/setuptools/issues/3119. As a
result, if you run uv from multiple processes, and they each attempt to
build the same source distribution, you can hit failures.

This PR applies an advisory lock to the source distribution directory.
We apply it unconditionally, even if we ultimately find something in the
cache and _don't_ do a build, which helps ensure that we only build the
distribution once (and wait for that build to complete) rather than
kicking off builds from each thread.

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

## Test Plan

Ran:

```sh
#!/bin/bash
make_venv(){
    target/debug/uv venv $1
    source $1/bin/activate
    target/debug/uv pip install opentracing --no-deps --verbose
}

for i in {1..8}
do
   make_venv ./$1/$i &
done
```
2024-05-13 10:42:20 -04:00
Charlie Marsh
42c3bfa351
Make Directory its own distribution kind (#3519)
## Summary

I think this is overall good change because it explicitly encodes (in
the type system) something that was previously implicit. I'm not a huge
fan of the names here, open to input.

It covers some of https://github.com/astral-sh/uv/issues/3506 but I
don't think it _closes_ it.
2024-05-13 10:03:14 -04:00
Zanie Blue
6bbfe555be
Add test case for --only-binary with editable requirement (#3521) 2024-05-13 14:00:11 +00:00
Dimitri Papadopoulos Orfanos
d2ee567fe7
Fix a few typos found by codespell (#3543)
<!--
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

Just fix typos.

While `alpha-numeric` is not really a misspelling:
- it is missing from mainstream curated dictionaries, all of them
suggest `alphanumeric`;
- it is less used than `alphanumeric` (more than ⨉10 less) according to
the Google [Ngram
Viewer](https://books.google.com/ngrams/graph?content=alpha-numeric%2Calphanumeric&year_start=1900&year_end=2019&corpus=en-2019);
- it is [missing from
SCOWL](http://app.aspell.net/lookup?dict=en_US-large;words=alpha-numeric).

## Test Plan

CI jobs.
2024-05-13 11:55:10 +00:00
Charlie Marsh
106c3b583c
Add HTTPS and SSH hints to scheme error (#3536)
Closes https://github.com/astral-sh/uv/issues/3483.
2024-05-13 02:14:58 +00:00
Charlie Marsh
b6f6f58831
Fix cfg_attr ignore for macOS (#3535) 2024-05-13 01:53:04 +00:00
Charlie Marsh
aa6b853d78
Run cargo shear in CI (#3534) 2024-05-12 21:44:58 -04:00
Charlie Marsh
e0da977fc9
Get cargo shear passing (#3533)
## Summary

Remove a few unused deps, and ignore `flate2` (which we include for
feature control).
2024-05-13 01:43:45 +00:00
renovate[bot]
84602c467b
Update Rust crate async-channel to v2.3.0 (#3532) 2024-05-13 01:30:55 +00:00
Fred Stober
457d4526fa
Update activate_this.py to use runpy instead of exec in the docstring (#3442)
## Summary

runpy.run_path was added in python 2.7 and 3.2 - and every python that
is not EOL supports it.

It is arguably nicer to read and the path is only given once in the
command.

At least right now, runpy - unlike exec with S102 - is not flagged by
any bandit-derived ruff check.
(I guess because it loads from a file instead of a simple string...)

Because of the import, it is also not a one-liner anymore. (But that
could be fixed with an __import__('runpy').run_path...)

## Test Plan

import runpy
runpy.run_path('/path/to/venv/bin/activate_this.py')
2024-05-13 01:21:24 +00:00
renovate[bot]
a81752a0cf
Update Rust crate zip to v1.2.3 (#3530) 2024-05-12 20:17:34 -04:00
renovate[bot]
c5528a5384
Update pre-commit dependencies (#3531) 2024-05-12 20:17:29 -04:00
renovate[bot]
3422bea1a7
Update Rust crate axoupdater to v0.6.2 (#3529) 2024-05-12 20:17:18 -04:00
Charlie Marsh
c2452957f9
Remove unused dependencies (#3527)
Surfaced with `cargo shear`.
2024-05-11 13:33:49 -04:00
Charlie Marsh
2c3a6796aa
Remove unused seek methods (#3526) 2024-05-11 17:31:32 +00:00
Charlie Marsh
3b728c16cc
Make cache clearing robust to directories without read permissions (#3524)
## Summary

If you run the script included in the linked issue, then `uv cache
clean`, we hit permissions errors on certain directories created by
`setuptools`. The permissions on those directories look like:

```
❯ sudo ls -l /Users/crmarsh/Library/Caches/uv/built-wheels-v3/pypi/opentracing/2.4.0/M-fYsaHAaQQvedmPMUl9D/opentracing-2.4.0.tar.gz/build/bdist.macosx-14.2-arm64/wheel/opentracing
Password:
total 0
drwxr-xr-x  3 crmarsh  staff  96 May 11 12:51 harness
```

This PR adds logic to make those directories readable by the current
user.

Closes https://github.com/astral-sh/uv/issues/3515.
2024-05-11 17:02:25 +00:00
Henry Schreiner
df43dc9e70
ci: build musllinux_1_1 wheels (#3523)
This is needed to include uv in manylinux, which has both the
musllinux_1_1 and musllinux_1_2 images.

## Summary

We are looking into including uv in the `pypa/manylinux` docker images,
so that cibuildwheel will be able to use it. But to do so, we need all
actively supported images to be able to take it, including
musllinux_1_1.

## Test Plan

The test was updated to make sure Alpine 3.12, which musllinux was based
on, can run uv.

The binary build does need to be triggered on this PR to make sure it
works. Ah,
5b6040184d/.github/workflows/build-binaries.yml (L15-L20)
is a good idea, nice.

Will need a followup to fill out the other platforms `pypa/manylinux`
supports for musllinux.

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2024-05-11 12:35:40 -04:00
Charlie Marsh
1ba3414dd6
Avoid keyword arguments for PEP 517 build hooks (#3517)
## Summary

pip passes these as positional arguments, and at least one build backend
relies on that. My personal opinion is that it's a spec violation, and
the build backend should be updated, but I'd prefer to favor
compatibility over strictness here.

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

## Test Plan

`cargo run pip install cryptacular==1.6.2`
2024-05-10 17:15:08 -04:00
konsti
45a2594de6
Allow unknown pyproject.toml fields (#3511)
Fixes #3510, we use typo error messages though.

Tested manually by adding `[tool.uv.pip]`, we should add proper tests
for this feature.
2024-05-10 18:50:24 +00:00
Ibraheem Ahmed
783df8f657
Consolidate concurrency limits (#3493)
## Summary

This PR consolidates the concurrency limits used throughout `uv` and
exposes two limits, `UV_CONCURRENT_DOWNLOADS` and
`UV_CONCURRENT_BUILDS`, as environment variables.

Currently, `uv` has a number of concurrent streams that it buffers using
relatively arbitrary limits for backpressure. However, many of these
limits are conflated. We run a relatively small number of tasks overall
and should start most things as soon as possible. What we really want to
limit are three separate operations:
- File I/O. This is managed by tokio's blocking pool and we should not
really have to worry about it.
- Network I/O.
- Python build processes.

Because the current limits span a broad range of tasks, it's possible
that a limit meant for network I/O is occupied by tasks performing
builds, reading from the file system, or even waiting on a `OnceMap`. We
also don't limit build processes that end up being required to perform a
download. While this may not pose a performance problem because our
limits are relatively high, it does mean that the limits do not do what
we want, making it tricky to expose them to users
(https://github.com/astral-sh/uv/issues/1205,
https://github.com/astral-sh/uv/issues/3311).

After this change, the limits on network I/O and build processes are
centralized and managed by semaphores. All other tasks are unbuffered
(note that these tasks are still bounded, so backpressure should not be
a problem).
2024-05-10 12:43:08 -04:00
Andrew Gallant
eab2b832a6
uv-resolver: make hashes optional (#3505)
This only makes hashes optional for wheels/sdists that come from
registires or direct URLs. For wheels/sdists that come from other
sources, a hash should not be present.

For path dependencies, a hash should not be present because the state of
the path dependency is not intended to be tracked in the lock file. This
is consistent with how other tools deal with path dependencies, and if
it were otherwise, the hash would I believe need to be updated for every
change to the path dependency.

For git dependencies (source dists only), a hash should not be present
because the lock will contain the specific commit revision hash. This is
functionally equivalent to a hash, and so a hash is redundant.

As part of this change, we validate the presence or absence of a hash
based on the dependency source. We also add our first regression tests.
2024-05-10 10:32:30 -04:00
Charlie Marsh
835ebe60c6
Create virtualenv if it doesn't exist in project API (#3499)
## Summary

This doesn't yet respect `--python` or the `requires-python` in the
project itself.

Closes #3449.
2024-05-10 14:10:13 +00:00
konsti
5f8c3b7e45
Re-add dummy serde feature to pep440-rs and pep508-rs (#3501)
This keeps us in sync with the published pep440-rs and pep508-rs crates
for prefix.
2024-05-10 13:46:29 +00:00
Chan Kang
76a39c76f5
add sys_path to Interpreter struct (#3500)
<!--
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
likely necessary to resolve https://github.com/astral-sh/uv/issues/2500

made this a separate PR in an attempt to make the changes as small as
possible; let me know if it's preferred to keep them as a single PR.
<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan
- edited the test in `interpreter.rs`
- tested manually via `println!` 

```
$ cargo run --quiet pip show test
["/Users/chankang/Library/Caches/uv/.tmpKzNEPN", "/Users/chankang/.pyenv/versions/3.12.2/lib/python312.zip", "/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12", "/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12/lib-dynload", "/Users/chankang/repos/uv/.venv/lib/python3.12/site-packages"]
warning: Package(s) not found for: test
chankang@chans-Air ~/repos/uv -  (syspath)
$ git diff
diff --git a/crates/uv-interpreter/src/environment.rs b/crates/uv-interpreter/src/environment.rs
index 33b785ce..8ebf0864 100644
--- a/crates/uv-interpreter/src/environment.rs
+++ b/crates/uv-interpreter/src/environment.rs
@@ -106,6 +106,7 @@ impl PythonEnvironment {
     /// Some distributions also create symbolic links from `purelib` to `platlib`; in such cases, we
     /// still deduplicate the entries, returning a single path.
     pub fn site_packages(&self) -> impl Iterator<Item = &Path> {
+        println!("{:?}", self.interpreter.sys_path());
         if let Some(target) = self.interpreter.target() {
             Either::Left(std::iter::once(target.root()))
         } else {
chankang@chans-Air ~/repos/uv -  (syspath)
$ python -c "import sys; print(sys.path)"
['', '/Users/chankang/.pyenv/versions/3.12.2/lib/python312.zip', '/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12', '/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12/lib-dynload', '/Users/chankang/.pyenv/versions/3.12.2/lib/python3.12/site-packages']
chankang@chans-Air ~/repos/uv -  (syspath)
```

<!-- How was it tested? -->
2024-05-10 08:41:32 +02:00
konsti
404552d0d8
Allow clippy map-unwrap-or (#3498)
`map_or` is harder too read than the `.map().unwrap()` versions.
2024-05-09 20:17:01 +00:00
Charlie Marsh
d68b740af7
Read and write uv.lock based on project root (#3497)
## Summary

The `uv.lock` location is no longer based on the current working
directory, but rather, on the discovered project name.
2024-05-09 19:54:10 +00:00
Charlie Marsh
3dd34e218a
Read package name from pyproject.toml in uv run (#3496)
## Summary

Right now, the project name is hard-coded.

Closes https://github.com/astral-sh/uv/issues/3491.
2024-05-09 19:42:53 +00:00
Charlie Marsh
51f4ab1c8d
Use defaults in RequirementsSpecification constructors (#3495) 2024-05-09 19:27:59 +00:00
Charlie Marsh
3bd89ce5b3
Discover uv run projects hierarchically (#3494)
## Summary

Ensures that running `uv run` in a subdirectory of a project behaves
just as-if in the project root.

Closes https://github.com/astral-sh/uv/issues/3490.
2024-05-09 19:16:07 +00:00
Charlie Marsh
5e3260933c
Run cargo update (#3488) 2024-05-09 15:09:13 -04:00
Andrew Gallant
ad01a768bc
uv-resolver: push resolver state to its own type (#3492)
This still keeps the resolver state on the stack, but it organizes it
into a more structured representation. This is a precursor to
implementing resolver forking, where we will ultimately put this state
on the heap. The idea is that this will let us maintain multiple
independent resolver states that will all produce their own resolution
(and potentially other forked states).

Closes #3354
2024-05-09 14:16:43 -04:00
Charlie Marsh
2d70303d56
Rebrand workspace API as project API (#3489)
## Summary

I've started to refer to this as the "project" API in various places, it
seems less duplicative than the "workspace" API which is a little
different.
2024-05-09 13:05:31 -04:00