Python plugin: paths for from the snapcraft snap in sys.path break dependencies
Metadata
Current evaluation
Abandoned due to inactivity. The Python plugin incorrectly included snapcraft snap paths in sys.path during builds, causing dependency conflicts. No resolution or fix was implemented.
Suggested action: —
No scores available.
Issue body
Tested with Snapcraft 3.9.8 (3970) from stable channel
In a python part for a snap, if python3 is called inside a build step, the interpreter installed from the part is used. However, this has some paths from the python from the snapcraft snap in sys.path.
He're a minimal reproducer:
name: python-path-test
version: "0.0.1"
summary: python-path-test
description: python-path-test
grade: stable
confinement: strict
base: core18
apps:
python-path-test:
command: python-path-test
parts:
python-path-test:
plugin: python
source: .
source-type: local
requirements:
- requirements.txt
override-build: |
set -e
snapcraftctl build
echo -------------
which python3
echo -------------
python3 -c "import sys; import pprint; pprint.pprint(sys.path)"
echo -------------
python-path-test
The "python-path-test" script does exactly the same as the oneliner above.
The output during build is the following:
-------------
/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/bin/python3
-------------
['',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python36.zip',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python3.6',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python3.6/lib-dynload',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python3/dist-packages',
'/snap/snapcraft/3970/lib/python3.6/site-packages',
'/home/ack/Desktop/python-path-test/stage/lib/python3.6/site-packages',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/lib/python3.6/site-packages']
-------------
['/home/ack/Desktop/python-path-test/parts/python-path-test/install/bin',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python36.zip',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python3.6',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python3.6/lib-dynload',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/usr/lib/python3/dist-packages',
'/snap/snapcraft/3970/lib/python3.6/site-packages',
'/home/ack/Desktop/python-path-test/stage/lib/python3.6/site-packages',
'/home/ack/Desktop/python-path-test/parts/python-path-test/install/lib/python3.6/site-packages']
In both cases '/snap/snapcraft/3970/lib/python3.6/site-packages' ia included. It seems like only paths under $SNAPCRAFT_INSTALL_PART should be there.
This can cause issues when the application has dependency requirements that conflict with the ones from snapcraft itself, since in that case pkg_resources breaks.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Abandoned due to inactivity. The Python plugin incorrectly included snapcraft snap paths in sys.path during builds, causing dependency conflicts. No resolution or fix was implemented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The Python plugin incorrectly injected snapcraft's site-packages into sys.path during builds, causing dependency conflicts. No fix was implemented. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1876370 Python libraries installed by python path are not found in sys.path | snapcraft (launchpad) | open | Snapcraft 4.0 core20: Python parts install packages to $SNAP/lib/python3.8/site-packages but that path is missing from sys.path, so apps cannot import them. No labels, no comments, no maintainer response; last activity ~6.3 years ago. | |
| #2161192 python plugin not working at all with snapcraft 9+ | snapcraft (launchpad) | open | Python plugin broken on core26/snapcraft 9+ — modules not loading, requires python3-venv instead of python3. No maintainer response after 49 days. | |
| #1841861 Python plugins fails to build a snap when some parts depends on unpublished modules | snapcraft (launchpad) | closed | Closed without resolution. The Python plugin fails to build snaps when parts depend on unpublished local modules because pip download fails to locate them on PyPI. No fix was implemented. | |
| #1880319 Python plugin --classic snap conflicts with system python | snapcraft (launchpad) | closed | Closed without comments or resolution, likely abandoned. The issue reported a Python plugin conflict where classic confinement snaps incorrectly imported host system libraries instead of packaged dependencies. |