Skip to content

Commit 5c22357

Browse files
authored
Merge pull request #779 from tiran/uv-safe-cache-clean
feat: uv cache clean is concurrency safe
2 parents 712a0a9 + a217071 commit 5c22357

6 files changed

Lines changed: 7 additions & 12 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies = [
4848
"tomlkit",
4949
"tqdm",
5050
"wheel",
51-
"uv",
51+
"uv>=0.8.19",
5252
]
5353

5454
[project.optional-dependencies]

src/fromager/bootstrapper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ def _build_wheel(
422422
version=resolved_version,
423423
build_env=build_env,
424424
)
425-
# invalidate uv cache
426-
self.ctx.uv_clean_cache(req)
427425
server.update_wheel_mirror(self.ctx)
428426
# When we update the mirror, the built file moves to the
429427
# downloads directory.

src/fromager/commands/build.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ def build(
118118
force=True,
119119
cache_wheel_server_url=None,
120120
)
121-
# invalidate uv cache
122-
wkctx.uv_clean_cache(req)
123121
print(entry.wheel_filename)
124122

125123

@@ -435,8 +433,6 @@ def _build(
435433
version=resolved_version,
436434
build_env=build_env,
437435
)
438-
# uv cache is cleaned in build / build_parallel commands
439-
# wkctx.uv_clean_cache(req)
440436

441437
hooks.run_post_build_hooks(
442438
ctx=wkctx,
@@ -731,9 +727,6 @@ def update_progressbar_cb(future: concurrent.futures.Future) -> None:
731727
logger.error(f"Failed to build {node.key}: {e}")
732728
raise
733729

734-
# invalidate uv cache
735-
wkctx.uv_clean_cache(*reqs)
736-
737730
metrics.summarize(wkctx, "Building in parallel")
738731
_summary(wkctx, entries)
739732

src/fromager/commands/step.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,5 @@ def build_wheel(
224224
version=dist_version,
225225
build_env=build_env,
226226
)
227-
wkctx.uv_clean_cache(req)
228227
requirement_ctxvar.reset(token)
229228
print(wheel_filename)

src/fromager/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def uv_clean_cache(self, *reqs: Requirement) -> None:
141141
cache location. This function removes a package from all caches, so
142142
subsequent installations use a new built.
143143
144-
WARNING: 'uv clean cache' is not concurrency safe with 'uv pip install'.
144+
'uv clean cache' is concurrency safe since 0.8.19.
145145
"""
146146
if not reqs:
147147
raise ValueError("no requirements")

src/fromager/wheels.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ def build_wheel(
361361
)
362362
validate_wheel_filename(req=req, version=version, wheel_file=new_wheel_file)
363363

364+
# invalidate uv cache, so the new wheel is picked up. The step is only
365+
# relevant for local development when a package is rebuilt multiple times
366+
# without bumping the build tag.
367+
ctx.uv_clean_cache(req)
368+
364369
return new_wheel_file
365370

366371

0 commit comments

Comments
 (0)