← Back to issue list

Python plugin: file conflicts when using the plugin with a custom version of Python from another part

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1850921
Type
issue
State
open
Author
~ntamas
Labels
—
Created
Updated
Closed
—

Current evaluation

Python plugin reportedly provisions Python 3.5 before a custom-Python part is staged, causing /usr/bin conflicts; this Snapcraft 2.44 report remains untriaged against the current plugin architecture.

Suggested action: needs triage

Reason: The issue has no labels, maintainer comments, or activity, so it has not been assessed. It provides a concrete configuration and conflicting paths, but current Snapcraft delegates Python behavior to craft-parts; a current-version reproduction or confirmation that the legacy behavior is obsolete is needed.

Evaluated by: mr-cal-bot

Impact: 46 Quick Win: 8 Complexity: 67 Confidence: 76 Actionability: 55

Issue body

My use-case is as follows: I need to snap a package that supports Python 3.7 only, so I added the compilation of Python 3.7 as a separate part to my snap, similarly to the following snippet: parts:   python37:     source: https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz     source-type: tar     source-checksum: md5/93df27aec0cd18d6d42173e601ffbbfd     plugin: autotools     configflags:       - --prefix=/usr     build-packages: ***omitted***     stage-packages: ***omitted***     stage:       - -usr/lib/python3.7/test       - -var   my-package:     plugin: python     source: .     requirements: ./requirements.txt     after:       - python37     override-pull: |       ...some custom script that is probably not relevant...       snapcraftctl pull     override-prime: |       snapcraftctl prime       ...some custom script that is probably not relevant... During the first build, the Python plugin fails to detect that another version of Python has already been built and staged in another part so it includes the default Python version (3.5) in the "my-package" part, leading to conflicts between "my-package" and "python37"; in particular, the following files are present in the install area of both parts: /usr/bin/2to3 /usr/bin/pydoc3 /usr/bin/python3 If my understanding is correct, the Python plugin should be able to detect that I have built Python 3.7 in another part and should simply use that instead of bundling Python 3.5. Cleaning the `my-package` part and rebuiling everything from there seems to resolve the problem, but it's not an ideal experience. It is also possible to work around the issue by not staging the conflicting files from `my-package`, but it still means that there are two versions of Python in my snap, even though one would be enough. I managed to track the bug down to the part that the `stage_packages` property in the Python plugin is evaluated right at the beginning of the build (when there is no `python37` part built yet), and that's why the plugin infers that it should bundle Python 3.5 with the `my-package` part. If the `stage_packages` property were evaluated _later_, right before starting to build `my-package`, it should be able to infer that my custom Python is already compiled. Snapcraft version: 2.44 (I would use Snapcraft 3.x if I could, but I'm preparing a snap for a Raspberry Pi so I'm using classic on Ubuntu Server 18.04, which provides only Snapcraft 2.44 within the classic environment).

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 46
Quick Win: 8
Complexity: 67
Confidence: 76
Actionability: 55
needs triage Python plugin reportedly provisions Python 3.5 before a custom-Python part is staged, causing /usr/bin conflicts; this Snapcraft 2.44 report remains untriaged against the current plugin architecture.
stealth/space-bunny-alpha
Impact: 42
Quick Win: 22
Complexity: 44
Confidence: 97
Actionability: 94
close resolved Snapcraft 2.44's Python v2 plugin bundled a default interpreter before an earlier custom-Python part was staged, causing file conflicts; a merged fix resolves this.
stealth/space-bunny-alpha
Impact: 30
Quick Win: 5
Complexity: 55
Confidence: 96
Actionability: 38
close stale Unmaintained core18-era report: Snapcraft 2.44's Python plugin staged a duplicate interpreter when another part supplied Python; the affected legacy stack has since been removed.
qwen/qwen3.8-27b
Impact: 20
Quick Win: 12
Staleness: 95
Complexity: 40
Confidence: 70
Support Request: 10
close stale Snapcraft 2.44 Python plugin bundles default Python 3.5 when a custom Python 3.7 is built in another part, causing file conflicts. Root cause: stage_packages evaluated too early. No maintainer response; predates Snapcraft 3.x which uses craft-parts venv-based Python plugin without stage_packages.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 55
Confidence: 90
Support Request: 10
close stale Python plugin bundles default Python instead of detecting a custom version built in another part, causing file conflicts. The report is over six years old, lacks maintainer response, and targets the unsupported Snapcraft 2.44 release.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 40
Confidence: 85
Support Request: 10
close stale Python plugin bundles default Python instead of detecting a custom Python built in another part, causing file conflicts. Untriaged, inactive for ~6.7 years, specific to obsolete Snapcraft 2.44.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 45
Confidence: 90
Support Request: 10
close stale Python plugin bundles default Python causing file conflicts when a custom Python part is used. Untriaged, inactive for ~6.7 years, reported against Snapcraft 2.44.

Update history

Date Change
created

Related work

  • Superseded By: snapcraft#4044 (confidence 78%)

    Commit 302e58eeb introduced the current Snapcraft-specific Python plugin, which delegates to craft-parts rather than the legacy plugin lifecycle described by the report.

  • Related To: craft-parts#449 (confidence 72%)

    Commit 1fbda451 improved checking for a Python interpreter already present in the payload, but it is not identified as a direct resolution of this issue.

  • Related To: craft-parts#487 (confidence 72%)

    Commit d3cc6ccf refined payload-Python detection and may be relevant when reproducing the staged custom-interpreter scenario.

Related issues

Issue Project State Summary Similarity
#1502105 when two python3 parts are used the pycs give a conflict snapcraft (launchpad) closed Overlapping Python 3 .pyc staging conflicts were fixed in ubuntu-core/snapcraft#50 using Python-plugin snap_fileset filtering; regression coverage was proposed in #109.
74%
#6411 The Python plugin can create conflicting interpreters snapcraft closed Closed as fixed by merged PR #6437 (commit 35853fff8): the Python plugin now rewrites shebangs on core26+ to the absolute /snap/<name>/bin/python3 path, removing PATH-order ambiguity with staged /usr/bin/python3.
72%
#2161191 python plugin messing with snapcraft env snapcraft (launchpad) open Vague report that the Python plugin alters Snapcraft's own Python version/modules instead of isolating part deps in a venv; links a core26 forum thread. No labels, no maintainer response, zero comments, no reproducer.
72%