python console_scripts not installed into /snap/<snap>/current/bin

Bug #1670852 reported by Corey Bryant
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
High
Sergio Schvezov

Bug Description

Versions:
snapcraft 2.27.1+17.04
snapd 2.23+17.04

Python console_scripts and wsgi_scripts (entry_points) are not being installed into /snap/<snap>/current/bin. This used to work, but is not working now.

I have a simple python snap:
git clone https://github.com/coreycb/snap-keystone-test
cd snap-keystone-test
sudo snapcraft
sudo snap install --dangerous keystone_ocata_amd64.snap

After I install the snap, the bin files aren't available in $SNAP/bin:
ls /snap/keystone/current/bin/ # no sight of keystone-manage, keystone-wsgi-admin, and keystone-wsgi-public

If I pip install into a virtualenv from the same source tar file that the snap is using, the bin files are available:

wget http://tarballs.openstack.org/keystone/keystone-master.tar.gz
tar -xvf keystone-master.tar.gz
cd keystone-*
pip install -c https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt .
ls venv/bin/ # keystone-manage, keystone-wsgi-admin, and keystone-wsgi-public are installed

description: updated
description: updated
description: updated
Revision history for this message
Corey Bryant (corey.bryant) wrote :

With snapcraft 2.23 the bin files do get installed, so it appears that something has regressed since 2.23.

summary: - python entry_points not installed into /snap/<snap>/current/bin
+ python console_scripts not installed into /snap/<snap>/current/bin
Revision history for this message
Corey Bryant (corey.bryant) wrote :

I'm not entirely sure 2.23 works as today I'm getting "Unresolvable JSON pointer: 'definitions/stage-packages'" when using snapcraft cli with it. However, 2.22 definitely works ok.

Revision history for this message
Corey Bryant (corey.bryant) wrote :
Download full text (5.0 KiB)

I think I've narrowed this down a bit.

2.22 pip commands grepped from snapcraft run
--------------------------------------------
pip download --disable-pip-version-check --dest /root/snaps/orig/snap-keystone/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt pymysql uwsgi git+https://github.com/openstack/snap.openstack#egg=snap.openstack

pip download --disable-pip-version-check --dest /root/snaps/orig/snap-keystone/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt .

pip wheel --disable-pip-version-check --no-index --find-links /tmp/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt --wheel-dir /tmp/tmpjlck2avo pymysql uwsgi git+https://github.com/openstack/snap.openstack#egg=snap.openstack

pip install --user --no-compile --disable-pip-version-check --no-index --find-links /root/snaps/orig/snap-keystone/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt functools32 jsonschema uWSGI pbr Jinja2 MarkupSafe snap.openstack PyMySQL --no-deps --upgrade

pip wheel --disable-pip-version-check --no-index --find-links /root/snaps/orig/snap-keystone/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt --wheel-dir /tmp/tmpwv9fjma2 .

pip install --user --no-compile --disable-pip-version-check --no-index --find-links /root/snaps/orig/snap-keystone/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt python_dateutil python_keystoneclient Routes pytz dogpile.cache oslo.utils wrapt keystoneauth1 PasteDeploy debtcollector positional netaddr oslo.serialization pika_pool cachetools statsd iso8601 pysaml2 stevedore netifaces futures keystone eventlet WebOb oslo.service ipaddress SQLAlchemy oslo.log PyYAML zope.interface oslo.db oslo.cache enum34 sqlalchemy_migrate pycadf oslo.context rfc3986 decorator Babel msgpack_python kombu oslo.concurrency repoze.lru funcsigs passlib keystonemiddleware vine osprofiler amqp oslo.i18n requests pyasn1 idna monotonic pycrypto sqlparse alembic futurist greenlet python_editor contextlib2 fasteners prettytable tenacity Mako pyinotify repoze.who oslo.config Tempita oslo.middleware pyOpenSSL pika oslo.messaging pycparser oslo.policy cryptography oauthlib cffi Paste --no-deps --upgrade

2.27.1 pip commands grepped from snapcraft run
----------------------------------------------
/root/snaps/orig/snap-keystone/parts/keystone/install/usr/bin/python2 -m pip download --disable-pip-version-check --dest /root/snaps/orig/snap-keystone/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt . pymysql uwsgi git+https://github.com/openstack/snap.openstack#egg=snap.openstack

/root/snaps/orig/snap-keystone/parts/keystone/install/usr/bin/python2 -m pip wheel --disable-pip-version-check --no-index --find-links /root/snaps/orig/snap-keystone/parts/keystone/packages --constr...

Read more...

Leo Arias (elopio)
tags: added: openstack
Revision history for this message
Corey Bryant (corey.bryant) wrote :

