Python plugin: paths for from the snapcraft snap in sys.path break dependencies
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
Fix Released
|
High
|
Sergio Schvezov |
Bug Description
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.
echo -------------
python-
The "python-path-test" script does exactly the same as the oneliner above.
The output during build is the following:
-------------
/home/ack/
-------------
['',
'/home/
'/home/
'/home/
'/home/
'/snap/
'/home/
'/home/
-------------
['/home/
'/home/
'/home/
'/home/
'/home/
'/snap/
'/home/
'/home/
In both cases '/snap/
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.
summary: |
- Python plugin: paths for from the snapcraft snap in sys.pat break + Python plugin: paths for from the snapcraft snap in sys.path break dependencies |
Changed in snapcraft: | |
status: | New → Triaged |
importance: | Undecided → High |
assignee: | nobody → Sergio Schvezov (sergiusens) |
Changed in snapcraft: | |
status: | Triaged → In Progress |
This is an effect of running `snapcraftctl build`. It modifies sitecustomize.py to include snap dir, stage dir, and part install site-packages.
I believe stage dir is required (if you use stage-packages to pull in dependencies).
sergiusens will be able to weigh in with a more expert opinion. In the meantime, you could update sitecustomize.py to work as you want it after `snapcraftctl build`.
e.g. PART_INSTALL/ usr/lib/ python3. 6/sitecustomize .py pprint( sys.path) " path-test
override-build: |
set -e
snapcraftctl build
sed -i "s|snap_dir, ||" $SNAPCRAFT_
python3 -c "import sys; import pprint; pprint.
python-