← Back to issue list

Python plugin: paths for from the snapcraft snap in sys.path break dependencies

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1860884
Type
issue
State
closed
Author
~ack
Labels
—
Created
Updated
Closed

Current evaluation

Snapcraft's Python plugin no longer leaks its site-packages into part builds. Fixed by snapcore/snapcraft#2901 (c13c79d76a) and released in Snapcraft 3.10.

Resolution: closed resolved

Reason: Commit c13c79d76a from PR #2901 prevents Snapcraft's site-packages from entering the part interpreter's sys.path. A maintainer confirmed the fix was part of Snapcraft 3.10.

Evaluated by: mr-cal-bot

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
stealth/space-bunny-alpha — closed resolved Snapcraft's Python plugin no longer leaks its site-packages into part builds. Fixed by snapcore/snapcraft#2901 (c13c79d76a) and released in Snapcraft 3.10.
stealth/space-bunny-alpha — closed resolved Bug confirmed and fixed: snapcraftctl build's sitecustomize.py added /snap/snapcraft/<rev>/lib/python3.6/site-packages to sys.path. Fixed upstream in snapcore/snapcraft#2901 (commit c13c79d76), shipped in Snapcraft 3.10.
stealth/space-bunny-alpha — closed resolved Fixed in merged PR #2901 (commit c13c79d76, 'python plugin: do not leak snapcraft's site-packages'), shipped in Snapcraft 3.10; sitecustomize.py now exports snap site-packages only when SNAPCRAFT_INTERPRETER is set.
stealth/space-bunny-alpha — closed resolved Python builds no longer inherited Snapcraft's site-packages: merged PR #2901 fixed the leak with commit c13c79d76.
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

Date Change
created

Related work

  • Likely Fixed By: snapcore/snapcraft#2901 (confidence 100%)

    PR #2901 produced commit c13c79d76a, which removes the Snapcraft site-packages path.

Related issues

Issue Project State Summary Similarity
#1767434 Host python dist-packages in sys.path of snapcraft's python snapcraft (launchpad) closed Merged in snapcore/snapcraft#2131 (commit 9dfbdbaba), disabling Python user site-packages for Snapcraft, closing this report about host/user paths leaking into snapcraft's python sys.path.
79%
#2901 python plugin: do not leak snapcraft's site-packages snapcraft merged Merged #2901 fixed Python plugin builds leaking Snapcraft's $SNAP/site-packages by conditioning that path on SNAPCRAFT_INTERPRETER (commit c13c79d76).
79%
#1841861 Python plugins fails to build a snap when some parts depends on unpublished modules snapcraft (launchpad) closed Fixed by PR #2771 (commit 9bac0fd64), which made the Python plugin try processing setup.py before querying PyPI, allowing parts to use locally built packages.
71%
#1778716 snapcraft clean snapcraft fails as it cannot find python snapcraft (launchpad) closed Fixed by snapcore/snapcraft PR #2171, which corrected Python plugin cleanup so `snapcraft clean snapcraft` no longer fails when python3 is unavailable.
70%
#1586546 snapcraft python2 plugin build fails because of .pth and PYTHONPATH test snapcraft (launchpad) closed Fixed Python plugin setup.py handling in snapcore/snapcraft#718, merged as commit 810136457.
70%