Problem
The uv plugin fails when building charms on Ubuntu 26.04 (core26) because craft-parts removes python symlinks from venv/bin/ and the dispatch script's fallback uses the system Python interpreter, which doesn't have venv packages installed.
Root Cause
On core26, the base snap does NOT include Python. The uv plugin flow:
- Creates a venv with
uv venv --relocatable --python /usr/bin/python3.14
- Runs
uv sync to install dependencies (ops, cosl, etc.)
- craft-parts removes
python* symlinks from venv/bin/
- craft-parts tries to find Python in the payload - fails (core26 has no Python)
- craft-parts falls back to system interpreter path
/usr/bin/python3.14
- The dispatch script checks if
venv/bin/python exists - it doesn't
- The dispatch script creates
ln -s $(which python3) venv/bin/python
- This symlinks to the system Python, which doesn't have
ops installed
Result: ModuleNotFoundError: No module named 'ops' at runtime.
Reproduction
base: ubuntu@26.04
parts:
charm:
plugin: uv
source: .
build-snaps:
- astral-uv
Build Output
:: + uv venv --relocatable --allow-existing --python /usr/bin/python3.14 /root/parts/charm/install/venv
:: + uv sync --no-dev --no-editable --reinstall --no-install-project
:: + rm /root/parts/charm/install/venv/bin/python /root/parts/charm/install/venv/bin/python3 /root/parts/charm/install/venv/bin/python3.14
:: + echo 'Python interpreter not found in payload.'
:: Python interpreter not found in payload.
:: + symlink_target=/usr/bin/python3.14
The dispatch script then creates venv/bin/python -> /usr/bin/python3, which doesn't have venv packages.
Runtime Error
File "/var/lib/juju/agents/unit-image-garden-stream-0/charm/src/charm.py", line 20, in <module>
from ops.charm import CharmBase
ModuleNotFoundError: No module named 'ops'
Related
Suggested Fix
Options:
- On core26, automatically include python3 as a dependency in the payload
- Don't remove python symlinks from venv/bin/ when the interpreter is not in the payload
- Have craft-parts copy the interpreter to the payload when it's not available
- Document that core26 requires additional configuration for the uv plugin
Problem
The uv plugin fails when building charms on Ubuntu 26.04 (core26) because craft-parts removes python symlinks from
venv/bin/and the dispatch script's fallback uses the system Python interpreter, which doesn't have venv packages installed.Root Cause
On core26, the base snap does NOT include Python. The uv plugin flow:
uv venv --relocatable --python /usr/bin/python3.14uv syncto install dependencies (ops, cosl, etc.)python*symlinks fromvenv/bin//usr/bin/python3.14venv/bin/pythonexists - it doesn'tln -s $(which python3) venv/bin/pythonopsinstalledResult:
ModuleNotFoundError: No module named 'ops'at runtime.Reproduction
Build Output
The dispatch script then creates
venv/bin/python -> /usr/bin/python3, which doesn't have venv packages.Runtime Error
Related
Suggested Fix
Options: