Repository navigation
Installer (Windows): fall back to the python-build-standalone mirror for uv-managed Python - #14686
Conversation
…for uv-managed Python
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36eef8d976
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ($Tool -eq 'python') { | ||
| if ($env:UV_PYTHON_INSTALL_MIRROR) { return $true } | ||
| $pattern = '^\s*python-install-mirror\s*=' |
There was a problem hiding this comment.
Honor UV_CONFIG_FILE before accepting a Python mirror
When UV_CONFIG_FILE points to a custom uv.toml without python-install-mirror, but a discovered file such as %APPDATA%\uv\uv.toml contains that setting, this new branch incorrectly concludes that Python already has a mirror configured. uv specifies that an explicit config file is used in place of discovered configuration files (uv configuration files), so uv python install will use neither the ignored configured mirror nor the generated npmmirror fallback, and a blocked Astral download still fails. Restrict the scan to UV_CONFIG_FILE when it is set, and likewise avoid treating disabled configuration as active.
Useful? React with 👍 / 👎.
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…th UV_NO_CONFIG uv reads an explicit config file in place of the discovered ones, so a Python mirror (or index) in %APPDATA%\uv\uv.toml did not apply and must not stop the fallback. [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f139ea53ab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # uv reads UV_CONFIG_FILE in place of every discovered file, and none with UV_NO_CONFIG. | ||
| $files = @($env:UV_CONFIG_FILE, "$env:APPDATA\uv\uv.toml", "$env:ProgramData\uv\uv.toml") | ||
| $dir = (Get-Location -PSProvider FileSystem).ProviderPath | ||
| if ($env:UV_NO_CONFIG -and $env:UV_NO_CONFIG -notmatch '^(0|false|no|off)$') { $files = @(); $dir = $null } |
There was a problem hiding this comment.
Use uv's bool parser for UV_NO_CONFIG
When UV_NO_CONFIG is set to n or f, uv treats it as false (as the existing Test-UvEnvFlag helper documents), but this condition treats every value except 0, false, no, and off as true. In that configuration, uv still reads a discovered uv.toml, while the fallback ignores it and may export mirror environment variables that override the user's configured index or Python mirror. Use Test-UvEnvFlag 'UV_NO_CONFIG' here so the scan follows uv's full boolean syntax.
Useful? React with 👍 / 👎.
| if ($Tool -eq 'python') { | ||
| if ($env:UV_PYTHON_INSTALL_MIRROR) { return $true } | ||
| $pattern = '^\s*python-install-mirror\s*=' |
There was a problem hiding this comment.
Respect the general Astral mirror for Python
When a caller sets UV_ASTRAL_MIRROR_URL, this check still arms the Python fallback because it only recognizes UV_PYTHON_INSTALL_MIRROR. If the probe of the public Astral endpoint is slow or blocked, the fallback exports UV_PYTHON_INSTALL_MIRROR for npmmirror; uv documents that this more-specific variable takes precedence over UV_ASTRAL_MIRROR_URL, so the managed-Python download silently bypasses the operator's corporate Astral mirror. The pinned uv 0.12.1 supports this variable because it was added in 0.11.14; treat it as an already-configured Python source before adding the host. See the uv environment-variable reference.
Useful? React with 👍 / 👎.
…at UV_ASTRAL_MIRROR_URL as a Python mirror UV_PYTHON_INSTALL_MIRROR wins over UV_ASTRAL_MIRROR_URL in uv, so arming the npmmirror fallback would bypass the operator's Astral mirror. [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c11154924c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $files = @($env:UV_CONFIG_FILE, "$env:APPDATA\uv\uv.toml", "$env:ProgramData\uv\uv.toml") | ||
| $dir = (Get-Location -PSProvider FileSystem).ProviderPath | ||
| # uv's bool parser (Test-UvEnvFlag), inlined: setup.ps1 reaches this before it defines that helper. | ||
| if (@('1', 't', 'true', 'y', 'yes', 'on') -contains "$env:UV_NO_CONFIG".Trim().ToLowerInvariant()) { $files = @(); $dir = $null } |
There was a problem hiding this comment.
Honor UV_NO_SYSTEM_CONFIG when scanning mirror settings
When UV_NO_SYSTEM_CONFIG is truthy and %ProgramData%\uv\uv.toml defines python-install-mirror, the new Python scan still treats that ignored file as an active mirror and suppresses the npmmirror fallback, so a blocked public Python download can still fail. uv 0.11.16+ documents that UV_NO_SYSTEM_CONFIG prevents reading system-level configuration; apply uv's boolean parsing to this flag and exclude the ProgramData file in both PowerShell copies.
Useful? React with 👍 / 👎.
| if ("$env:UV_DEFAULT_INDEX$env:UV_INDEX_URL$env:UV_INDEX$env:UV_EXTRA_INDEX_URL") { return $true } | ||
| $pattern = '^\s*(\[\[(tool\.uv\.)?index\]\]|(pip\.)?(index|index-url|default-index|extra-index-url|no-index)\s*=)' | ||
| } | ||
| # uv reads UV_CONFIG_FILE in place of every discovered file, and none with UV_NO_CONFIG. |
There was a problem hiding this comment.
Start mirror discovery from uv's configured directory
When UV_PROJECT selects another project, or UV_WORKING_DIR/UV_WORKING_DIRECTORY changes uv's working directory, the new Python-mirror scan still walks upward from PowerShell's original Get-Location. uv documents that UV_PROJECT changes the root used to discover pyproject.toml and uv.toml, while UV_WORKING_DIR changes the working directory; consequently, a corporate Python mirror in the selected tree can be missed and overridden by UV_PYTHON_INSTALL_MIRROR, or an unrelated config in the original tree can suppress a needed fallback. Derive the scan root using uv's directory semantics in both PowerShell copies.
Useful? React with 👍 / 👎.
| return | ||
| } | ||
| if ($Output -match 'download(-r2)?\.pytorch\.org') { 'torch' } | ||
| elseif ($Output -match 'python-build-standalone') { 'python' } |
There was a problem hiding this comment.
Retry Python downloads rejected with HTTP 403
When a firewall or regional gateway blocks the public Python-build URL with 403 Forbidden, the initial probe keeps the default because its slow-host filter ignores 4xx responses, and the subsequent uv error still does not reach this new python-build-standalone classification because the preceding transport-error regex recognizes neither 403 nor Forbidden. The Python mirror spare therefore remains unused even though this is a common blocked-host response; recognize access-denial statuses here while retaining the intentional no-retry behavior for missing artifacts such as 404.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this one as is in this PR. The transport-error list is shared with install.sh's _mirror_failed_host and with every other host (PyPI, torch, npm), and neither installer treats a 4xx as a reason to switch mirrors: a 403 is as often an auth or policy answer from the user's own proxy as a regional block. Changing that belongs in its own change to both installers.
…_CONFIG, UV_PROJECT, UV_WORKING_DIR) [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 792c0c58d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $workDir = if ($env:UV_WORKING_DIR) { $env:UV_WORKING_DIR } else { $env:UV_WORKING_DIRECTORY } | ||
| if ($workDir) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $workDir)) } | ||
| if ($env:UV_PROJECT) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $env:UV_PROJECT)) } |
There was a problem hiding this comment.
Resolve UV_PROJECT from the invocation directory
When both UV_WORKING_DIR and a relative UV_PROJECT are set, this resolves the project relative to the working-directory override, but uv resolves the project from the original invocation directory. Fresh evidence beyond the prior comment: a local uv python find probe with configs at <cwd>/proj and <cwd>/work/proj selected <cwd>/proj, while this code scans <cwd>/work/proj; uv help python install also distinguishes changing only the project root from changing the working directory. The mismatch can miss the active corporate Python mirror or treat an ignored mirror as active, so derive both relative paths from the original $dir rather than applying them sequentially.
Useful? React with 👍 / 👎.
| } | ||
| if (-not $env:UNSLOTH_NODE_MIRROR) { $hosts['node'] = @('node', 'npmmirror-node', "$npmMirror/-/binary/node", $null, $null) } | ||
| if (-not "$env:UNSLOTH_NPM_REGISTRY$env:NPM_CONFIG_REGISTRY") { $hosts['npm'] = @('npm', 'npmmirror', $npmMirror, $null, $null) } | ||
| if (-not (Test-MirrorConfigured -Tool python)) { $hosts['python'] = @('astral', 'npmmirror', $pythonMirror, $null, $null) } |
There was a problem hiding this comment.
Probe the Python mirror tree before switching
When Astral is slow but usable and npmmirror's npm-package endpoint works while its /-/binary/python-build-standalone tree is unavailable, this entry immediately exports UV_PYTHON_INSTALL_MIRROR and removes the Python spare. The source named npmmirror is actually measured with the TypeScript tarball at line 4703, so none of the Python mirror content is verified; all managed-Python candidates then use the broken mirror and cannot return to the working Astral source. Probe a representative artifact from the Python-build tree, or retain Astral as a fallback after an eager switch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Keeping this as is. It is the same choice install.sh makes for its npmmirror Python source: the npmmirror host is measured once and every npmmirror tree it serves (node, npm, python-build-standalone) rides on that measurement. Probing a python-build-standalone artifact would need a version-specific filename that tracks uv's pin, which is a change for both installers, not this parity fix.
| if ($uvTrue -contains "$env:UV_NO_CONFIG".Trim().ToLowerInvariant()) { $files = @(); $dir = $null } | ||
| elseif ($env:UV_CONFIG_FILE) { $files = @($env:UV_CONFIG_FILE); $dir = $null } |
There was a problem hiding this comment.
Prefer UV_CONFIG_FILE over UV_NO_CONFIG
When a caller sets both a truthy UV_NO_CONFIG and an explicit UV_CONFIG_FILE, uv still reads the explicitly named file: uv help python install defines --no-config as avoiding configuration-file discovery, while --config-file explicitly selects a file, and a local uv probe confirmed that the selected file remains active. This branch instead empties $files before reaching the UV_CONFIG_FILE case, so it misses a configured Python mirror and may export the higher-precedence npmmirror variable over it. Check UV_CONFIG_FILE first and apply UV_NO_CONFIG only to discovered files.
Useful? React with 👍 / 👎.
| if ($Tool -eq 'python') { | ||
| # UV_ASTRAL_MIRROR_URL also serves Python builds, but UV_PYTHON_INSTALL_MIRROR would win over it. | ||
| if ("$env:UV_PYTHON_INSTALL_MIRROR$env:UV_ASTRAL_MIRROR_URL") { return $true } | ||
| $pattern = '^\s*python-install-mirror\s*=' |
There was a problem hiding this comment.
Recognize dotted Python-mirror keys in pyproject.toml
A valid pyproject.toml can express this setting as the TOML dotted key tool.uv.python-install-mirror = "https://corp.example/pbs" (uv accepts the equivalent dotted tool.uv.* structure), but this regex only recognizes a bare python-install-mirror line. The surrounding discovery check also looks only for a bracketed [tool.uv] header, so the configured mirror is missed and UV_PYTHON_INSTALL_MIRROR is exported, overriding the user's corporate source. Parse the tool.uv table or recognize dotted and inline-table forms rather than matching only the conventional layout.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not handling this here. The scan matches the conventional [tool.uv] / uv.toml layout, the same way the existing index check in this function and install.sh's _mirror_configured do. A full TOML read (dotted keys, inline tables) would change every one of those checks and belongs in its own change.
| if ($Tool -ne 'pip') { | ||
| if ($Tool -eq 'python') { | ||
| # UV_ASTRAL_MIRROR_URL also serves Python builds, but UV_PYTHON_INSTALL_MIRROR would win over it. | ||
| if ("$env:UV_PYTHON_INSTALL_MIRROR$env:UV_ASTRAL_MIRROR_URL") { return $true } |
There was a problem hiding this comment.
Account for older accepted uv versions before honoring UV_ASTRAL_MIRROR_URL
When an existing uv 0.8.16 through 0.11.13 is reused, it ignores UV_ASTRAL_MIRROR_URL because that variable was added in 0.11.14, yet this return suppresses the Python fallback. Fresh evidence beyond the prior comment is the installer’s version gate at lines 6815 and 6884, which accepts any uv at least 0.8.16 instead of always installing the pinned 0.12.1. On a machine carrying that older uv and a globally defined variable, a blocked public Astral download therefore still fails; either raise the accepted uv version or recognize this variable only for a compatible selected executable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this as is. Before this PR, Windows had no Python fallback at all, so an old uv with UV_ASTRAL_MIRROR_URL set fails the same way it did on main; nothing regresses. Someone who sets that variable is pointing uv at their own mirror, and overriding it with npmmirror on a guess about the uv version would be the worse failure.
…, and read UV_CONFIG_FILE even with UV_NO_CONFIG
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e29528066e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| $start = if ($env:UV_PROJECT) { $env:UV_PROJECT } elseif ($env:UV_WORKING_DIR) { $env:UV_WORKING_DIR } else { $env:UV_WORKING_DIRECTORY } | ||
| if ($start) { $dir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($dir, $start)) } | ||
| if ($env:UV_CONFIG_FILE) { $files = @($env:UV_CONFIG_FILE); $dir = $null } |
There was a problem hiding this comment.
Resolve relative uv paths after changing directory
When UV_WORKING_DIR is combined with a relative UV_PROJECT or UV_CONFIG_FILE, this resolves those paths from the original PowerShell location. uv help python install documents that --directory changes directory before running and relative paths use that directory as their base; fresh evidence contrary to the prior comment is that the bundled uv 0.12.1 loaded <work>/proj/uv.toml and <work>/custom.toml in local probes, while this block checks the corresponding paths under <cwd>. Both this copy and studio/setup.ps1 can therefore miss the active corporate mirror and export UV_PYTHON_INSTALL_MIRROR over it, or suppress the fallback because an ignored file was found; resolve UV_WORKING_DIR first, then resolve the other relative paths against it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, and this reverses the previous round. Checked with uv python install --show-settings from a tree with proj/uv.toml, work/proj/uv.toml, custom.toml and work/custom.toml: UV_WORKING_DIR=work UV_PROJECT=proj picks work/proj, UV_WORKING_DIR=work UV_CONFIG_FILE=custom.toml picks work/custom.toml, and UV_CONFIG_FILE is still read under UV_NO_CONFIG. The scan now follows that order, with tests for each case. The downloads-manifest point is handled in the same commit.
| if ("$env:UV_PYTHON_INSTALL_MIRROR$env:UV_ASTRAL_MIRROR_URL") { return $true } | ||
| $pattern = '^\s*python-install-mirror\s*=' |
There was a problem hiding this comment.
Preserve custom Python download manifests
When a caller supplies UV_PYTHON_DOWNLOADS_JSON_URL, or configures python-downloads-json-url, this check still considers Python unconfigured and may export UV_PYTHON_INSTALL_MIRROR when Astral is slow or blocked. The manifest setting overrides uv's hardcoded installation list specifically so operators can provide custom download URLs, and uv currently errors when a mirror variable is combined with a manifest URL that does not have the expected python-build-standalone shape, as demonstrated in uv issue #17005. This makes a working internal or offline Python source fail only after the fallback activates; treat either custom-manifest setting as an already configured Python source.
Useful? React with 👍 / 👎.
…m UV_WORKING_DIR, and leave a custom Python downloads manifest alone Checked against uv python install --show-settings: uv changes to --directory first and resolves the relative paths from there. UV_PYTHON_DOWNLOADS_JSON_URL names its own URLs, and uv rejects it combined with a mirror (astral-sh/uv#17005). [skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42340b02a7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # uv's bool parser (Test-UvEnvFlag), inlined: setup.ps1 reaches this before it defines that helper. | ||
| $uvTrue = @('1', 't', 'true', 'y', 'yes', 'on') | ||
| $files = @("$env:APPDATA\uv\uv.toml") | ||
| if ($uvTrue -notcontains "$env:UV_NO_SYSTEM_CONFIG".Trim().ToLowerInvariant()) { $files += "$env:ProgramData\uv\uv.toml" } |
There was a problem hiding this comment.
Gate UV_NO_SYSTEM_CONFIG handling on uv version
When the installer reuses uv 0.8.16–0.11.15 and UV_NO_SYSTEM_CONFIG is truthy, this excludes %ProgramData%\uv\uv.toml even though those uv versions still read it—the variable was only added in uv 0.11.16. Since install.ps1 accepts uv as old as 0.8.16 at line 6818, a corporate python-install-mirror in the system config can be missed and then overridden by the npmmirror environment fallback when Astral is slow. Fresh evidence beyond the earlier system-config comment is this mismatch between the newly honored flag and the existing old-uv reuse gate; either raise the minimum version or ignore this flag for uv versions that do not support it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this one. Someone who sets UV_NO_SYSTEM_CONFIG has asked for the system file to be ignored, and the narrow overlap (that variable set, an old uv reused, a Python mirror only in %ProgramData%, and a slow Astral) does not justify version-gating each flag. The fallback is also never worse than main here, which has no Python fallback on Windows at all.
| # UV_ASTRAL_MIRROR_URL also serves Python builds, but UV_PYTHON_INSTALL_MIRROR would win over it; a | ||
| # custom downloads manifest names its own URLs, which uv rejects combined with a mirror. | ||
| if ("$env:UV_PYTHON_INSTALL_MIRROR$env:UV_ASTRAL_MIRROR_URL$env:UV_PYTHON_DOWNLOADS_JSON_URL") { return $true } | ||
| $pattern = '^\s*(python-install-mirror|python-downloads-json-url)\s*=' |
There was a problem hiding this comment.
Discover Python mirror settings from the workspace root
When setup runs inside a uv workspace member that has any local [tool.uv] configuration while the workspace root defines the corporate python-install-mirror, this scan stops at the member file and never reads the active root setting. uv instead begins configuration discovery at the workspace root and ignores member configuration, as documented in uv configuration files. The scanner therefore reports Python as unconfigured and, when Astral is slow, exports UV_PYTHON_INSTALL_MIRROR for npmmirror; because environment settings outrank files, that overrides the working corporate mirror. Resolve the workspace root before selecting the project configuration file in both PowerShell copies.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not handling workspace-root resolution in this scan. The installer runs from wherever the user launches it, not from inside a uv workspace member, and the existing index check in this function and install.sh's _mirror_configured stop at the first [tool.uv] file in the same way. Doing full workspace discovery would change all of those checks and belongs in its own change.
[skip ci]
[skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1528a49d76
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| if (-not $env:UNSLOTH_NODE_MIRROR) { $hosts['node'] = @('node', 'npmmirror-node', "$npmMirror/-/binary/node", $null, $null) } | ||
| if (-not "$env:UNSLOTH_NPM_REGISTRY$env:NPM_CONFIG_REGISTRY") { $hosts['npm'] = @('npm', 'npmmirror', $npmMirror, $null, $null) } | ||
| if (-not (Test-MirrorConfigured -Tool python)) { $hosts['python'] = @('astral', 'npmmirror', $pythonMirror, $null, $null) } |
There was a problem hiding this comment.
Probe the host uv actually uses for Python builds
When GitHub is slow or blocked but releases.astral.sh is healthy, this maps the Python check to the astral artifact at line 4704 and therefore leaves managed-Python downloads on the failing source. The bundled uv 0.13.5 says in uv help python install that --mirror replaces https://github.com/astral-sh/python-build-standalone/releases/download, so the uv-release probe does not measure the default Python-build host at all; a slow GitHub transfer can consequently sit through uv's long timeout/retries instead of triggering the eager npmmirror fallback. Give Python its own representative GitHub probe in both PowerShell copies rather than sharing the uv-binary probe.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Keeping the shared astral probe, as install.sh does: its python host is measured against the same uv-release artifact. A slow download that the eager probe misses is still covered by the failure path, since uv's error names python-build-standalone and that reruns the install once through the npmmirror spare. Giving Python its own probe would be a change to both installers.
| if ($Tool -eq 'python') { | ||
| # UV_PYTHON_INSTALL_MIRROR would override UV_ASTRAL_MIRROR_URL; uv rejects a mirror beside a custom manifest. | ||
| if ("$env:UV_PYTHON_INSTALL_MIRROR$env:UV_ASTRAL_MIRROR_URL$env:UV_PYTHON_DOWNLOADS_JSON_URL") { return $true } | ||
| $pattern = '^\s*(python-install-mirror|python-downloads-json-url)\s*=' |
There was a problem hiding this comment.
Restrict Python source keys to the active TOML table
When a pyproject.toml contains any [tool.uv] section plus an unrelated table that defines python-install-mirror or python-downloads-json-url, this file-wide regex treats that unrelated key as uv configuration and suppresses the Python spare. A probe with the bundled uv 0.13.5 using [tool.uv] followed by [tool.other] and python-install-mirror = "https://corp.invalid/pbs" reports python_install_mirror: None under uv python install --show-settings, while this function returns true; if the real Python-build host is unavailable, no npmmirror retry is armed. Scope these keys to [tool.uv] when scanning pyproject.toml while continuing to read them at the root of uv.toml.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not scoping the scan to the [tool.uv] table here. The existing index check in this function and install.sh's _mirror_configured read pyproject.toml the same line-based way, and a python-install-mirror key under some other tool's table is not a layout we see in practice. A real TOML read would change all of those checks and belongs in its own change.
`Repo tests (CPU, studio-install)` fails on `main` (c5482a5). Four tests fail in two groups, and both reproduce on a clean `main` checkout. ## `test_uv_boolish_parity.py::test_every_resolver_variable_in_shipped_powershell_goes_through_a_reader[install.ps1, setup.ps1]` #14686 added `Test-MirrorConfigured`'s uv config discovery. It decides `UV_NO_SYSTEM_CONFIG` and `UV_NO_CONFIG` with an inlined copy of uv's boolish set, because `setup.ps1` reaches that code before it defines `Test-UvEnvFlag`. The guard exists so every `UV_*` / `PIP_*` switch goes through the one reader, so the code is what needed to change: - Both scripts now call `Test-UvEnvFlag 'UV_NO_SYSTEM_CONFIG'` and `Test-UvEnvFlag 'UV_NO_CONFIG'`. - `setup.ps1` defines `Test-UvEnvFlag` / `Test-PipEnvFlag` ahead of `Test-MirrorConfigured`. The block moved unchanged, with one added comment line. `install.ps1` already defines it earlier in the same function. - New test `test_setup_defines_the_uv_reader_before_its_first_mirror_probe` pins that order. This hazard is what led to the inline copy in the first place. Behaviour is unchanged. Under `Set-StrictMode -Version Latest`, `Test-MirrorConfigured -Tool uv` returns the same answer on base and head, in both scripts, with a user `uv.toml` carrying an index and `UV_NO_CONFIG` set to each of unset, `off`, `0`, `no`, `YES`, ` 1 `, `true`. ## `test_rocm_native_linux_lib_dirs.py::TestLlamaCppRuntimeNativeOrdering` #14933 now holds the native-Linux ROCm dirs in `_system_rocm`, so it can skip them when they hide the GPU. The source check still looked for the old one-line `lib_dirs.extend(_native_linux_system_rocm_lib_dirs(binary_dir))`. The test was out of date. It now finds the helper call, follows the local it is assigned to, and still asserts two orderings: - helper call, then `lib_dirs.extend(...)`, then `lib_dirs.append(binary_dir)` - the WSL DXG decision comes before the native dirs ## Verification - `tests/studio/install/test_rocm_native_linux_lib_dirs.py` and `test_uv_boolish_parity.py`: 4 failed on `main`, 581 passed on this branch. - `tests/studio/install/test_denied_llama_cpp_preflight.py` (byte parity of the shared install/setup helpers): passes. - `pwsh tests/studio/test_mirror_fallback.ps1`: 142 PASS, 0 FAIL. - Sabotage checks: - Moving `lib_dirs.append(binary_dir)` above the native block fails the ROCm ordering test. - Restoring `main`'s `setup.ps1` fails both the reader test and the new ordering test.
On Linux and macOS,
install.shfalls back to the npmmirror python-build-standalone mirror (UV_PYTHON_INSTALL_MIRROR) when releases.astral.sh is slow or unreachable. On Windows,install.ps1had nopythonhost in its mirror table and ranuv python installwith-NoMirror, so a blocked astral download failed the managed Python install even with the mirror fallback on.Changes
install.ps1, copied tostudio/setup.ps1withscripts/sync_shared_ps1_helpers.py):Test-MirrorConfigured -Tool pythonrespects a userUV_PYTHON_INSTALL_MIRROR,UV_ASTRAL_MIRROR_URL(whichUV_PYTHON_INSTALL_MIRRORwould override), a custom downloads manifest (UV_PYTHON_DOWNLOADS_JSON_URL/python-downloads-json-url), orpython-install-mirrorin uv config.Test-MirrorConfiguredreads onlyUV_CONFIG_FILEwhen it is set and no file whenUV_NO_CONFIGis true by uv's bool rules, no system file withUV_NO_SYSTEM_CONFIG, changes toUV_WORKING_DIRfirst and resolves a relativeUV_PROJECT/UV_CONFIG_FILEfrom there, and still readsUV_CONFIG_FILEunderUV_NO_CONFIG, as uv does, so a mirror in a discovereduv.tomlthat uv will ignore no longer stops the fallback. This applies to the index check too.pythonhost (astral to npmmirror) maps toUV_PYTHON_INSTALL_MIRROR, named "releases.astral.sh (Python builds)".Get-MirrorFailedHostmapspython-build-standalonefailures to it.Invoke-InstallMirrorRetrytreatsuv python installfailures aspython, like_mirror_retry_installin install.sh.Resolve-UvManagedPythonno longer passes-NoMirror. A transport failure reruns once through the mirror;Pop-MirrorSpareuses the spare up, so later attempts do not retry again. With the fallback off nothing changes.UV_PYTHON_INSTALL_MIRRORis saved and restored with the other mirror variables.Tests
tests/studio/test_mirror_fallback.ps1: 142 passed here; on main the new Python checks fail (10 failures).scripts/sync_shared_ps1_helpers.py --checkmatches.tests/sh/test_mirror_fallback.sh(install.sh side, unchanged) 253 passed. Not run on a real Windows host behind a blocked astral.