Python apps broken in MicroStack (a classic snap) after Jan 14 snapcraft update
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
snapd |
Fix Released
|
High
|
Zygmunt Krynicki |
Bug Description
I ran into this bug on January 14th, when the snapcraft stable snap updated, but it's strange enough that it took me a week to come to terms with it (and rule out foolish things that I might have been doing).
In the MicroStack snap, we have a few Python scripts that are built using Python's entry point convention, where, after running setup.py, you wind up with a script in your bin dir that looks something like this:
#!/usr/bin/env python
from my_package import some_function
if __name__ == '__main__'
That's all very straightforward and normal, and our scripts were working beautifully before January 14th. Post snapcraft 3.9.5, however, the import of <my_package> will fail, causing the script to bail with an Exception.
MicroStack is a large and complex snap, and test cycles can run upwards of an hour. I made a much simpler snap that reproduces the bug, and pushed it to my public github account here: https:/
If you run snapcraft on a checkout of that reproducer, then snap install the resultant snap and run pedrolino.test (or just run reproducer.sh in the repo's root), you should be able to reproduce the problem: the .test script will fail with a DistributionNot
Interestingly, the following set of commands will work:
sudo snap run --shell pedrolino.test
$SNAP/
It looks like something broke with the pathing, and Python scripts with entry points are using the wrong Python, or are otherwise winding up without the correct libraries in their PYTHONPATH. Do you know why this might have happened, and do you know how we might work around the issue? (I kind of have a bad feeling that the workaround might be to find every invocation of a Python script in the snapcraft.yaml and MicroStack tooling, and explicitly call the scripts with usr/bin/python3 ...)
summary: |
- Issue running Python daemons that have been built using entry points - with the latest snapcraft (in a --classic snap) + Python entry points broken in MicroStack (a classic snap) after Jan 14 + snapcraft update |
summary: |
- Python entry points broken in MicroStack (a classic snap) after Jan 14 - snapcraft update + Python apps broken in MicroStack (a classic snap) after Jan 14 snapcraft + update |
Changed in snapd: | |
importance: | Undecided → High |
tags: | added: core20 |
Changed in snapd: | |
assignee: | nobody → Ian Johnson (anonymouse67) |
Changed in snapd: | |
status: | Confirmed → Triaged |
Is this possibly related to the switch from using pip.wheel to using pip.install when building packages?
That change happened here: https:/ /github. com/snapcore/ snapcraft/ commit/ 9bac0fd647c22e2 207a3b27b886ea1 2a8809ce30
Said change caused other broken-ness in MicroStack, though the workaround turned out to be a one line change.
Specifically I was building an OpenStack component called horizon from source in MicroStack's openstack-projects part. A horizon version is specified in the OpenStack upper constraints file, which we reference in the openstack-projects part. Pip.wheel was happy to just build from our horizon source tarball, but pip.install failed, complaining about being unable to apply a version of a source-built library. This is a reasonable error message, and I simply switched to installing horizon via pip (the constraints basically just points at the version in pip that matches the tarball that I was downloading).
I'm wondering if there are further consequences from moving away from wheels. Though I do see everything living happily in the snap's site packages. This really is a weird one :-/