Repository navigation
Commit 7bbe763
authored
Fix require-runtime-dependencies being ignored for build hooks (#2257)
PR #2073 (workspace support) introduced a separate `additional_dependencies`
list on `EnvironmentInterface` and changed `prepare_build_environment` to
extend that list with the dynamic build-hook dependencies discovered by
`get_required_build_deps` (e.g. project runtime deps when a build hook sets
`require-runtime-dependencies = true`).
Bug: by the time `prepare_build_environment` extends
`additional_dependencies`, the cached property chain that consumes it:
`dependencies_complex` -> `all_dependencies_complex` -> `missing_dependencies`
has already been populated by the preceding `prepare_environment` call (via
`dependency_hash()` and `dependencies_in_sync()`) with the *empty*
`additional_dependencies` snapshot.
The second `sync_dependencies()` call then early-returns because the
cached `missing_dependencies` reflects the pre-mutation deps which have
just been installed — so the runtime deps never get installed and the
build hook fails with `ModuleNotFoundError`.
Before PR #2073, this worked because the old code mutated the cached
`dependencies` list in place and the old `sync_dependencies` reinstalled
the entire list via pip — there was no cached `missing_dependencies`
short-circuit.
Fix: add `EnvironmentInterface.add_additional_dependencies()` which extends
`additional_dependencies` and invalidates the dependent cached properties
(`dependencies_complex`, `dependencies`, `all_dependencies_complex`,
`all_dependencies`). `VirtualEnvironment` extends it to also invalidate its
own `distributions` and `missing_dependencies` caches. Update
`prepare_build_environment` to use it.
Add a regression test that primes the caches before extending and asserts
the new deps are visible and the virtual environment caches are cleared.1 parent ac9c0c9 commit 7bbe763
4 files changed
Lines changed: 66 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
410 | 423 | | |
411 | 424 | | |
412 | 425 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
2288 | 2290 | | |
2289 | 2291 | | |
2290 | 2292 | | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
2291 | 2336 | | |
2292 | 2337 | | |
2293 | 2338 | | |
| |||
0 commit comments