I've hidden my previous comment that said this appears to not be caused by the python plugin updates. That's incorrect.

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Running on zesty with snapcraft 2.27.1 installed from source, and the following update, works successfully. /snap/keystone/current/bin/keystone* files are installed successfully and library files are successfully installed in /snap/keystone/lib/python2.7/site-packages/keystone/*. This line of code was switched from runnable='pip' to runnable=pip_command in commit e7824093f9a6942b7c395958e8bf31021566bd81. Note: pip_command in my case is defined as '/root/snaps/snap-keystone/parts/keystone/install/usr/bin/python2'.

diff --git a/snapcraft/plugins/python.py b/snapcraft/plugins/python.py
index 8a9ec61..665d610 100644
--- a/snapcraft/plugins/python.py
+++ b/snapcraft/plugins/python.py
@@ -279,7 +279,7 @@ class PythonPlugin(snapcraft.BasePlugin):
                                            self.options.constraints)

         pip = _Pip(exec_func=self.run,
- runnable=pip_command,
+ runnable='pip',
                    package_dir=self._python_package_dir, env=env,
                    constraints=constraints,
                    dependency_links=self.options.process_dependency_links)

Revision history for this message
Corey Bryant (corey.bryant) wrote :

pip_command is a list, just to be clear:
pip_command = ['/root/snaps/snap-keystone/parts/keystone/install/usr/bin/python2', '-m', 'pip']

affects: snappy → snapcraft
Revision history for this message
Leo Arias (elopio) wrote :

This is a regression caused by: https://github.com/snapcore/snapcraft/pull/1093

tags: added: regression
Changed in snapcraft:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Leo Arias (elopio) wrote :

I also get the error using:

runnable=['/usr/bin/python', '-m', 'pip']

That' doesn't make sense to me.

Revision history for this message
Leo Arias (elopio) wrote :

Some more info, installing in a virtualenv with pip it installs the console_scripts in bin.
Running in a virtualenv with python -m pip doesn't install the console_scripts.

looking at the logs, the later case prints:
Requirement already satisfied (use --upgrade to upgrade): keystone==11.0.1.dev124 from file:///tmp/snap-keystone-test/parts/keystone/src in /tmp/snap-keystone-test/parts/keystone/src

Revision history for this message
Leo Arias (elopio) wrote :

Adding upgrade to the plugin didn't change anything.
I'm now looking at the logs when running the plugin with pip, and the difference is that it prints:

Collecting keystone

Revision history for this message
Leo Arias (elopio) wrote :

(.env) ubuntu@juju-07fb34-remote-devel-0:/tmp/snap-keystone-test/parts/keystone/src$ python -m pip install --no-deps --upgrade --no-compile --disable-pip-version-check --no-index --find-links /tmp/snap-ke
ystone-test/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt keystone
Requirement already up-to-date: keystone in /tmp/snap-keystone-test/parts/keystone/src

(.env) ubuntu@juju-07fb34-remote-devel-0:/tmp/snap-keystone-test/parts/keystone/src$ pip install --no-deps --upgrade --no-compile --disable-pip-version-check --no-index --find-links /tmp/snap-keystone-tes
t/parts/keystone/packages --constraint https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt keystone
Collecting keystone
Installing collected packages: keystone
Successfully installed keystone-11.0.1.dev124

Maybe it's time to summon barry?

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

yes, please do, I will work on a workaround fix in the meantime.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

I am inclined to think this is a setup.cfg thing not working as we have an integration test for console_scripts as an entry point in setup.py

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

I have nailed the problen down to this being a mix of pbr and pip

We can solve this by calling setup.py instead of pip install.
Fix comming soon

Changed in snapcraft:
status: Confirmed → Fix Committed
status: Fix Committed → In Progress
milestone: none → 2.28
assignee: nobody → Sergio Schvezov (sergiusens)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Changed in snapcraft:
status: In Progress → Fix Committed
Revision history for this message
Corey Bryant (corey.bryant) wrote :

I just tested with the committed fix and this bug appears to be fixed, in terms of bin files are now getting installed. Thanks! \o/

However, behavior seems to be a bit odd after the snap is installed and I'm seeing errors that I didn't see before with 2.22.

For example, running a command from the snap I hit this: http://paste.ubuntu.com/24230185/
And /snap/keystone/current/lib/python2.7/site-packages/repoze/lru/ does in fact exist.
'touch /snap/keystone/current/lib/python2.7/site-packages/repoze/lru/__init__.py' got me past that issue.

Then starting a daemon 'sudo systemctl restart snap.keystone.api' I hit: http://paste.ubuntu.com/24230205/

Once again, 'touch /snap/keystone/x1/lib/python2.7/site-packages/paste/__init__.py' seemed to fix that issue.

It seems like this could be related: https://github.com/pypa/pip/issues/1924

I should probably open another bug for this.

Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.