Skip to content

fix: pass --break-system-packages for uv-managed Python (PEP 668)#3073

Merged
markphelps merged 1 commit into
mainfrom
md/pep668-fix
Jun 22, 2026
Merged

fix: pass --break-system-packages for uv-managed Python (PEP 668)#3073
markphelps merged 1 commit into
mainfrom
md/pep668-fix

Conversation

@michaeldwan

Copy link
Copy Markdown
Contributor

GPU builds on nvidia/cuda base images fail with externally-managed-environment because uv python install marks its Python as PEP 668 externally managed, and uv 0.9.x enforces it. pip refuses to install without --break-system-packages.

The flag existed behind SetBreakSystemPackages, but only the cog base-image CLI called it. Normal cog build never did -- so every GPU build hitting the CUDA base image path broke.

The fix adds needsBreakSystemPackages() which auto-detects the uv-managed Python condition (same predicate as installPython()). All pip install and uninstall sites go through it.

error: externally-managed-environment

× This environment is externally managed
╰─> This Python installation is managed by uv and should not be modified.

GPU builds on nvidia/cuda base images install Python via `uv python
install`, which marks it as externally managed. uv 0.9.x enforces
PEP 668, so pip refuses to install into that environment without
--break-system-packages.

The flag was already wired up behind SetBreakSystemPackages, but only
the `cog base-image` CLI command called it. Normal `cog build` never
did, breaking every GPU build that uses the CUDA base image path.
@ask-bonk

ask-bonk Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@michaeldwan michaeldwan marked this pull request as ready for review June 22, 2026 18:48
@michaeldwan michaeldwan requested a review from a team as a code owner June 22, 2026 18:48
@markphelps markphelps added this pull request to the merge queue Jun 22, 2026
Merged via the queue into main with commit 40f61a3 Jun 22, 2026
43 checks passed
@markphelps markphelps deleted the md/pep668-fix branch June 22, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants