Commit graph

2900 commits

Author SHA1 Message Date
Charlie Marsh
9905521957
Use shared client in Git fetch implementation (#4487)
## Summary

It turns out that the Git fetch implementation is initializing its own
client, which can be really expensive on macOS (due to loading native
certificates) _and_ bypasses any of our middleware. This PR modifies the
Git implementation to accept a shared client.
2024-06-24 17:09:29 -04:00
Charlie Marsh
7221514136
Make overrides a workspace method (#4491)
## Summary

No functional changes; just encapsulating the logic within the workspace
module.
2024-06-24 17:09:23 -04:00
Charlie Marsh
7d3fb4330f
Skip submodule update for fresh clones (#4482)
## Summary

We unconditionally update the submodules in our Git code, but AFAICT it
shouldn't be necessary if we already have a complete, up-to-date fetch
available.
2024-06-24 17:09:14 -04:00
Christopher Covington
01515c1332
Document PEP517 difference (#4480)
## Summary
PEP 517 build isolation https://github.com/astral-sh/uv/pull/843 has not
yet been mentioned in the PIP compatibility documentation. Add a section
for it.

## Test Plan
Visual inspection only

## Open Questions
> in most cases, swapping out `pip install` for `uv pip install` should
"just work".

In the first non-trivial case I tried, it worked for a short time and
then [started
failing](https://github.com/astral-sh/uv/issues/4069#issuecomment-2186762048).
Is there any data out there on how many top 100 or top 1000 packages
work with PEP 517 build isolation?

How can someone specify `--no-build-isolation` for just one package/line
in `requirements.txt`?

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2024-06-24 16:41:57 -04:00
Charlie Marsh
849478fa91
Add unowned settings variants (#4490)
## Summary

This PR adds unowned settings variants so that we can convert from
`ResolverInstallerSettings` to `ResolverSettings` without allocating.
2024-06-24 20:18:16 +00:00
Charlie Marsh
8afad69b03
Implement settings conversion traits (#4489)
## Summary

This does require cloning the settings, but I think it's fine. A better
solution would be to have owned and unowned settings structs, so that we
could convert `ResolverInstallerSettingsRef` to `InstallerSettingsRef`
without cloning, but that requires maintaining owned and unowned
variants.

Closes https://github.com/astral-sh/uv/issues/4455.
2024-06-24 16:08:11 -04:00
Charlie Marsh
ff72bb9bcc
Read content length from response rather than request (#4488)
## Summary

I might be mistaken, but I think we need to read the header from the
response, not the request. The request would only contain headers that
we set.

I verified (with extra logging) that the request header is `None` while
PyPI returns a valid length in the response header.
2024-06-24 15:58:21 -04:00
Charlie Marsh
f6aec0a96c
Remove non-existent extras from lockfile (#4479)
## Summary

Ultimately decided to view this as part of `LockWire` normalization:
removing references to extras that don't exist. I think it would be nice
if the resolver avoided omitting these, but I don't know if it's fully
possible.

Closes https://github.com/astral-sh/uv/issues/4405.
2024-06-24 14:56:56 -04:00
konsti
1984ada57c
Break PubGrubReportFormatter::hints into methods (#4478)
I have to add yet another indentation level to the prerelease-available
check in `PubGrubReportFormatter::hints` for #4435, so i've broken the
code into methods and decreased indentation in this split out
refactoring-only change.
2024-06-24 19:14:09 +02:00
Chan Kang
c127632419
implement --no-dedupe for uv pip tree (#4449)
<!--
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
Resolves https://github.com/astral-sh/uv/issues/4439 partially.

Implements for `uv pip tree`:
- `--no-dedupe` flag, similar to `cargo tree --no-dedupe` .
- denote dependency cycles with `(#)` and add a footnote if there's a
cycle (using `(*)` would require keeping track of the cycle state, so
opted to do this instead).
<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan
The existing tests pass + added a couple of tests to validate
`--no-dedupe` behavior.
<!-- How was it tested? -->
2024-06-24 11:54:55 -05:00
Sandu
03cfdc2275
uv lock to use overrides from tool.uv (#4108) (#4369)
## Summary

This will make `uv lock` read `override-dependencies` from the
`[tool.uv]` section of `pyproject.toml`.
Resolves #4108

This [other](https://github.com/astral-sh/uv/pull/4446) implementation
touches more code but seems more consistent.

## Test Plan

Unit test
2024-06-24 12:44:54 -04:00
Zanie Blue
bfc342da94
Bump version to 0.2.15 (#4475)
Releasing 0.2.15 with a few additions over 0.2.14. Motivated by the
incorrect tagging of 0.2.14 (#4474).

Generated the changelog with a small patch to Rooster allowing me to
force the previous commit to be correct.

```diff
diff --git a/src/rooster/_cli.py b/src/rooster/_cli.py
index 2a4f61b..4ec1299 100644
--- a/src/rooster/_cli.py
+++ b/src/rooster/_cli.py
@@ -38,6 +38,7 @@ def release(
     without_sections: list[str] = typer.Option(
         [], help="Sections to exclude from the changelog"
     ),
+    previous_commit: str = None,
 ):
     """
     Create a new release.
@@ -58,7 +59,11 @@ def release(
         typer.echo("It looks like there are no version tags for this project.")
 
     # Get the commits since the last release
-    changes = list(get_commits_between(config, repo, last_version))
+    changes = list(
+        get_commits_between(
+            config, repo, last_version, force_first_commit=previous_commit
+        )
+    )
     since = "since last release" if last_version else "in the project"
     typer.echo(f"Found {len(changes)} commits {since}.")
 
diff --git a/src/rooster/_git.py b/src/rooster/_git.py
index 597bb88..66bc54e 100644
--- a/src/rooster/_git.py
+++ b/src/rooster/_git.py
@@ -29,12 +29,13 @@ def get_commits_between(
     target: Path,
     first_version: Version | None = None,
     second_version: Version | None = None,
+    force_first_commit: str | None = None,
 ) -> Generator[git.Commit, None, None]:
     """
     Yield all commits between two tags
     """
     repo = git.repository.Repository(target.absolute())
-    first_commit = (
+    first_commit = force_first_commit or (
         repo.lookup_reference(
             TAG_PREFIX + config.version_tag_prefix + str(first_version)
         )
```
2024-06-24 10:04:09 -05:00
konsti
40f852687b
Add context to unregistered task name to error context (#4471)
I caused this error during development and having the name of the task
on it is helpful for debugging.

Split out from #4435
2024-06-24 14:42:55 +00:00
Zanie Blue
64e07b68a8
Reapply "Bump version to 0.2.14" (#4472)
Restores #4431

This reverts commit 9ff6a5ed74 (#4436)
2024-06-24 09:14:16 -05:00
Charlie Marsh
f07308823e
Add --emit-build-options flag to uv pip compile interface (#4463)
## Summary

Closes https://github.com/astral-sh/uv/issues/4420.
2024-06-24 12:25:01 +00:00
Charlie Marsh
cba270f750
Respect index strategy in source distribution builds (#4468)
## Summary

The `--index-strategy` is linked to the index locations, which we
propagate to source distribution builds; so it makes sense to pass the
`--index-strategy` too.

While I was here, I made `exclude_newer` a required argument so that we
don't forget to set it via the `with_options` builder.

Closes https://github.com/astral-sh/uv/issues/4465.
2024-06-24 12:03:38 +00:00
Charlie Marsh
1eee427c94
Add standalone CLI crate (#4456)
## Summary

This PR moves all the CLI code into its own crate, separate from the
`uv` crate. The `uv` crate is iterated on frequently, and the CLI code
comprises a significant portion of it but rarely changes. Removing the
CLI code reduces the `uv` crate size from 1.4MiB to 1.0MiB.
2024-06-24 06:16:22 -04:00
renovate[bot]
3251690327
Update Rust crate rustc-hash to v2 (#4461) 2024-06-24 01:13:05 +00:00
renovate[bot]
8a0a3b47db
Update docker/build-push-action action to v6 (#4462) 2024-06-24 00:14:16 +00:00
renovate[bot]
9498e5f02e
Update pre-commit dependencies (#4460) 2024-06-24 00:13:02 +00:00
renovate[bot]
cdba918453
Update Rust crate syn to v2.0.68 (#4459) 2024-06-24 00:10:32 +00:00
renovate[bot]
5c7576abc2
Update Rust crate cargo-util to v0.2.12 (#4457) 2024-06-24 00:08:14 +00:00
renovate[bot]
628e5112e8
Update Rust crate mimalloc to v0.1.43 (#4458) 2024-06-24 00:07:52 +00:00
Charlie Marsh
757ea61bea
Fix casing of --no-compile alias (#4453)
## Summary

Closes https://github.com/astral-sh/uv/issues/4452.
2024-06-23 17:25:50 +00:00
Zanie Blue
d4f2a8a52f
Adjust the docs for the pip CLI commands (#4445) 2024-06-23 12:03:49 -04:00
Zanie Blue
03e2e6b99a
Fix construction of Python path in test context (#4443)
When executables were not named `python3` e.g. `python3.11` we would
construct a Python path that would only work for _some_ requests in
tests since we don't search for those names unless a specific version is
requested. To solve, we construct a test context with constant Python
executable names. For example, if a test context was created with `3.11`
and `3.12` we could end up with the search path
`/usr/local/python-3.11/bin:/usr/local/python-3.12/bin` where the
executables are named `python3.11` and `python3` respectively. A test
invocation of uv requesting any Python toolchain version would then
locate the `3.12` executable since the `3.11` executable doesn't have
the generic name, but we want `3.11` to come first.

On Windows, we just leave things as-is because executables are always
called `python.exe`.

Closes https://github.com/astral-sh/uv/issues/4376
2024-06-23 10:05:48 -05:00
samypr100
2288ff7bf4
feat: pythonw support on gui scripts (#4409)
## Summary

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

This changes the bootstrap launcher script to use `pythonw.exe` instead
of `python.exe` on `gui_scripts` via a helper fn both in the shebang and
the python exe path encoded before `UVUV` magic, that way
uv-trampoline's `find_python_exe` can use the right pythonw executable.

## Test Plan

New unit tests for the helper was added.
Tested on example from #2956 on Windows to make sure it works as
expected.

## Questions

I noticed the docs in `fn windows_script_launcher` says ```The launcher
will look for `python[w].exe` adjacent to it in the same directory to
start the embedded script.``` but I didn't find such functionality when
I looked in uv-trampoline.
I only saw `clear_app_starting_state` getting called when `is_gui` is
set.

Was the intention to do this in uv-trampoline at some point instead?

---------

Co-authored-by: konstin <konstin@mailbox.org>
2024-06-23 09:48:47 +00:00
Zanie Blue
3a63e1410d
Adjust deduplicated message in pip tree (#4448) 2024-06-22 14:53:01 +00:00
Zanie Blue
c7149e96ca
Collapse duplicate toolchain search in test setup (#4442) 2024-06-22 09:43:03 -05:00
Zanie Blue
8f2d8b3f4f
Fix ordering of prefer-system toolchain preference (#4441)
Whoopsies!
2024-06-22 09:42:51 -05:00
renovate[bot]
895f202b77
Update Rust crate url to v2.5.2 (#4351) 2024-06-22 09:28:58 -05:00
Chan Kang
dd45fce2d4
implement uv pip tree (#3859)
## Summary

resolves https://github.com/astral-sh/uv/issues/3272

added it as a new subcommand rather than a flag on an existing
command since that seems more consistent with `cargo tree` + cleaner
code organization, but can make changes if it's preferred the other way.
2024-06-21 15:48:30 -04:00
Zanie Blue
7e574f5e20
Avoid running most of CI for non-code changes (#4438)
Running these test suites is both expensive and wasteful when there
aren't relevant changes.
2024-06-21 16:42:01 +00:00
Zanie Blue
b412a53e85
Add mdbook to docs workflow (#4437)
Based on
https://github.com/rust-lang/mdBook/wiki/Automated-Deployment%3A-GitHub-Actions
2024-06-21 16:33:55 +00:00
Zanie Blue
9ff6a5ed74
Revert "Bump version to 0.2.14 (#4431)" (#4436)
This reverts commit e0ad649c74.

We shouldn't be linking to this version in the readme.

See https://github.com/astral-sh/uv/issues/4432
2024-06-21 16:24:32 +00:00
Zanie Blue
e89196f969
Add documentation for using uv in a Docker image (#4433)
[Rendered](https://github.com/astral-sh/uv/blob/zb/docker/docs/docker.md)
2024-06-21 09:49:34 -05:00
Zanie Blue
e0ad649c74
Bump version to 0.2.14 (#4431) 2024-06-20 13:58:10 -05:00
Zanie Blue
93c6e0df56
Expose toolchain-preference as a CLI and configuration file option (#4424)
Exposes the option added in #4416. Adds `--toolchain-preference` and
`tool.uv.toolchain-preference` to configure if system or managed
toolchains are preferred. Users can opt-out of managed toolchains or
system toolchains entirely as well.
2024-06-20 13:42:09 -05:00
Ibraheem Ahmed
e797d3eb5c
Pin benchmark requirements (#4429)
## Summary

This should make benchmarks more consistent.
2024-06-20 14:13:38 -04:00
Zanie Blue
e783a79955
Add PythonEnvironment::find API (#4423)
Restores the `PythonEnvironment::find` API which was removed a while
back in favor of `Toolchain::find`. As mentioned in #4416, I'm
attempting to separate the case where you want an active environment
from the case where you want an installed toolchain in order to create
environments.

I wanted to drop `EnvironmentPreference` from `Toolchain::find` and just
have us consistently consider (or not consider) virtual environments
when discovering toolchains for creating environments. Unfortunately
this caused a few things to break so I reverted that change and will
explore it separately. Because I was exploring that change, there are
some minor changes to the `Toolchain` API here.
2024-06-20 17:54:17 +00:00
Zanie Blue
baa86f2edf
Fix the documentation branch target (#4428)
Doh.
2024-06-20 17:35:56 +00:00
Zanie Blue
30eedb35c6
Add documentation publishing workflow (#4427)
Exploring publishing documentation to GitHub Pages. Not intended for
public consumption yet.
2024-06-20 12:24:20 -05:00
Zanie Blue
13e532ccda
Add internal options for managing toolchain discovery preferences (#4416)
Adds support for the toolchain discovery preferences outlined in
https://github.com/astral-sh/uv/issues/4198 but we don't expose this to
users yet, I'll do that next to make it easier to review.

I've made some refactors in the toolchain discovery implementation to
enable this behavior and move us towards clearer abstractions. There's
still remaining work here, but I'd prefer tackle things in follow-ups
instead of expanding this pull request. I plan on opening a couple
before merging this.

I'd like to shift the public toolchain API to focus on discovering
either an **environment** or a **toolchain**. The first would be used by
commands that operate on an environment, while the latter would be used
by commands that just need an interpreter to create environments. I
haven't changed this here, but some of the refactors are in preparation
for supporting this idea.

In brief:

- We now allow different ordering of installed toolchain discovery based
on a `ToolchainPreference` type. This is the type we will expose to
users.
- `SystemPython` was changed into an `EnvironmentPreference` which is
used to determine if we should prefer virtual or system Python
environments.
- We drop the whole `ToolchainSources` selection concept, it was
confusing and the error messages from it were awkward. Most of the
functionality is now captured by the preference enums, but you can't do
things like "only find a toolchain from the parent interpreter" as
easily anymore.
2024-06-20 08:57:05 -05:00
konsti
b865341517
Use correct lock path for workspace dependencies (#4421)
Previously, distributions created through `Source::Workspace` would have
the absolute path as lock path. This didn't cause any problems, since in
`Urls` we would later overwrite those urls with the correct one created
from being workspace members by path.

Changing the order surfaced this. This change emits the correct lock
path. I've manually checked the difference with `dbg!`, this is not
observable on main, but on the diverging urls branch it fixes lockfile
creation.
2024-06-20 13:28:47 +00:00
Andrew Gallant
fc7c318dd0 uv/tests: add sibling fork filter dependency test
This is from: https://github.com/astral-sh/packse/pull/197
2024-06-20 07:21:45 -04:00
Andrew Gallant
10c950a551 scenarios: bump to packse 0.3.29 2024-06-20 07:21:45 -04:00
Andrew Gallant
9595a511cd uv-resolver: filter out sibling dependencies in a fork
When a fork is created from a list of dependencies, we were previously
adding all other sibling dependencies to every fork created. But this
isn't actually quite right, since the fork created is always created by
some marker expression. And while it is definitively disjoint from any
directly conflicting dependency specification, it is also possibly
disjoint with other dependencies. For example, as reported in #4414:

```toml
dependencies = [
  "anyio==4.4.0 ; python_version >= '3.12'",
  "anyio==4.3.0 ; python_version < '3.12'",
  "b1 ; python_version >= '3.12'",
  "b2 ; python_version < '3.12'",
]
```

The first two `anyio` requirements are conflicting with non-overlapping
marker expressions, and so a fork is created. Prior to this commit,
*both* `b1` and `b2` would be added to each fork. But of course, `b2` is
impossible in the `anyio==4.4.0` fork because of disjoint marker
expressions.

So in this commit, we specifically filter out any sibling dependencies
that could find their way into a fork that have disjoint markers with
that fork. We are careful to do this both when a new fork is created
from an existing set of dependencies, and when adding new dependencies
to a fork.

Fixes #4414
2024-06-20 07:21:45 -04:00
Zanie Blue
34c7bc5cc8
Refactor Python executable chain into lazy variables (#4318)
In preparation for changing the order dynamically in #4416
2024-06-19 15:27:02 -05:00
Ibraheem Ahmed
7b72b55af8
Opt-out tool.uv.sources support for uv add (#4406)
## Summary

After this change, `uv add` will try to use `tool.uv.sources` for all
source requirements. If a source cannot be resolved, i.e. an ambiguous
Git reference is provided, it will error. Git references can be
specified with the `--tag`, `--branch`, or `--rev` arguments. Editables
are also supported with `--editable`.

Users can opt-out of `tool.uv.sources` support with the `--raw` flag,
which will force uv to use `project.dependencies`.

Part of https://github.com/astral-sh/uv/issues/3959.
2024-06-19 14:20:16 -04:00
konsti
3c5b13695e
Move adding dependencies for versions into dedicated method (#4410)
To support diverging urls, we have to check urls when adding
dependencies (after forking). To prepare for this, i've moved adding
dependencies for the current version to
`SolveState::add_package_version_dependencies` and removed the
duplication when checking for self-dependencies.

This changed is joined with a change in pubgrub
(https://github.com/astral-sh/pubgrub/pull/27) that simplifies the same
code path.
2024-06-19 20:19:12 +02:00