Repository navigation
Conversation
On Windows the gate could not start: scripts/_uv.py pinned uv only for
the macOS and Linux tarballs, so it exited with "Install uv 0.13.7 to
run the gate on this bootstrap platform."
With uv installed by hand, generate.py --check still failed ("The
generated Python API differs"). The generator read openapi.public.json
with read_text() and no encoding, so on Windows Python used the legacy
code page (cp1252) and the UTF-8 "§" became "§" in a docstring. Its
text writes also used Windows line endings (CRLF), which ruff format
keeps. The committed files only matched because Git for Windows checks
them out as CRLF too.
Now:
- _uv.py pins the official x86_64 and aarch64 Windows zips of uv 0.13.7
and reads uv.exe from them, with the same checksum and version checks.
release_target() and unpack() hold the platform mapping and archive
reading; the tarball path is unchanged.
- generate.py and contracts.py read and write text as UTF-8, and the
generator's ruff format pass uses LF line endings.
- .gitattributes (* text=auto eol=lf) makes Windows clones check out LF
files, like CI.
Tests: tests/test_generate.py runs generate.py --check under a
non-UTF-8 default encoding (ASCII on Linux, cp1252 on Windows), and
tests/test_uv.py covers the platform mapping and both archive types.
Both fail on main and pass now. On Windows, a fresh clone with
core.autocrlf=true now passes the whole gate.
…s bootstrap Proofline review, round 1: - .gitattributes only changes how files are checked out from now on. A Windows clone made before it keeps CRLF files, so --check still said "differs" there, although Git stores the same LF content. files() now compares text with CRLF turned into LF (files containing a NUL byte, i.e. binary files, stay byte-exact). Line-ending drift can't be committed anyway: .gitattributes makes Git store LF. - Because the check now ignores line endings, a new test checks the generator's own output for CRLF, so the LF option stays covered. - test_uv.py only tested the helpers, so executable() could have asked for a .tar.gz or saved a file without .exe on Windows and still passed. A new test runs executable() for both Windows targets with a fake download and checks the .zip URL, the .exe path and the bytes. Each of the four guarded lines was mutated and made its test fail.
Proofline review, round 2: - The CRLF test called text() directly, so files() could stop using it and the test would still pass. It now compares files() on an LF folder and a CRLF folder, and checks that a file with a NUL byte is still compared byte for byte. - The LF test ran the whole generator, but on Linux the generator already writes LF, so CI could not notice if the LF option were removed. The ruff format step is now format_python(), and the test feeds it a CRLF file, so it fails on any OS without the option. - Nothing checked that a Windows zip with a wrong checksum is refused. A new test covers a fresh download (refused and never saved) and a cached archive (refused and never extracted). Each guarded line was mutated and made its test fail.
…rap tests Proofline review, round 3: - The Windows bootstrap test accepted any version check. It now records which executable matching() was asked about and expects exactly the returned uv.exe. - The wrong-checksum test now fails if unpack() runs, so an archive can't be unpacked before its checksum is checked. Both were mutation-checked: skipping the version check, or unpacking a cached archive before verifying it, now fails a test.
Proofline review, round 4: the Windows tests always made the version check succeed, so executable() could ignore its result and still pass. A new test serves a zip with a valid checksum, makes the version check fail, and expects "The verified uv executable has an unexpected version." Ignoring the result (mutation) now fails the test.
This branch has not been deployed
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.
Fixes #87
The problem in one sentence
python scripts/check.py, the check the README asks contributors to run, can't run on Windows. It has no Windows build of its pinneduvtool. Its "is the generated code up to date?" step also fails there, because on Windows the generator writes§as§and uses Windows line endings.Why it happens, step by step
scripts/_uv.pypins checksums only for the macOS/Linux.tar.gzarchives. On Windows it stops withInstall uv 0.13.7 to run the gate on this bootstrap platform.scripts/generate.py:88readsopenapi.public.jsonwithread_text()and no encoding. On Windows, Python then uses the legacy code page (cp1252), not UTF-8. The two UTF-8 bytes of§become the two characters§, which land in a generated docstring (models/customer_review_detail.py).ruff formatkeeps the ending it finds. So the generator's output is CRLF there.generate.py --checkcompares the output with the committedproofline/_generatedbyte for byte. The repo has no.gitattributes, so Git for Windows (defaultcore.autocrlf=true) checks the LF files out as CRLF. The line endings match only by accident, the§file always differs, and the step fails withThe generated Python API differs; run scripts/generate.py.I first thought the cause was only the CRLF checkout. A clone with LF files still failed, and comparing the two outputs showed the encoding bug.
Who is affected
Windows contributors without WSL. They can't run the gate. If they run
scripts/generate.pyafter an API change, they would commit§mojibake and CRLF files. Linux, macOS and CI are not affected today, and they behave the same after this PR.What this PR changes
scripts/_uv.py: adds the checksums of the two official Windows archives (x86_64-pc-windows-msvc,aarch64-pc-windows-msvc), copied from the.sha256files of the uv 0.13.7 release; I recomputed them from the downloaded zips and they match. Two small helpers:release_target(system, machine)mapsWindowsand theAMD64/ARM64names Windows reports.unpack(content, target)readsuv.exefrom the zip, oruv-<target>/uvfrom the tarball, exactly as before.The download, the checksum checks (before saving and again before use) and the version check are unchanged. On Windows the archive is
.zipand the saved binary ends in.exe.scripts/generate.py: every text read and write now saysencoding="utf-8".ruff formatruns with--config "format.line-ending = 'lf'", so the generated files are LF on every OS.--checkcompares text files with CRLF turned into LF (files with a NUL byte stay byte-exact), so a clone made before.gitattributesexisted also passes. Git stores LF anyway, so this hides no real drift.scripts/contracts.py: reads the same document and the Python sources as UTF-8 (the same latent bug; it passes today only because it reads IDs, not descriptions)..gitattributes:* text=auto eol=lf. Windows clones now check out LF, like CI. No file in the repo is stored with CRLF, and Git still detects binaries itself (text=auto).Why not the obvious alternatives
--checkcomparison: not enough on its own.generate.pywould still write mojibake on Windows. So the comparison ignores line endings (for old CRLF clones), and the generator itself is also fixed and tested.PYTHONUTF8=1incheck.py: this fixes only the gate. People runningscripts/generate.pydirectly would still get§. Explicit encodings also match what the script already tells the generator library (file_encoding="utf-8",generate.py:133).How I tested it (Windows 11, Python 3.13.12, Git for Windows with
core.autocrlf=true)Before (upstream
main48c4489):py scripts/check.py(only winget's uv 0.13.6 onPATH)Install uv 0.13.7 to run the gate on this bootstrap platform., exit 1PATHThe generated Python API differs; run scripts/generate.py., exit 1(§55)vs(§55)§fileNew tests, written first, RED on
main:tests/test_generate.py::test_generation_does_not_depend_on_the_locale_encodingrunsgenerate.py --checkwith-X utf8=0,LC_ALL=CandPYTHONCOERCECLOCALE=0. That forces a non-UTF-8 default encoding: ASCII on Linux, cp1252 on Windows, so CI catches a regression too. Onmainit fails with "differs".tests/test_uv.py: the four platform mappings have a pinned archive,uv.exeis read from a Windows zip, and the Unix tarball path still works. Onmainthey fail (no Windows target, nounpack).Mutation check: I removed
encoding="utf-8"fromgenerate.py:88, and separately removed theline-ending = 'lf'option. Each makes the new test fail, and the file was restored byte for byte.After (this branch):
4913069: exit 0, 233 tests.core.autocrlf=true: all 255 text files check out as LF, andpy scripts/check.pyexits 0 on the first run. It downloadsuv-x86_64-pc-windows-msvc.zip, verifies the checksum and extractsuv-0.13.7-x86_64-pc-windows-msvc.exe. Then generation, contracts, Ruff, format, mypy, 226 tests, the wheel and sdist builds and both install smoke tests all pass:Python SDK generation, HTTP contracts, wheel and source installs passed.unpack()and covered bytest_unix_archive_still_yields_its_uv_executable. The fork's Ubuntu CI runs the full gate, including the new tests.Known, separate: in about 2 of 5 full Windows runs, one existing test fails:
tests/test_http.py::test_body_stream_deadline_does_not_turn_authority_into_timeout[403-sync]. It fails withProoflineError: Proofline request failed (HTTP 0)after a WindowsConnectionResetError(WinError 10054). That's about 1 in 5 when run alone. This PR doesn't touch the test or the code it tests. I'll look at it separately; it may be a real Windows behaviour of the sync client.Existing Windows clones (CRLF files from before
.gitattributes) pass too. I converted all 212 generated files to CRLF andgenerate.py --checkexited 0.Linux: the fork's Ubuntu CI (
check) passes the full gate with the new tests.Proofline review log
Fork review PR: Ahmar004#1. 4 rounds (the cap): 12 findings, 8 fixed, 4 disagreed (with reasons below). CI green on every round. A 5th review starts automatically on
4913069; it isn't answered (cap).--checkstill fails in a clone made before.gitattributes(CRLF files).gitattributesdoesn't rewrite existing files. Git stores LF anyway, so comparing with line endings normalized hides nothing.19d891f: text compared CRLF→LF, binary exact; 2 new tests; 212-file CRLF copy passesexecutable(), so a.tar.gz/no-.exemistake would pass19d891f:executable()tested for both Windows targets with a fake download; mutation-checked.py+LICENSE); a NUL byte is Git's own binary test; an allow-list would need syncing with the templates.text(), notfiles()c7c8fe2: comparesfiles()on LF vs CRLF folders (+ binary stays exact)c7c8fe2:format_python()helper, test feeds it a CRLF filec7c8fe2: download (never saved) and cache (never extracted) casesformat_python()and tests would still pass.gitattributesmakes Git store LF, so it can't reach the repo; catching it on Linux needs faked text writes.3ededd9:matching()called once with the returneduv.exe3ededd9:unpackfails the test if calledLICENSEtemplate could give a CRLFLICENSEwithout failing--check4913069: wrong version →SystemExit; mutation-checked.sha256files and my own hashes; the real bootstrap accepted the official zip.