Repository navigation
feat: install CPython from uv-build by default on Linux and macOS - #62
Merged
Merged
Conversation
On Linux and macOS, a CPython install now takes the prebuilt uv-build archive when the uv-build index lists the version, and builds from source with pyenv otherwise. Windows, GraalPy, PyPy and Conda keep their current paths. - VFOX_PYTHON_USE_UV_BUILD is three-state: unset selects the default above, 0/false/no/off builds every CPython from source, and 1/true/yes/on uses uv-build only, as before. - Available lists the pyenv names together with the CPython releases only the index lists, newest first; pyenv -dev snapshots sort last. - A partial name such as python@3.12 resolves in the index first, so it installs the newest 3.12 that has an archive. Only a line the index does not list falls back to the combined list. latest is unchanged. - PreInstall sets the note "uv-build" on an archive. vfox passes the note to PostInstall in sdkInfo, so PostInstall makes no second index request. A source build refuses to start over a Python already in the install path. - With VFOX_PYTHON_MIRROR set and VFOX_PYTHON_UV_BUILD_MIRROR unset, CPython stays on the python.org mirror and builds from source, because uv-build downloads come from GitHub. - An index that cannot be read fails the install and names VFOX_PYTHON_USE_UV_BUILD=0; it never starts a silent source build. - The source-build E2E subtests set VFOX_PYTHON_USE_UV_BUILD=0, and the container test installs the exact uv-build version. - A pyenv index failure reports the HTTP status instead of a Lua concatenation error.
latest stays the newest entry of the combined list. It is not resolved in the uv-build index, because that would silently install an older release, or a pre-release the index lists in place of a final one. The newest release comes from its archive when the index lists it, and is built from source, with a line saying so, when it does not. Add a test for the case where pyenv lists a newer release than the index, and document the behaviour in English and Chinese.
Bring in #61 (read Python's MSIs from the installer, drop vendored WiX). The only textual conflict was the require list at the top of lib/util.lua. Both requires stay: python_version (this branch) and bundle (main). The other files merged without conflicts; the merged tree passes vfox plugin test with vfox 1.1.0, the glua Windows layout test, stylua and go vet.
…s for latest With VFOX_PYTHON_USE_UV_BUILD=1 the list kept the order the index returned, and latest took its first entry, so latest depended on that order. The pyenv list sorted names with compare_versions, which reads 3.13.18t as 3.13.0. The uv-build list and the pyenv list now use one comparator, python_version.newer_first: release numbers first, then a final build before its free-threaded build before its pre-release, with snapshots last. latest is now the first entry that is not a free-threaded build. A free-threaded build is installed only when its name asks for it, as the README describes, so latest never selects one. The =1 test now expects the newest-first list, and new tests cover the comparator, the pyenv order and latest.
The uv-build and pyenv index requests were sent once, so a brief network error, HTTP 429 or 5xx failed a CPython install in the default mode. A transient failure is now sent again: up to three attempts in all, with pauses of one and then two seconds, and each retry is announced. A failure that persists still fails the install and names VFOX_PYTHON_USE_UV_BUILD=0. The default mode does not fall back to a source build for it, and other statuses such as 404 are not retried. The pause is replaced in the tests that fail an index, because os.execute is disabled in plugin tests. tests/index_retry_test.lua covers the retries, the pause commands on Linux and Windows, and the pyenv index. The default-mode tests count the requests that a failing index receives.
latest selects the newest standard release even when a free-threaded build is newer, and a free-threaded build is installed only when its name asks for it. Both modes are tested (uv_build_test.lua and uv_build_default_test.lua); the English and Chinese version pages now say so as well.
An index request reads the Retry-After header, in seconds, and waits for it when it is at most ten seconds. Without a usable header it waits one second, then two. A longer Retry-After fails at once and names the wait. HTTP-date values are not read. A 200 response that is not the index is sent again too. Before, an HTML page raised a Lua error, and a JSON object without the list was read as an empty list. The body check is inside the retry loop, so it applies to both indexes. The reads and the waits live in readIndex in lib/util.lua. The tests cover the Retry-After forms, the captive-portal body, the pause commands on Linux and Windows, and the uv-build and pyenv indexes.
test.yml runs a search through a closed proxy on Windows, with VFOX_PYTHON_USE_UV_BUILD=1. It must fail after three attempts, show two retries, and take at least three seconds, which only happens when the PowerShell pause runs through os.execute. The plugin tests never sleep, so this is the only check of the real Windows wait. lint.yml gets a docs job that runs .github/scripts/check_docs_parity.py. It compares each Chinese page with its English page: both exist, both name the same VFOX_* variables, both have the same number of fenced code blocks, and every relative link resolves. Sentences are not compared; translations differ on purpose.
The index retries, Retry-After and the archive download limit are described in English and Chinese. The stale getIndexWithRetry references are gone. The Chinese pages changed in this branch were read against their English pages. The mirror paragraph now names VFOX_PYTHON_UV_BUILD_MIRROR instead of "this mirror", and a few sentences were reworded for clarity.
The search in the Windows retry check is meant to fail. Its exit code stayed in $LASTEXITCODE, which the runner reads, so the step failed even though every check held: run 43580252144 waited 5.8 seconds, reported three attempts and two retries. The step now exits 0 once its checks pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Linux and macOS, a CPython install now takes the prebuilt uv-build archive when the uv-build index lists the version, and builds from source with pyenv otherwise. Windows, GraalPy, PyPy and Conda keep their current paths.
A default install no longer needs a C toolchain or the
-devpackages a source build needs. uv-build archives are the python-build-standalone builds that uv itself installs CPython from. Installs that already exist are not touched.Behaviour
VFOX_PYTHON_USE_UV_BUILD0,false,no,off1,true,yes,onvfox search pythonlists the pyenv names together with the CPython releases only the index lists. Every list is newest first, and pyenv-devsnapshots sort last.python@3.12resolves in the index first, so it installs the newest 3.12 that has an archive. Only a line the index does not list falls back to the combined list, and is built from source.latestis the first entry of the list that is not a free-threaded build. It is not resolved in the index. A free-threaded build such as3.13.18tis installed only when its name asks for it, even when it is newer than every standard release.Retry-Afterin seconds when it is at most ten; otherwise it waits one second, then two. A longerRetry-Afterfails at once and names the wait. Other statuses, such as 404, are not retried.VFOX_PYTHON_USE_UV_BUILD=0. It never starts a silent source build.VFOX_PYTHON_MIRRORset andVFOX_PYTHON_UV_BUILD_MIRRORunset, CPython stays on the python.org mirror and builds from source, because uv-build downloads come from GitHub.Design notes
uv-build, and vfox passes the note to PostInstall insdkInfo. PostInstall makes no second index request, so it cannot disagree with PreInstall or fail after a download. Checked with vfox 1.0.13 and 1.1.0.python@3.12installs the older patch the index lists. Name the exact version to build the newer one.lateststays on the newest standard release. Resolving it in the index would silently install an older release while pyenv is ahead. It also skips free-threaded builds even when they are newer, as uv does by default for Python 3.13. A free-threaded build is installed only when its name asks for it.python_version.newer_first, solatestno longer depends on the order the index returns.readIndexinlib/util.luasends a request again in the cases above, with a warning for each retry. A failure that persists is an error that namesVFOX_PYTHON_USE_UV_BUILD=0; the default mode does not fall back to a source build for it.Tests
vfox plugin test .with vfox 1.1.0, the version CI pins: every test file passes, including the newtests/index_retry_test.lua.tests/index_retry_test.luacovers a 503, a transport error, and a 429 followed by a 500, each of which ends in success after retries; a persistent 503 or transport error stops after three attempts; a 404 is not retried;Retry-Afterin seconds is used in any letter case, and a value above ten seconds fails at once; an HTTP date is ignored; a 200 with an HTML page, or with JSON that lacks the list, is sent again; the pyenv index is retried too; and the Linux and Windows pause commands are checked.tests/uv_build_default_test.luaandtests/uv_build_test.luacount the requests that a failing index receives.test.yml(Windows leg): a search through a closed proxy withVFOX_PYTHON_USE_UV_BUILD=1must fail after three attempts, show two retries, and take at least three seconds. The plugin tests never sleep, so this is the only check of the real Windows wait.lint.ymldocs:.github/scripts/check_docs_parity.pychecks that every page has its counterpart in the other language, that both pages of a pair name the sameVFOX_*variables and have the same number of fenced code blocks, and that relative links resolve.stylua --check ., actionlint 1.7.7 on the workflows, the glua Windows installer layout test, and the docs check.HTTPS_PROXY=http://127.0.0.1:9): fails after about 6 s; each index is sent three times, with two warnings each, and both failures are listed.VFOX_PYTHON_USE_UV_BUILD=1through the closed proxy: fails after about 3 s, with two warnings andafter 3 attempts.VFOX_HOME: about 0.9 s, no warnings, 999 entries.VFOX_PYTHON_USE_UV_BUILD=1, network, freshVFOX_HOME: about 1.5 s, no warnings, 10 entries. The real uv-build index passes the new body check.python@3.12resolves to 3.12.16 and installs from the archive; vfox 1.0.13python@3.12.16installs from the archive;python@2.7.18, which the index lacks, falls back to a pyenv source build.Not verified here, and known limits
Retry-Afteris not read; the fixed wait applies instead.