Hi,
I’m trying to snap my own local python package/app and run into some issues. Sample app is here: GitHub - juergh/testsnap
It’s a very simple classic snap that contains a python app that calls a system command (dput
- another python program). The current state is that the execution of dput
fails because it seems confused (see below) by PYTHONPATH
which I had to set in snapcraft.yaml
.
Questions/issues:
- Why do I have to manually stage the python interpreter? Shouldn’t snapcraft figure out by itself that it’s required?
enable-patchelf
seems necessary to prevent lint warnings. Do I really need this or am I doing something wrong?- I need to set
PYTHONPATH
otherwise I’m getting the below, butPYTHONPATH
breaksdput
. It feels wrong to have to specifyPYTHONPATH
…
Traceback (most recent call last):
File "/snap/testapp/x3/bin/testapp", line 5, in <module>
from testapp.testapp import main
ModuleNotFoundError: No module named 'testapp'
Current output:
$ /snap/bin/testapp
Calling dput...
Traceback (most recent call last):
File "/usr/bin/dput", line 33, in <module>
sys.exit(load_entry_point('dput==1.1.3+ubuntu3', 'console_scripts', 'execute-dput')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/dput", line 25, in importlib_load_entry_point
return next(matches).load()
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
module = import_module(match.group('module'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/usr/share/dput/dput/dput.py", line 34, in <module>
from .helper import dputhelper
File "/usr/share/dput/dput/helper/dputhelper.py", line 17, in <module>
import pkg_resources
File "/snap/testapp/x6/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2172, in <module>
register_finder(pkgutil.ImpImporter, find_on_path)
^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
Any help is greatly appreciated. Thanks!