fix(pm): give the download hint only to network timeouts; hoist index_config imports
A bare 'operation timed out' can be a local write on a network mount, so the UV_CONCURRENT_DOWNLOADS hint now also needs uv's download/fetch wording. pm.index_config is stdlib-only, so its names import at module top.
This commit is contained in:
@@ -20,6 +20,7 @@ import time
|
||||
from typing import TextIO
|
||||
|
||||
from pm.filesystem import native
|
||||
from pm.index_config import TIMEOUT_HINT, bridged_index_settings, is_forwarded, is_index_redirect
|
||||
from pm.package import InstallError
|
||||
from pm.progress import LiveTail, TextSink, verbose_output
|
||||
|
||||
@@ -48,6 +49,9 @@ _RESOLVER_MARKERS = (
|
||||
|
||||
# A package's own build ran and failed; a fetch/download failure never prints this.
|
||||
_BUILD_MARKERS = ("the build backend returned an error",)
|
||||
# uv's wording for a network fetch that failed; a bare "operation timed out" can
|
||||
# also be a local write on a network mount, which download settings cannot fix.
|
||||
_HTTP_FAILURE_MARKERS = ("failed to download", "failed to fetch", "request failed after")
|
||||
|
||||
# The index omitted upload times (no PEP 700 metadata), so the release-age cutoff
|
||||
# cannot date the file. uv words it as "no solution", but the index is at fault,
|
||||
@@ -118,10 +122,8 @@ def classify_uv_failure(stage: str, returncode: int, output: str) -> InstallErro
|
||||
from pm.build_compilers import missing_compiler_remedy
|
||||
|
||||
return BuildFailure("venv", cause, missing_compiler_remedy(output))
|
||||
if "operation timed out" in lowered:
|
||||
if "operation timed out" in lowered and any(marker in lowered for marker in _HTTP_FAILURE_MARKERS):
|
||||
# uv gave up on its own HTTP timeout/retries before PM's deadline (#148262).
|
||||
from pm.index_config import TIMEOUT_HINT
|
||||
|
||||
return InstallError("venv", cause, TIMEOUT_HINT)
|
||||
return InstallError("venv", cause)
|
||||
|
||||
@@ -252,7 +254,6 @@ def _base_environment(env: Mapping[str, str] | None = None) -> dict[str, str]:
|
||||
Index and transport settings are the exception (pm.index_config): without
|
||||
them mirrored and air-gapped networks cannot resolve anything.
|
||||
"""
|
||||
from pm.index_config import bridged_index_settings, is_forwarded
|
||||
|
||||
source = os.environ if env is None else env
|
||||
base = {key: value for key, value in source.items()
|
||||
@@ -354,8 +355,6 @@ class PythonEnvironment:
|
||||
# mirror to resolve. Index-REDIRECT settings are dropped; transport
|
||||
# knobs (pm.index_config.FORWARDED_UV_SETTINGS minus the redirects)
|
||||
# survive — corporate and slow networks need them to reach the pinned URLs.
|
||||
from pm.index_config import is_index_redirect
|
||||
|
||||
env = {key: value for key, value in env.items() if not is_index_redirect(key)}
|
||||
# uv is a child: it gets the ordinary spelling of store paths (pm.filesystem.native),
|
||||
# or the venv it writes would record the extended-length one in pyvenv.cfg.
|
||||
@@ -403,8 +402,6 @@ class PythonEnvironment:
|
||||
return subprocess.run(command, cwd=native(cwd), env=env, capture_output=True,
|
||||
text=True, encoding="utf-8", errors="replace", timeout=timeout, check=False)
|
||||
except subprocess.TimeoutExpired as exc:
|
||||
from pm.index_config import TIMEOUT_HINT
|
||||
|
||||
# A silent stall against an unreachable index is the #95608 shape;
|
||||
# name the mirror knobs instead of surfacing a raw TimeoutExpired.
|
||||
raise InstallError("venv", f"uv {args[0]} timed out after {timeout}s", TIMEOUT_HINT) from exc
|
||||
|
||||
@@ -144,3 +144,5 @@ def test_uv_own_download_timeout_names_the_concurrency_knob():
|
||||
" Caused by: Request failed after 5 retries in 127.8s\n"
|
||||
" Caused by: operation timed out\n")
|
||||
assert "UV_CONCURRENT_DOWNLOADS" in classify_uv_failure("sync", 1, output).remedy
|
||||
local_write = "error: Failed to write to the cache\n Caused by: operation timed out\n"
|
||||
assert "UV_CONCURRENT_DOWNLOADS" not in classify_uv_failure("sync", 1, local_write).remedy
|
||||
|
||||
Reference in New Issue
Block a user