← Back to issue list

Host python dist-packages in sys.path of snapcraft's python

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1767434
Type
issue
State
closed
Author
~adam-collard
Labels
—
Created
Updated
Closed

Current evaluation

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.

Resolution: closed resolved

Reason: ~sergiusens closed the report pointing to snapcore/snapcraft#2131, titled 'No user site for snapcraft', which merged as commit 9dfbdbaba ('package: disable user site-packages for snapcraft'). That change stops the host's ~/.local user site-packages (and its conflict with snapcraft's bundled deps, e.g. pymacaroons/nacl) from appearing in the snapcraft python's sys.path.

Evaluated by: mr-cal-bot

No scores available.

Issue body

$ /snap/snapcraft/current/usr/bin/python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/snap/snapcraft/current/usr/lib/python35.zip', '/snap/snapcraft/current/usr/lib/python3.5', '/snap/snapcraft/current/usr/lib/python3.5/plat-x86_64-linux-gnu', '/snap/snapcraft/current/usr/lib/python3.5/lib-dynload', '/home/acollard/.local/lib/python3.5/site-packages', '/home/acollard/.local/lib/python3.5/site-packages/GitPython-2.1.3-py3.5.egg', '/home/acollard/.local/lib/python3.5/site-packages/gitdb2-2.0.0-py3.5.egg', '/home/acollard/.local/lib/python3.5/site-packages/smmap2-2.0.1-py3.5.egg', '/usr/lib/python3/dist-packages', '/snap/snapcraft/current/usr/lib/python3/dist-packages'] >>> import snapcraft.storeapi Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'snapcraft' >>> import snapcraft.storeapi Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'snapcraft' >>> import pymacaroons Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3/dist-packages/pymacaroons/__init__.py", line 2, in <module> from .macaroon import Macaroon File "/usr/lib/python3/dist-packages/pymacaroons/macaroon.py", line 13, in <module> from pymacaroons.caveat_delegates import ( File "/usr/lib/python3/dist-packages/pymacaroons/caveat_delegates/__init__.py", line 4, in <module> from .encrypted_first_party import ( File "/usr/lib/python3/dist-packages/pymacaroons/caveat_delegates/encrypted_first_party.py", line 5, in <module> from pymacaroons.field_encryptors import SecretBoxEncryptor File "/usr/lib/python3/dist-packages/pymacaroons/field_encryptors/__init__.py", line 2, in <module> from .secret_box_encryptor import SecretBoxEncryptor File "/usr/lib/python3/dist-packages/pymacaroons/field_encryptors/secret_box_encryptor.py", line 3, in <module> from nacl.secret import SecretBox File "/usr/lib/python3/dist-packages/nacl/secret.py", line 17, in <module> import nacl.bindings File "/usr/lib/python3/dist-packages/nacl/bindings/__init__.py", line 17, in <module> from nacl.bindings.crypto_box import ( File "/usr/lib/python3/dist-packages/nacl/bindings/crypto_box.py", line 18, in <module> from nacl._sodium import ffi, lib ImportError: No module named 'nacl._sodium' >>> import site >>> site.PREFIXES ['/snap/snapcraft/current/usr', '/snap/snapcraft/current/usr'] >>> site.USER_BASE '/home/acollard/.local' >>> site.USER_SITE '/home/acollard/.local/lib/python3.5/site-packages' >>> sys.path_hooks [<class 'zipimport.zipimporter'>, <function FileFinder.path_hook.<locals>.path_hook_for_FileFinder at 0x7f3a531c6950>] >>> sys.prefix '/snap/snapcraft/current/usr' >>> sys.platform 'linux'

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved 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.
stealth/space-bunny-alpha — closed resolved PR #2131 (9dfbdbaba) was merged to disable user site-packages for Snapcraft's bundled Python and was linked by the maintainer as the fix.
stealth/space-bunny-alpha — closed stale Closed without comments, linked fixes, or follow-up; adding host dist-packages to Snapcraft’s bundled Python import path had no recorded resolution.
qwen/qwen3.6-35b-a3b — — Closed without comments or follow-up, likely abandoned or resolved in later snapcraft versions. No fix or merge was tracked.
qwen/qwen3.6-35b-a3b — — Abandoned. The request to host system Python dist-packages in snapcraft's sys.path was closed without resolution or comments due to prolonged inactivity.

Update history

Date Change
created

Related work

  • Likely Fixed By: snapcore/snapcraft#2131 (confidence 95%)

    PR cited by the closing maintainer comment; merged as commit 9dfbdbaba disabling user site-packages for snapcraft's python.

Related issues

Issue Project State Summary Similarity
#1860884 Python plugin: paths for from the snapcraft snap in sys.path break dependencies snapcraft (launchpad) closed 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.
79%
#2131 No user site for snapcraft snapcraft merged Merged in canonical/snapcraft#2131 via commit 9dfbdbaba, disabling Python user site-packages for Snapcraft.
74%
#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).
71%