I'm trying to snap package a non-pure python project. I used python
plugin with custom build/install scripts.
This project contains 2 python packages that are required for desktop app:
alfanous
(API)alfanous-desktop
(Qt PySide GUI)
snapcraft.yaml
file:
name: alfanous
version: "0.7.8"
summary: Alfanous
description: GNU hello prints a friendly greeting.
This is part of the snapcraft tour at http://snapcraft.io/create/
#confinement: strict
confinement: devmode
apps:
alfanous-gui:
command: usr/bin/alfanous-desktop
#desktop: usr/share/applications/my-app.desktop
alfanous-cli:
command: usr/bin/alfanous-console
parts:
alfanous-git:
build-packages:
#- python
- sqlite3
- pyside-tools
- qt4-linguist-tools
- python-babel
- qt4-qmake
- python-setuptools
#- python-pyparsing
#- perl
#plugin: make
plugin: python
python-version: python2
#source: https://github.com/Alfanous-team/alfanous/archive/0.7.8.tar.gz
source: https://github.com/Alfanous-team/alfanous.git
source-type: git
source-depth: 1
#source-tag: 0.7.8
build: |
make build
install: |
echo _______#######:$(pwd)
#make install_api
make install_api DESTDIR=$SNAPCRAFT_PART_INSTALL
make install_desktop DESTDIR=$SNAPCRAFT_PART_INSTALL
stage-packages:
- python-pyparsing
- python-pyside
#- epydoc
#- sphinx
- python-babel
- python-setuptools
python-packages:
- pyparsing
- pyside
- babel
The snap package is built and installed without errors. However, if i try to run it:
$ alfanous.alfanous-cli
Traceback (most recent call last):
File "/snap/alfanous/x3/usr/bin/alfanous-console", line 5, in <module>
from pkg_resources import load_entry_point
File "/snap/alfanous/x3/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
@_call_aside
File "/snap/alfanous/x3/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/snap/alfanous/x3/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/snap/alfanous/x3/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 635, in _build_master
ws.require(__requires__)
File "/snap/alfanous/x3/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 943, in require
needed = self.resolve(parse_requirements(requirements))
File "/snap/alfanous/x3/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 829, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'alfanous==0.7.29' distribution was not found and is required by the application
My first suspect is non-complete PYTHONPATH
, trying to debug:
snap run --shell alfanous.alfanous-cli
env | grep -i python
brings nothing.
and both packages are there:
$ ls /snap/alfanous/current/usr/lib/python2.7/site-packages/
alfanous alfanousDesktop
alfanous-0.7.29-py2.7.egg-info alfanousDesktop-0.7.29-py2.7.egg-info
How could I setup PYTHONPATH
correctly? Shouldn't the python plugin take care of that?
snapcraft v2.28 Ubuntu 16.04.2 LTS 64Bit
I modified
alfanous-console
to printsys.path
and rebuild the snap:It seems clear the
snap
does not includesite-packages
toPYTHONPATH
where my target package installs itself.Or report this to snap team to add
usr/lib/python2.7/site-packages
Related bug report #1670749 : classic confinement requires manually setting PATH and PYTHONPATH
The suggested solution there didn't work:
Because of that weird path pointing to host
/home
folder