Skip to content

Recover tool executables without replacing competing owners - #1981

Draft
zaniebot wants to merge 59 commits into
zb/future-20260912-tool-executable-ownershipfrom
zb/future-20260912-tool-executable-recovery
Draft

zaniebot wants to merge 59 commits into
zb/future-20260912-tool-executable-ownershipfrom
zb/future-20260912-tool-executable-recovery

Conversation

@zaniebot

Copy link
Copy Markdown
Collaborator

Deleting a tool’s exported command or changing UV_TOOL_BIN_DIR can leave install and upgrade reporting that nothing needs to change, even though the command is no longer runnable. Capture ownership of existing exports before changing environments, then check the complete export plan before replacing command files. Restore destinations attributable to the selected tool, and refuse competing receipts or ambiguous Windows aliases even with --force. The integration also keeps tool-upgrade version preferences consistent with ordinary upgrades.

astral-automations-bot Bot and others added 30 commits September 12, 2026 14:54
The aarch64 walltime benchmark run in #1614 reached its
20-minute job deadline without a benchmark assertion or runner-loss
diagnostic. Raise `benchmarks-walltime-run` to 30 minutes to give that
lane more headroom. The walltime build and simulated benchmark timeouts
are unchanged.

Co-authored-by: Zanie Blue <[email protected]>
)

`uv python install` checks a Unix executable symlink's relative target
against the process working directory. This can overwrite a valid
unmanaged Python without `--force`, or reject a dangling link when a
same-named path exists in the working directory. Check the executable
path after establishing that it is a symlink, so relative targets
resolve from the link's directory. Non-symlink executables, inspection
errors, and unmanaged Windows launchers still require `--force`.

Refs astral-sh#9706.

---------

Co-authored-by: Zanie Blue <[email protected]>
Failed revalidation of a cached response discards the retries already
performed by the HTTP middleware, so the outer cache retry loop can
spend the same retry budget again. Preserve the response's `RetryCount`
and elapsed duration when constructing the HTTP status error, matching
the fresh-request path. Status classification, problem details, and
cache policy remain unchanged.

---------

Co-authored-by: Zanie Blue <[email protected]>
Co-authored-by: Charlie Marsh <[email protected]>
## Summary

We currently check `required-environments` against wheel coverage
outside the current resolver fork. For example, a release with a Python
3.12 Linux wheel and a Python 3.13 Windows wheel can satisfy a Linux
requirement in the Python 3.13 fork, even though neither wheel supports
that environment.

Restrict the coverage and dependency-relevance checks to the current
fork, for both registry candidates and direct wheel URLs. This lets us
backtrack to a compatible release when one is available, or report that
the required environment is unsupported.
<!--
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

Like astral-sh#21674 and astral-sh#21676 

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

## Test Plan

NFC, internal.

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

Signed-off-by: William Woodruff <[email protected]>
The resolved `IndexLocations` type still implements Serde even though
configuration and tool receipts serialize their input options instead.
These derives were added alongside the resolved tool settings in
astral-sh#5937; the parent settings derives were removed in
astral-sh#7442. Remove the unused implementation without changing
configuration or receipt formats.

Co-authored-by: zaniebot <[email protected]>
<!--
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 gives us a backstop so we don't accidentally reintroduce toolchain
components outside of astral-dev-toolchain.

Closes astral-sh#21665.

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

## Test Plan

NFC, internal.

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

Signed-off-by: William Woodruff <[email protected]>
## Summary

Repeated `uv export` calls rediscover the workspace and load the same
lockfile for every output. We add a hidden, experimental `--batch`
option to export multiple selections from one workspace and lockfile
load:

```sh
uv export --frozen --batch exports.toml --preview-features batch-export
```

```toml
[[export]]
output-file = "requirements.txt"
no-group = ["dev"]

[[export]]
output-file = "app-test.txt"
package = ["app"]
no-default-groups = true
extra = ["test"]

[[export]]
output-file = "app-tools.txt"
package = ["app"]
only-group = ["tools"]
```

Each entry has its own package, extra, and group selections, including
member-specific default groups. Output paths are relative to the
manifest; formatting options apply to every output.
Co-authored-by: astral-automations-bot[bot] <305554984+astral-automations-bot[bot]@users.noreply.github.com>
I noticed this duplication in
astral-sh#21467, this centralizes
`--find-links` flat-index loading into `FlatIndex::load`.

<!-- codex-thread: 01a0a188-693a-7190-b38a-8b924b74cc2a -->
## Summary

We now serialize and atomically write each HTTP cache entry in one
blocking task, including directory creation for new entries. On a 304
response, we refresh the policy and decode the cached payload in the
same task. This reduces blocking-pool handoffs and moves serialization,
temporary-file creation, and rename operations off the async thread.

We reuse the synchronous atomic-write helper, including its Windows
retry behavior. Decoding failures remain distinct from write failures so
corrupt payloads can be refetched.

## Benchmarks

Resolving pinned Jupyter 1.1.1 and its 95 dependencies against a local
mirror takes **16% less time with an empty cache** and **11–13% less
time when revalidating cached responses** across two batches.
Fresh-cache controls show no clear change.

| Workload | Batch | Median baseline → PR | Paired time reduction [95%
interval] |
| --------------------- | ----- | -------------------- |
------------------------------------ |
| Cold cache | 1 | 275.4 → 233.0 ms | 15.9% [12.7, 20.0] |
| Cold cache | 2 | 281.4 → 237.6 ms | 16.0% [14.0, 17.9] |
| HTTP 304 revalidation | 1 | 185.2 → 166.2 ms | 10.9% [8.6, 13.3] |
| HTTP 304 revalidation | 2 | 190.7 → 168.0 ms | 12.8% [9.8, 14.3] |

