Commit graph

6047 commits

Author SHA1 Message Date
Zanie Blue
c1a0bb85ea
Bump version to 0.6.6 (#12125) 2025-03-12 00:02:48 +00:00
Zanie Blue
b7167dc4d8
Fix uv python install --reinstall when the version is not yet installed (#12124)
I noticed this was failing to perform the install
2025-03-11 23:53:28 +00:00
Zanie Blue
553bcccb6a
Add support for dynamic musl Python distributions on x86-64 Linux (#12121)
Following the upstream release and #12120, removes gating preventing
installation of the managed musl Python versions.

Of note

- The filtering of musl Python distributions has moved from the Rust
runtime to the metadata fetcher
- The filtering is now conditional on the PBS release date, removing all
old static musl distributions
- We could support the `+static` musl downloads in the future; right
now, they are deprioritized when selecting a variant
- I added test to CI which uses Alpine and installs numpy
2025-03-11 18:14:10 -05:00
github-actions[bot]
f3fb1c5a17
Sync latest Python releases (#12120)
Automated update for Python releases.

---------

Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-03-11 20:58:47 +00:00
Zanie Blue
a59778fca3
Update the index.authenticate docs (#12102)
Follow-up to #11896 

Reframes the documentation a bit.

Looking into why the `[index]` child fields aren't generate in the
reference correctly too.
2025-03-11 15:01:42 -05:00
justin
c48af312ae
Add --marker flag to uv add (#12012)
## Summary

Add a `--marker` flag to `uv add` which applies a marker to all given
requirements.

Example:

```
$ uv-debug add --marker "platform_machine == 'x86_64'" \
    "anyio>=2.31.0" \
    "iniconfig>=2; sys_platform != 'win32'" \
    "numpy>1.19; sys_platform == 'win32'"
```

```toml
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12.0"
dependencies = [
    "anyio>=2.31.0 ; platform_machine == 'x86_64'",
    "iniconfig>=2 ; platform_machine == 'x86_64' and sys_platform != 'win32'",
    "numpy>1.19 ; platform_machine == 'x86_64' and sys_platform == 'win32'",
]
```

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


## Test Plan

Added snapshot tests

---------

Co-authored-by: konstin <konstin@mailbox.org>
2025-03-11 16:29:36 +01:00
Jean-Michel Rouet
d660882b8d
publish with sized stream to comply with WSGI pypi server constraints. (#12111)
<!--
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 PR is meant to fix issue #11862 

It allows to send sized bodies during `publish`

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

## Test Plan

the PR was tested on the MRE from #11862 

<!-- How was it tested? -->
2025-03-11 15:54:30 +01:00
GCHQDeveloper314
2ac47d76b8
Docs : Quote versions string in python-versions.md (#12112)
<!--
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

The command `uv python find >=3.11` doesn't work . The version should be
quoted otherwise the terminal interprets the `>` and pipes output to a
file named `=3.11`. I've used single quotes as used on line 90 of this
file.

## Test Plan

Locally
2025-03-11 09:03:00 -05:00
samypr100
e096ab2411
Add support for Windows legacy scripts via uv tool run (#12079)
## Summary

Follow up to https://github.com/astral-sh/uv/pull/11888 with added
support for uv tool run.

Changes
* Added functionality for running windows scripts in previous PR was
moved from run.rs to uv_shell::runnable.
* EXE was added as a supported type, this simplified integration across
both uv run and uvx while retaining a backwards compatible behavior and
properly prioritizing .exe over others. Name was adjusted to runnable as
a result to better represent intent.

## Test Plan

New tests added.

## Documentation

Added new documentation.
2025-03-11 09:02:17 -05:00
konsti
82212bb439
Show ambiguous requirements when uv add failed (#12106)
Improves the error message.

Fixes #12105

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-03-10 23:00:09 -04:00
konsti
e843433b07
Cache workspace discovery (#12096)
Reduce the overhead of `uv run` in large workspaces. Instead of
re-discovering the entire workspace each time we resolve the metadata of
a member, we can the discovered set of workspace members. Care needs to
be taken to not cache the discovery for `uv init`, `uv add` and `uv
remove`, which change the definitions of workspace members.

Below is apache airflow e3fe06382df4b19f2c0de40ce7c0bdc726754c74 `uv run
python` with a minimal payload. With this change, we avoid a ~350ms
overhead of each `uv run` invocation.

```
$ hyperfine --warmup 2 \
    "uv run --no-dev python -c \"print('hi')\"" \
    "uv-profiling run --no-dev python -c \"print('hi')\""
Benchmark 1: uv run --no-dev python -c "print('hi')"
  Time (mean ± σ):     492.6 ms ±   7.0 ms    [User: 393.2 ms, System: 97.1 ms]
  Range (min … max):   482.3 ms … 501.5 ms    10 runs
 
Benchmark 2: uv-profiling run --no-dev python -c "print('hi')"
  Time (mean ± σ):     129.7 ms ±   2.5 ms    [User: 105.4 ms, System: 23.2 ms]
  Range (min … max):   126.0 ms … 136.1 ms    22 runs
 
Summary
  uv-profiling run --no-dev python -c "print('hi')" ran
    3.80 ± 0.09 times faster than uv run --no-dev python -c "print('hi')"
```

The profile after those change below. We still spend a large chunk in
toml parsing (both `uv.lock` and `pyproject.toml`), but it's not
excessive anymore.


![image](https://github.com/user-attachments/assets/6fe78510-7e25-48ee-8a6d-220ee98ad120)
2025-03-10 22:03:30 +01:00
renovate[bot]
15663eab26
Update Rust crate reflink-copy to v0.1.25 (#12087)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [reflink-copy](https://redirect.github.com/cargo-bins/reflink-copy) |
workspace.dependencies | patch | `0.1.24` -> `0.1.25` |

---

### Release Notes

<details>
<summary>cargo-bins/reflink-copy (reflink-copy)</summary>

###
[`v0.1.25`](https://redirect.github.com/cargo-bins/reflink-copy/blob/HEAD/CHANGELOG.md#0125---2025-03-08)

[Compare
Source](https://redirect.github.com/cargo-bins/reflink-copy/compare/v0.1.24...v0.1.25)

##### Other

- Bump rustix from 0.38.34 to 1.0.1
([#&#8203;101](https://redirect.github.com/cargo-bins/reflink-copy/pull/101))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/astral-sh/uv).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xODUuNCIsInVwZGF0ZWRJblZlciI6IjM5LjE4NS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJpbnRlcm5hbCJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-10 13:14:35 -05:00
John Mumm
c58675fdac
Add an optional authentication policy to [index] configuration (#11896)
Adds a new optional key `auth-policy` to `[tool.uv.index]` that sets the
authentication policy for the index URL.

The default is `"auto"`, which attempts to authenticate when necessary.
`"always"` always attempts to authenticate and fails if the endpoint is
unauthenticated. `"never"` never attempts to authenticate.

These policy address two kinds of cases:
* Some indexes don’t fail on unauthenticated requests; instead they just
forward to the public PyPI. This can leave the user confused as to why
their package is missing. The "always" policy prevents this.
* "never" allows users to ensure their credentials couldn't be leaked to
an unexpected index, though it will only allow for successful requests
on an index that doesn't require credentials.

Closes #11600
2025-03-10 12:24:25 -05:00
renovate[bot]
44c3648537
Update Rust crate proc-macro2 to v1.0.94 (#12085) 2025-03-10 09:39:09 -04:00
renovate[bot]
e37f3f1091
Update Rust crate serde to v1.0.219 (#12088) 2025-03-10 09:39:02 -04:00
renovate[bot]
43f424362f
Update Rust crate quote to v1.0.39 (#12086) 2025-03-10 09:38:54 -04:00
renovate[bot]
cff2ad969f
Update Rust crate jiff to v0.2.3 (#12084) 2025-03-10 09:38:45 -04:00
renovate[bot]
497e1bb9da
Update Rust crate indoc to v2.0.6 (#12083) 2025-03-10 09:38:41 -04:00
renovate[bot]
bc37d68238
Update Rust crate async-trait to v0.1.87 (#12082) 2025-03-10 09:38:37 -04:00
renovate[bot]
672eba1087
Update Rust crate anyhow to v1.0.97 (#12081) 2025-03-10 09:38:30 -04:00
konsti
aa629c4a54
Re-add 3 retries in uv publish (#12041)
In the publish client, we have to set the client retries to 0 as the
retry middleware is incompatible with upload bodies. This however also
sets `client.retry_policy()` to a zero-retry policy, so we need to
construct our own policy.

Fixes #12027

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-03-10 12:38:08 +01:00
John Mumm
ba74b9ea93
Move config dir functions to public functions in uv_dirs (#12090)
This PR moves functions for finding user- and system-level config
directories to public functions in `uv_fs::config`. This will allow them
to be used in future work without duplicating code.
2025-03-10 12:05:05 +01:00
Charlie Marsh
9776dc5882
Remove some allocations from uv-auth (#12077)
## Summary

Use `SmallString`, and no need to allocate a `String` to fetch from the
URLs cache.
2025-03-09 14:28:33 -04:00
Charlie Marsh
bcc3e4f196
Add Rustdoc boxes around references (#12076) 2025-03-09 13:17:28 -04:00
John Mumm
b7968e7789
Conflicting groups should handle conflicting inclusions automatically (#12005)
This adds support for inferring dependency group conflict sets from the
directly defined conflicts in configuration. For example, if you declare
a conflict between groups `alpha` and `beta` and `dev` includes `beta`,
then we will infer a conflict between `dev` and `alpha`. We will also
handle a conflict between two groups if they transitively include groups
that conflict with each other. See #11232 for more details.

Closes #11232
2025-03-08 19:21:25 +01:00
Zanie Blue
3739223c96
Fix tool concept page headings (#12053)
Some of these were incorrectly nested, and there was not a heading for
upgrades
2025-03-08 08:49:21 -06:00
JonCholas
b239c3ec4a
Avoid consider PATH updated when the export is commented in the shellrc (#12043)
## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
The way the `tool update-shell` checks if the command to export the PATH
exists or not in the RC files is a blind search, and therefore if finds
the command inside comments.

example with .zshenv

This content
```
# uv
# export PATH="/Users/cholas/.local/bin:$PATH"
```

Generates the following msg
```
error: The executable directory /Users/cholas/.local/bin is not in PATH, but the Zsh configuration files are already up-to-date
```

With this change, that content won't be considered as configured and the
following will be added
```
# uv
export PATH="/Users/cholas/.local/bin:$PATH"
```

This will make the `update-shell` more reliable

## Test Plan

I tested with and without the change with commented export in zsh in
mac. Tested running `cargo run -- tool update-shell`

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
2025-03-08 14:45:06 +00:00
Charlie Marsh
3c220c845e
Remove unused archive timestamp (#12064)
## Summary

Must've been leftover from a prior refactor.
2025-03-08 09:10:27 -05:00
konsti
b2a0ea3701
Integration test uv_build package (#12058)
I somehow missed running an actual integration test of the PEP 517 API
in CI and the python shim was using the old uv CLI interface still.

The tests include pip, uv and `python -m build`. They must be a in CI
job since we can't depend on the Python package in the Rust tests (we
only get the binary in `cargo test`, not the `uv_build` wheel).
2025-03-07 23:40:53 +01:00
Charlie Marsh
3dc9ac149d
Insert dependencies into fork state prior to fetching metadata (#12057)
## Summary

The order here is slightly off... As-is, we fetch the metadata for the
dependency, _then_ insert the URLs and indexes into the fork state -- so
the fetch doesn't take the explicit index or URL into account. This has
mostly been unobserved because we re-fetch anyway in the next request,
but if we do things in the right order (add to fork state, fetch
dependencies, insert dependencies), we can cut down on the fetches.

Closes https://github.com/astral-sh/uv/issues/12056.
2025-03-07 14:45:46 -05:00
Zanie Blue
f427164d99
Update versioning policy (#11666)
See https://github.com/astral-sh/uv/issues/10808#issuecomment-2671235395
2025-03-07 11:12:07 -06:00
Zanie Blue
0798c3565d
Fix PyPI typo in publish workflow (#12051) 2025-03-07 11:10:23 -06:00
Charlie Marsh
8fb616b61e
Use 'Upload' instead of 'Download' in publish reporter (#12029)
## Summary

Closes https://github.com/astral-sh/uv/issues/12026.
2025-03-07 10:48:34 -05:00
Christian Sachs
c57dd1a4a8
Allow overriding module name for uv build backend (#11884)
Thank you for uv, it has game-changer capabilities in the field of
Python package and environment maangement!

## Summary

This is a small PR adding the option `module-name`
(`tool.uv.build-backend.module-name`) to the uv build backend (
https://github.com/astral-sh/uv/issues/8779 ).

Currently, the uv build backend will assume that the module name matches
the (dash to underdash-transformed) package name. In some packaging
scenarios this is not the case, and currently there exists no
possibility to override it, which this PR addresses.

From the main issue ( https://github.com/astral-sh/uv/issues/8779 ) I
could not tell if there is any extensive roadmap or plans how to
implement more complex scenarios, hence this PR as a suggestion for a
small feature with a big impact for certain scenarios.

I am new to Rust, I hope the borrow/reference usage is correct.

## Test Plan

So far I tested this at an example, if desired I can look into extending
the tests.

Fixes #11428

---------

Co-authored-by: konstin <konstin@mailbox.org>
2025-03-07 15:20:00 +01:00
John Mumm
1ab1945dd9
Move DependencyGroups to uv-pypi-types so it can be imported there (#12037)
This PR is in support of #12005, where we need to import
`DependencyGroups` in the `uv-pypi-types` crate without a circular
dependency on `uv-workspace`.
2025-03-07 12:30:47 +01:00
Zanie Blue
7a56aef7d1
Revert "Run the uv-build publish sequentially after uv (#12022)" (#12024)
This was not the problem
2025-03-06 16:53:39 -06:00
Zanie Blue
15bc1e7c03
Fix upload name for macOS wheels (#12023)
These were missed in the original PR and consequently not uploaded
2025-03-06 16:53:29 -06:00
Zanie Blue
ef1243c6e8
Run the uv-build publish sequentially after uv (#12022)
In an attempt to resolve a trusted publishing failure
2025-03-06 15:27:57 -06:00
Zanie Blue
f18e6ef6d4
Bump uv-build version to 0.6.5 (#12019) 2025-03-06 20:51:29 +00:00
Zanie Blue
bcbcd0a1e5
Bump version to 0.6.5 (#12018) 2025-03-06 14:39:23 -06:00
konsti
bf4c7afe8b
A minimal build backend for uv: uv_build (#11446)
uv itself is a large package with many dependencies and lots of
features. To build a package using the uv build backend, you shouldn't
have to download and install the entirety of uv. For platform where we
don't provide wheels, it should be possible and fast to compile the uv
build backend. To that end, we're introducing a python package that
contains a trimmed down version of uv that only contains the build
backend, with a minimal dependency tree in rust.

The `uv_build` package is publish from CI just like uv itself. It is
part of the workspace, but has much less dependencies for its own
binary. We're using cargo deny to enforce that the network stack is not
part of the dependencies. A new build profile ensure we're getting the
minimum possible binary size for a rust binary.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-03-06 13:27:20 -06:00
Charlie Marsh
d4a805544f
Allow users to set package = true on tool.uv.sources (#12014)
## Summary

In https://github.com/astral-sh/uv/issues/11998, a user is attempting to
vendor `pydantic-core`. But when they add `pydantic-core = { path =
"src/foo/vendor/pydantic-core" } `, we're installing it as a virtual
package, since `pydantic-core/pyproject.toml` contains `package =
false`.

This PR allows users to mark dependencies as "explicitly a package" or
"explicitly not a package" (i.e., virtual), as a workaround.

Closes https://github.com/astral-sh/uv/issues/11998.
2025-03-06 18:28:09 +00:00
Charlie Marsh
626fff1be7
Invalidate lockfile when empty dependency groups are added or removed (#12010)
## Summary

Since https://github.com/astral-sh/uv/pull/8598, we (correctly) include
empty groups in the lockfile, so we can validate them properly in the
satisfaction check.

Closes https://github.com/astral-sh/uv/issues/12007.
2025-03-06 12:44:20 -05:00
Charlie Marsh
40dce4e009
Allow overrides in all satisfies checks (#11995)
## Summary

This PR adds support for `SitePackages::satisfies` with unnamed
overrides and requirements.

The main challenge here was cases like: you have a `requirements.in`
with `git+https://github.com/pallets/flask` in it, and an
`overrides.txt` with `flask==2.0.0` in it. You _need_ to include
`flask==2.0.0`, but you can't know that without resolving the unnamed
URL requirement (since overrides only take effect when the package is
included, like constraints).

We now make the assumption that any unnamed overrides _are_ relevant,
for the purpose of the satisfies check. This is conservative, but this
whole check is an optimization anyway.
2025-03-05 21:54:19 -05:00
Charlie Marsh
b955211698
Allow overrides in satisfies check for uv tool run (#11994)
## Summary

For now, this routine requires that all requirements, constraints, and
overrides are named. I'll look at generalizing it later.
2025-03-05 21:43:49 -05:00
Charlie Marsh
c9e09de794
Warn user on uvx run command (#11992)
## Summary

If a user invokes `uvx run ...`, we hint them towards `uvx`. Otherwise,
this invokes the `run` package, which is unmaintained on PyPI.

If the user is _only_ using PyPI, we show an interactive prompt here;
otherwise, we just show a dedicated warning on error.

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

## Test Plan

Prompting to success:

![Screenshot 2025-03-05 at 5 00
47 PM](https://github.com/user-attachments/assets/d8180606-94e1-41df-b799-19b8ba57e662)

If you use `--from`, we avoid the prompt and hint:

![Screenshot 2025-03-05 at 5 03
26 PM](https://github.com/user-attachments/assets/59919390-01d3-4ddf-97bc-bb857ae9f8b0)

If you provide another index, we don't prompt, but we do warn on
failure:

![Screenshot 2025-03-05 at 5 03
43 PM](https://github.com/user-attachments/assets/0cc72c36-5744-48f1-aeff-4a214190d6fd)
2025-03-06 02:15:19 +00:00
samypr100
0fb5291239
Add support for Windows legacy scripts via uv run (#11888)
## Summary

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

This adds support for running .ps1, .cmd, .bat legacy scripts typically
provided by setuptools [legacy script
files](https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#scripts).

Note, .bat and .cmd scripts were somewhat supported previously by
[Command](https://doc.rust-lang.org/std/process/index.html#batch-file-special-handling)
when the extension was explicit but documentation says such behavior
should not be relied upon.

In addition, when no extension is provided and a legacy script exists,
it will try to infer the appropriate extension on Windows and use the
right runtime with preference for .ps1. Only powershell.exe and cmd.exe
are supported right now.

## Test Plan

Added tests. Tested with nuitka locally via uv run.

Note uvx support will be added in a follow up.
2025-03-05 14:39:48 -06:00
Charlie Marsh
28ff80b639
Respect markers on constraints when validating current environment (#11976)
## Summary

Small omission I noticed last night. This was overly strict (so, didn't
lead to any incorrect behavior; more that we did unnecessary work in
some cases).
2025-03-05 09:25:30 -05:00
Alex Lowe
7340ff72da
Add NO_BUILD and NO_BUILD_PACKAGE environment variables (#11968)
<!--
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? -->
Similar to https://github.com/astral-sh/uv/pull/11399

This adds `UV_NO_BUILD` and `UV_NO_BUILD_PACKAGE` environment variables
for non-pip commands.

## Test Plan

<!-- How was it tested? -->
Tested manually and with snapshot tests.


Fixes #11963

Signed-off-by: Alex Lowe <alex@lowe.dev>
2025-03-04 22:58:19 -06:00
Charlie Marsh
0f5b106dae
Fix empty constraints in satisfies check (#11971)
## Summary

Oversight from my constraints PR in `uv tool run`.
2025-03-05 03:11:20 +00:00