`uv` plugin: Environment validation failed

Hmm, I did some more experiments and saw that even with the above, the interpreter was removed somehow during packing. I did manage to get a working 3.11 interpreter into a snap using uv like so:

parts:
  uv-python:
    plugin: nil
    build-snaps:
      - astral-uv
    build-environment:
      - UV_PYTHON: "python3.11"
      - UV_PYTHON_PREFERENCE: "only-managed"
      - UV_PYTHON_DOWNLOADS: "true"
    override-build: |
      mkdir -p $CRAFT_PART_INSTALL/usr
      uv python install
      cp -r $(uv python dir)/cpython-3.11*/* $CRAFT_PART_INSTALL/usr/
     
  app:
    plugin: uv
    source: .
    after: [uv-python]
    build-snaps:
      - astral-uv
    build-environment:
      - UV_PYTHON: "$CRAFT_STAGE/usr/bin/python3.11"
      - UV_PYTHON_PREFERENCE: "only-managed"

I then end up with a working $SNAP/bin/python3 symlink.

1 Like