Peak RSS increases by roughly 5 MiB for cold runs and 3 MiB for
revalidation. Aggregate CPU time falls from 0.38 → 0.35 s for cold runs,
but rises from 0.26 → 0.30 s for revalidation. These are loopback
resolution measurements using the profiling build.

[Raw samples, exact inputs, and benchmark
harness](https://gist.github.com/charliermarsh/38da9136460c2edb6c530196eccd5864).

<details>
<summary>Benchmark method and fresh-cache control</summary>

Compared base `83d556d712c7e316932b239c49e86a5de95d124a` with
`41d72b21d42515e388e8488d25b0cecd00ed86be`. Measured on Linux/ext4, AMD
EPYC-Milan with 32 available CPUs, CPython 3.12.3, and the same Ohm
1.98.1-1 compiler, default features, and optimized `profiling`
configuration without LTO. The benchmarked production code matches the
PR.

Each batch has 40 alternating baseline/candidate pairs per write
workload and 20 pairs for the fresh-cache control, after an excluded
warmup pair. The second batch reverses the starting order. All 400
measured commands produce identical output for the same 96 packages.
Timings include command startup; preparation and validation are
excluded. OS pages are warm.

The mirror serves 14.7 MB of captured PyPI catalogs. Cold runs make 96
catalog and 96 METADATA requests, all HTTP 200. Revalidation uses
independently primed caches and makes the same 192 requests, all HTTP
304. Fresh-cache controls make zero requests.

| Fresh-cache control | Median baseline → PR | Paired time reduction
[95% interval] |
| ------------------- | -------------------- |
------------------------------------ |
| Batch 1 | 42.5 → 41.9 ms | 0.4% [-1.9, 2.0] |
| Batch 2 | 43.2 → 42.1 ms | -0.7% [-1.9, 4.8] |

Positive percentages mean less time. Reductions use the median of
matched candidate/baseline ratios, with 95% intervals from 10,000 paired
bootstrap resamples. They need not equal the ratio of the independent
medians. CPU time is user plus system time, reported in 10 ms
increments.

</details>

All six cache-client integration tests pass. Native and Windows-target
Clippy pass.
…21693)

Add a minimal integration test that reproduces astral-sh#21692.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: konstin <[email protected]>
…#21459)

`Constraints` currently stores only normalized requirements for
resolution, with extras and empty constraints removed. Callers that need
the original declarations and their hashes have to keep a separate
collection.

Preserve the original `NameRequirementSpecification`s in input order
alongside the resolver map. Use this representation for build
constraints in `uv pip install`, `uv pip sync`, and `uv build`,
preserving their existing hash-checking and resolution behavior.
…21699)

Reverts astral-sh#21569 to restore the previous wheel installation behavior.

This fixes two regressions introduced in uv 0.12.14:

- `uv pip install --target=.` fails because the relative installation
root normalizes to an empty path. Fixes astral-sh#21694.
- Installing wheels with man pages fails in official Python Docker
images, where `/usr/local/man` is a symlink to `share/man`. Fixes
astral-sh#21692.
<!-- codex-thread: 01a0a496-3b61-7140-8190-53aa070449d2 -->
Add a minimal integration test that reproduces astral-sh#21694.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: konstin <[email protected]>
We currently download Babel, python-dotenv, Ansible, and Black to
exercise tool upgrades and executable installation. Add console entry
point support to Packse's generated wheels and source distributions,
then use small local scenarios for these tests.

An earlier CI comparison measured the following summed duration across
the 13 converted tests:

| Platform |
[Before](https://github.com/astral-sh/uv/actions/runs/34663282841) |
[After](https://github.com/astral-sh/uv/actions/runs/34667628374) |
| -------- |
-----------------------------------------------------------------: |
----------------------------------------------------------------: |
| Linux | 11s | 5.2s |
| macOS | 90s | 5.1s |
| Windows | 61s | 16s |
Co-authored-by: astral-automations-bot[bot] <305554984+astral-automations-bot[bot]@users.noreply.github.com>
Co-authored-by: konstin <[email protected]>
zaniebot and others added 14 commits September 18, 2026 09:10
Python console output uses platform-native line endings. Normalize newlines before comparing the complete executable and installed-metadata output, retaining exact dependency-version checks.

(cherry picked from commit d0c4769)
Consecutive executable writes can have the same Unix ctime. Give the existing well-formed interpreter cache entry a deliberately different timestamp, then assert that the real query path replaces its stale metadata and reuses the refreshed entry.

(cherry picked from commit 790bf8e)
@astral-automations-bot astral-automations-bot Bot added bug Something isn't working preview Experimental behavior labels Sep 18, 2026
@codspeed

codspeed Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 25 untouched benchmarks


Comparing zb/future-20260912-tool-executable-recovery (7cf3f0a) with zb/future-20260912-tool-executable-ownership (c83b22a)

Open in CodSpeed

@zaniebot zaniebot added risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. priority:2 Important: bounded correctness, release reliability, committed work, or proven performance gains. size:4 Complex: architectural or security-sensitive work requiring broad or cross-repository context. labels Sep 22, 2026
@zaniebot zaniebot added the build:skip-release Disable building release binaries for a pull request label Oct 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working build:skip-release Disable building release binaries for a pull request preview Experimental behavior priority:2 Important: bounded correctness, release reliability, committed work, or proven performance gains. risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. size:4 Complex: architectural or security-sensitive work requiring broad or cross-repository context.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants