← Back to issue list

python v2 plugin: consistent linking for interpreter

View original Github issue

Metadata

Project
snapcraft
Number
#3320
Type
pull request
State
merged
Author
cjp256
Labels
—
Created
Updated
Closed

Current evaluation

Merged as d1d8a9414, fixing Python v2 venv interpreter linking by resolving interpreters before creation and relativizing staged interpreter symlinks.

Resolution: closed resolved

Reason: PR #3320 was merged as commit d1d8a9414. It resolves the interpreter before venv creation, uses that path for shebang replacement, and fixes symlinks for interpreters staged in the part install or stage.

Evaluated by: mr-cal-bot

No scores available.

Issue body

When creating a venv, the venv's bin/python[3|3.x] will always point to the python that created it. There are three basic cases where python points to: (1) the base @ /usr/bin/<python> (typical). (2) $SNAPCRAFT_PART_INSTALL/usr/bin/<python> (staged in the part). (3) $SNAPCRAFT_STAGE/usr/bin/<python> (staged from another part). The first two cases were handled previously, when PATH matched expected environment. The third case may occur when another part stages prior to the python part. - Resolve the interpreter before creating the venv. This way it is apparent which python the venv wil point to, and provide a hint in case things go wrong (e.g. partial staging of python). Use this resolved path for the shebang find/replace. - Fix the broken case where python is resolved to $SNAPCRAFT_STAGE. Handle it similar to $SNAPCRAFT_PART_INSTALL, making a relative symlink when found. - While here, refactor some shell code into functions with logging (set -x) disabled to reduce logging clutter. Signed-off-by: Chris Patterson <chris.patterson@canonical.com>

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Merged as d1d8a9414, fixing Python v2 venv interpreter linking by resolving interpreters before creation and relativizing staged interpreter symlinks.
stealth/space-bunny-alpha — closed resolved Merged PR #3320 (commit d1d8a9414) fixed Python v2 venv linking by resolving interpreters before creation and correctly linking part- or stage-staged Python.
stealth/space-bunny-alpha — closed resolved Merged PR #3320 resolved Python v2 plugin venv interpreter linking, including interpreters staged by another part, via commit d1d8a9414.
qwen/qwen3.6-35b-a3b — — Merged fix for Python v2 plugin venv creation failure when the interpreter is staged from another part. Resolved interpreter path, fixed symlink handling, and refactored shell code. Approved, passed CI, and merged.
qwen3.6-35b-a3b-mtp-q6 — — Merged into master. Resolves Python v2 plugin interpreter linking by resolving paths before venv creation, correctly handling staged environments with relative symlinks, and refactoring shell code to reduce logging clutter.

Update history

No update history recorded yet.

Related work

  • Related To: snapcraft#3103 (confidence 90%)

    Earlier merged change that established the Python interpreter path used by this fix.

  • Related To: snapcraft#3451 (confidence 80%)

    Follow-up fix for multiple Python parts using staged Python, merged as 932288fed.

Related issues

Issue Project State Summary Similarity
#3451 python v2 plugin: fix multiple python parts with staged python snapcraft merged Merged via commit 932288fed, fixing Python v2 plugin file conflicts and broken symlinks when multiple parts staged Python packages by resolving interpreters before venv creation.
81%