Reputation: 2945
I have a pretty standard python application, including setup.py
and requirements.txt
, which installs fine with pip
:
$ pip install .
$ tree -L 1 env/lib/python3.5/site-packages/
env2/lib/python3.5/site-packages/
├── myAPP
├── myAPP-0.1.0-py3.5.egg-info
...
I'd like to use snaps to build and deploy the application, and noticed that snapcraft
only installs my app's dependencies, but not the app itself. It does build a wheel, but does not install it:
$ snapcraft
....
Building wheels for collected packages: myAPP, blist
...
Successfully built myAPP blist
/home/ubuntu/parts/myAPP/install/usr/bin/python3 -m pip install --user
--no-compile --disable-pip-version-check --no-index
--find-links /home/ubuntu/parts/myAPP/packages blist
<other_requirements> --no-deps --upgrade
Does anyone know why myAPP
is not part of the pip install?
For reference, the snapcraft.yaml
is super simple at this stage, but I think should be all that's needed. Snapcraft is v2.27.1
on Ubuntu 16.04
name: myAPP
version: '0.0.1'
summary: myAPP web application
description: |
myAPP main web application
grade: devel
confinement: strict
apps:
myAPP:
command: gunicorn myApp.wsgi
daemon: simple
plugs:
- network-bind
parts:
myAPP:
plugin: python
python-version: python3
source: /opt/backend/
I checked what packages are installed after building the application:
$ parts/myAPP/install/bin/pip list --format columns
Package Version Location
----------------------- -------- -------------------
appdirs 1.4.2
blist 1.3.6
myAPP 0.1.0 /opt/backend
....
If I then manually re-run pip install -U myAPP
, it does get included into site-packages
. Will see if I can repeat the other build steps separately.
Upvotes: 2
Views: 952
Reputation: 2945
Found a workaround by patching the snapcraft python plugin (on my system in /usr/lib/python3/dist-packages/snapcraft/plugins/python.py
):
--- /usr/lib/python3/dist-packages/snapcraft/plugins/python.py 2017-02-17 13:45:14.000000000 +0000
+++ python.py 2017-03-02 01:53:54.993148168 +0000
@@ -298,7 +298,7 @@
# we want to avoid installing what is already provided in
# stage-packages
need_install = [k for k in wheel_names if k not in installed]
- pip.install(need_install + ['--no-deps', '--upgrade'])
+ pip.install(wheel_names + ['--no-deps', '--upgrade', '--ignore-installed'])
def _fix_permissions(self):
for root, dirs, files in os.walk(self.installdir):
I hope that there might be a cleaner solution to the problem? In the meantime, you can copy the patch above into a file called patch.diff
and apply with:
sudo patch -b /usr/lib/python3/dist-packages/snapcraft/plugins/python.py patch.diff
Upvotes: 1