uv/crates/uv-python/src
Jack O'Connor 85358fe9c6 Keep track of retries in ManagedPythonDownload::fetch_with_retry
If/when we see https://github.com/astral-sh/uv/issues/14171 again, this
should clarify whether our retry logic was skipped (i.e. a transient
error wasn't correctly identified as transient), or whether we exhausted
our retries. Previously, if you ran a local example fileserver as in
https://github.com/astral-sh/uv/issues/14171#issuecomment-3014580701 and
then you tried to install Python from it, you'd get:

```
$ export UV_TEST_NO_CLI_PROGRESS=1
$ uv python install 3.8.20 --mirror http://localhost:8000 2>&1 | cat
error: Failed to install cpython-3.8.20-linux-x86_64-gnu
  Caused by: Failed to extract archive: cpython-3.8.20-20241002-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
  Caused by: failed to unpack `/home/jacko/.local/share/uv/python/.temp/.tmpS4sHHZ/python/lib/libpython3.8.so.1.0`
  Caused by: failed to unpack `python/lib/libpython3.8.so.1.0` into `/home/jacko/.local/share/uv/python/.temp/.tmpS4sHHZ/python/lib/libpython3.8.so.1.0`
  Caused by: error decoding response body
  Caused by: request or response body error
  Caused by: error reading a body from connection
  Caused by: Connection reset by peer (os error 104)
```

With this change you get:

```
error: Failed to install cpython-3.8.20-linux-x86_64-gnu
  Caused by: Request failed after 3 retries
  Caused by: Failed to extract archive: cpython-3.8.20-20241002-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
  Caused by: failed to unpack `/home/jacko/.local/share/uv/python/.temp/.tmp4Ia24w/python/lib/libpython3.8.so.1.0`
  Caused by: failed to unpack `python/lib/libpython3.8.so.1.0` into `/home/jacko/.local/share/uv/python/.temp/.tmp4Ia24w/python/lib/libpython3.8.so.1.0`
  Caused by: error decoding response body
  Caused by: request or response body error
  Caused by: error reading a body from connection
  Caused by: Connection reset by peer (os error 104)
```

At the same time, I'm updating the way we handle the retry count to
avoid nested retry loops exceeding the intended number of attempts, as I
mentioned at
https://github.com/astral-sh/uv/issues/14069#issuecomment-3020634281.
It's not clear to me whether we actually want this part of the change,
and I need feedback here.
2025-07-01 09:52:19 -07:00
..
sysconfig Sync latest Python releases (#14381) 2025-07-01 03:44:18 +00:00
cpuinfo.rs Fix hard and soft float libc detection for managed Python distributions on ARM (#8498) 2024-10-29 23:46:21 +00:00
discovery.rs Bump MSRV and rust-toolchain version (#14303) 2025-06-27 10:27:45 -04:00
downloads.rs Keep track of retries in ManagedPythonDownload::fetch_with_retry 2025-07-01 09:52:19 -07:00
environment.rs Support transparent Python patch version upgrades (#13954) 2025-06-20 16:17:13 +02:00
implementation.rs Use the canonical ImplementationName -> &str implementation (#14337) 2025-06-28 09:42:18 -05:00
installation.rs Support transparent Python patch version upgrades (#13954) 2025-06-20 16:17:13 +02:00
interpreter.rs Include the canonical path in the interpreter query cache key (#14331) 2025-06-30 15:39:47 +00:00
lib.rs Support transparent Python patch version upgrades (#13954) 2025-06-20 16:17:13 +02:00
libc.rs make the error message clearer when running distroless containers (#13549) 2025-05-29 10:29:01 -07:00
macos_dylib.rs Install and remove managed Python to and from the Windows Registry (PEP 514) (#10634) 2025-01-23 14:13:41 +00:00
managed.rs Use the canonical ImplementationName -> &str implementation (#14337) 2025-06-28 09:42:18 -05:00
microsoft_store.rs Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00
platform.rs disfavor aarch64 windows in its own house (#13724) 2025-06-30 17:42:00 -04:00
pointer_size.rs Change "toolchain" to "python" (#4735) 2024-07-03 07:44:29 -05:00
prefix.rs Add uv- prefix to all internal crates (#7853) 2024-10-01 20:15:32 -04:00
python_version.rs Update schemars 1.0.0 (#13693) 2025-06-24 21:43:31 +02:00
target.rs Add uv- prefix to all internal crates (#7853) 2024-10-01 20:15:32 -04:00
version_files.rs Refactor PythonVersionFile global loading (#14107) 2025-06-20 15:31:32 -05:00
virtualenv.rs Consolidate logic for checking for a virtual environment (#14214) 2025-06-23 15:12:43 +02:00
windows_registry.rs Bump MSRV to 1.85 and Edition 2024 (#13516) 2025-05-18 19:38:43 -04:00