Nice work. I've some questions before approving
cargo build --timings -p red_knot
48 | // Write file or directory explicitly | ||
49 | // Some unzip tools unzip files with directory paths correctly, some do not! | ||
50 | if path.is_file() { | ||
51 | println!("adding file {path:?} as {name:?} ..."); |
Can we remove the println statements? Especially if they clutter the CLI output
Login to write a write a comment.
Summary
Work towards #11653.
This PR adds a
build.rs
script to thered_knot
crate that compresses our vendored typeshed stubs into a zip that is then included in the Ruff binary viainclude_bytes!()
inmodule.rs
. This will enable us to resolve modules to vendored stdlib stubs from typeshed in the future.Details:
build.rs
script is run before anything else in the crate is builtcargo:rerun-if-changed
directive to stdout to let Cargo know that thebuild.rs
only needs to be rerun if the contents ofcrates/red_knot/vendor/typeshed
changes, or if thebuild.rs
script itself changes. Docs here: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed. We need to use a syntax for this directive that's officially deprecated, due to the fact that our pinned minimum Rust version is old enough that it doesn't support the new version. (The deprecated syntax iscargo:rerun-if-changed=
, with one colon. The new syntax usescargo::rerun-if-changed=
, with two colons.).gitignored
. Unfortunately there will be a need to manually keep that.gitignore
entry in sync with the hardcoded path inbuild.rs
.zip
crate. Following the precedent in astral-sh/uv#3642, I pinned to an old version of thezip
crate, and added a Renovate rule to make sure that we don't get dependency-update PRs for that crate.Test Plan
Some basic tests have been added that show that the zip archive containing typeshed is available from the Ruff after it has been built, and that the zip archive has some stdlib stubs in it.