From 4fbbaa4963f10ed77e9d08e438fcbc694ba1ddd4 Mon Sep 17 00:00:00 2001 From: Elijah Zupancic Date: Fri, 18 Sep 2026 10:31:44 -0700 Subject: [PATCH] fix(py): rebuild the bindings when their version or Rust changes `make worktree-setup` runs `uv sync`, and on a clean `main` it replaced a current 2.2.1 install of the bindings with a cached 2.1.1 build. The version is dynamic: maturin reads it from the crate's `Cargo.toml`, which inherits it from the workspace root. The extension also compiles the root and ast crates, one directory up. uv's default cache key watches only `pyproject.toml` and `setup.*`, so neither a version bump nor a Rust change ever invalidated the cached build. `[tool.uv].cache-keys` now lists what the build actually reads: the manifests, the lockfile and the Rust sources, following the template uv itself generates for a maturin project but pointed at this workspace member's parent directory. Setting the key replaces the default, so `pyproject.toml` is listed again. Verified on this checkout: - on `main`, `uv sync` downgraded 2.2.1 to 2.1.1; with the fix it rebuilds to 2.2.1 - a second sync with nothing changed is a no-op, so the keys do not force a rebuild on every run - touching `../src/lib.rs` or `../big-code-analysis-ast/src/lib.rs` rebuilds (`Built big-code-analysis`, extension mtime advances), so the parent-directory paths are honoured - with the fix stashed, the same touch does not rebuild, so the keys are what cause it `uv lock --check` is unaffected. `make pre-commit` never saw the stale build, because `py-test` runs `maturin develop` before testing. Also corrects the comment beside `dynamic = ["version"]`, which pointed at a `[tool.maturin].version` key that does not exist. --- CHANGELOG.md | 11 +++++++++++ big-code-analysis-py/pyproject.toml | 26 ++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dd0e4611..8c5d95e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -196,6 +196,17 @@ for historical reference. ### Fixed +- **`make worktree-setup` reinstalled a stale build of the Python + bindings.** Their version is dynamic — maturin reads it from the + workspace `Cargo.toml` — and the extension compiles the root and ast + crates one directory up, but uv's default cache key watches only + `pyproject.toml`. So a version bump or a Rust change never invalidated + the cached build, and `uv sync` replaced a current 2.2.1 install with + a cached 2.1.1. `big-code-analysis-py/pyproject.toml` now sets + `[tool.uv].cache-keys` to the manifests, the lockfile and the Rust + sources the build reads. `make pre-commit` was unaffected: `py-test` + rebuilds with `maturin develop` before testing. + - **A relational operator scored an ABC condition only inside a boolean slot** (#1461). `var b = x == 1;` reported `abc.conditions` 1 while `var b = x is int;` reported 0, and the same asymmetry held for diff --git a/big-code-analysis-py/pyproject.toml b/big-code-analysis-py/pyproject.toml index 14afdf89d..e845020fb 100644 --- a/big-code-analysis-py/pyproject.toml +++ b/big-code-analysis-py/pyproject.toml @@ -25,8 +25,10 @@ classifiers = [ "Topic :: Software Development :: Quality Assurance", "Typing :: Typed", ] -# Version is read from the Rust workspace's Cargo.toml at build time -# by maturin (see [tool.maturin].version below). +# Version is read at build time by maturin from this crate's +# `Cargo.toml`, which inherits it from the workspace root +# (`version.workspace = true`) — so it lives outside this directory, +# which is why `[tool.uv].cache-keys` below watches `../Cargo.toml`. dynamic = ["version"] [project.urls] @@ -44,6 +46,26 @@ Changelog = "https://github.com/dekobon/big-code-analysis/blob/main/CHANGELOG.md # matrices the project will never serve. [tool.uv] environments = ["sys_platform != 'emscripten' and python_full_version < '3.15'"] +# What invalidates uv's cached build of this package. uv's default watches +# only `pyproject.toml` / `setup.*`, but the version here is dynamic — maturin +# reads it from the *workspace* `Cargo.toml` — and the extension compiles the +# root and ast crates one directory up. Under the default a version bump or a +# Rust change never invalidated the cache, so `uv sync` (and so +# `make worktree-setup`) reinstalled a stale build over a current one: 2.2.1 +# replaced by a cached 2.1.1. This is uv's own `maturin` template — the +# manifest, the lockfile, the Rust sources — pointed at where this workspace +# member actually keeps them. Setting the key replaces the default, which is +# why `pyproject.toml` is listed again. +cache-keys = [ + { file = "pyproject.toml" }, + { file = "Cargo.toml" }, + { file = "src/**/*.rs" }, + { file = "../Cargo.toml" }, + { file = "../Cargo.lock" }, + { file = "../src/**/*.rs" }, + { file = "../big-code-analysis-ast/Cargo.toml" }, + { file = "../big-code-analysis-ast/src/**/*.rs" }, +] [project.optional-dependencies] # Test/lint dependencies. The canonical install path is