togahello recipe fails
https://github.com/AppImage/pkg2appimage/blob/master/recipes/togahello.yml fails with AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'. Any help appreciated.
+ virtualenv --python=python3 usr
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/me/togahello/togahello.AppDir/usr/bin/python3
Also creating executable in /home/me/togahello/togahello.AppDir/usr/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
+ ./usr/bin/pip3 install -U --pre pip
Requirement already up-to-date: pip in ./usr/lib/python3.6/site-packages (19.2.2)
+ ./usr/bin/pip3 install --pre toga
Collecting toga
Using cached https://files.pythonhosted.org/packages/ed/9a/fb2cf5e51a677f4bb41d321d4dabf96b365e262d836e85552f607a44b293/toga-0.3.0.dev13-py3-none-any.whl
Collecting toga-gtk==0.3.0.dev13; sys_platform == "linux" (from toga)
Using cached https://files.pythonhosted.org/packages/19/39/6243d070e3e6fddf90a0e0231c899dc60561a1f5913188f93dee432ac88c/toga_gtk-0.3.0.dev13-py3-none-any.whl
Collecting pygobject>=3.14.0 (from toga-gtk==0.3.0.dev13; sys_platform == "linux"->toga)
Using cached https://files.pythonhosted.org/packages/40/ee/8daf797cda4ffe7724b9d47cbb5e2b44ca6235764622d163c586bd9bd7c5/PyGObject-3.32.2.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Command errored out with exit status 1:
command: /home/me/togahello/togahello.AppDir/usr/bin/python3 /home/me/togahello/togahello.AppDir/usr/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp931_s51m
cwd: /tmp/pip-install-oig48nml/pygobject
Complete output (28 lines):
Traceback (most recent call last):
File "/home/me/togahello/togahello.AppDir/usr/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/home/me/togahello/togahello.AppDir/usr/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/me/togahello/togahello.AppDir/usr/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 48, in get_requires_for_build_wheel
backend = _build_backend()
File "/home/me/togahello/togahello.AppDir/usr/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 34, in _build_backend
obj = import_module(mod_path)
File "/home/me/togahello/togahello.AppDir/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/pip-build-env-ya219q4b/overlay/lib/python3.6/site-packages/setuptools/__init__.py", line 18, in <module>
import setuptools.version
File "/tmp/pip-build-env-ya219q4b/overlay/lib/python3.6/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/me/togahello/togahello.AppDir/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
----------------------------------------
ERROR: Command errored out with exit status 1: /home/me/togahello/togahello.AppDir/usr/bin/python3 /home/me/togahello/togahello.AppDir/usr/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp931_s51m Check the logs for full command output.
cc @freakboy3742
I can't comment on any AppImage-related cause, but from a Python perspective, this is an indication that the Python runtime itself has a problem.
The SourceFileLoader is (as the name suggests) the bit of the Python runtime that actually loads the code that is going to run. The executable for Python is clearly there, but the standard library is corrupted or misconfigured in some way.
Since this is occurring during building the image, I'm guessing that means you're using the system Python - so my first diagnostic advice would be to confirm if you are able to run the toga demo code outside the app image build process. If you run the script commands by hand, do you get the same error? Can you run Python code at all?
I can't comment on any AppImage-related cause, but from a Python perspective, this is an indication that the Python runtime itself has a problem.
We are not even at the AppImage-ification stage yet.
The process is basically three steps and I am struggling at 1:
- Make a virtualenv with Toga and the "hello world" script. This virtualenv must at least run on all still-supported LTS releases of Ubuntu (currently: xenial and newer) in order to be useful for many users
- Turn the virtualenv into an AppDir (basically add the dependencies for Python, and a desktop file and an icon)
- Put the AppDir into an AppImage (easy; compare this step to putting it inside a zip file only that it is not a zip but an AppImage)
So, can you explain to me how, on Ubuntu xenial, I can make a virtualenv that runs Toga and its "hello world"?
I used:
mkdir appdir ; cd appdir
virtualenv --python=python3 usr
./usr/bin/pip3 install -U --pre pip
./usr/bin/pip3 install --pre toga
Is this halfway correct, and more importantly: Does it work for you?
The Toga tutorial I originally referenced has the step-by-step instructions you need. That tutorial doesn't use virtualenv; virtualenv is a third party package that has... an interesting history with Ubuntu's packaging team.
Python 3.3+ comes with a built-in version of virtualenv called venv.
$ python3 -m venv usr
$ source usr/bin/activate
$ pip install -U pip
$ pip install --pre toga
The only reason I've ever seen the pip install --pre toga step fail is because of binary requirements (usually cairo, pango, gobject-introspection or webkit); the required package names are also listed on the tutorial page.
Your call to pip install -U pip is nice to have, but shouldn't be required. The --pre flag should only be needed on the install of toga, not pip.
I've just tried this sequence of commands on my Ubuntu 18.04 and Fedora 29 box; both worked fine.
Are you aware of a Python distribution that is independent of the Linux distribution (besides the Conda stuff)? I recently learned about https://github.com/pypa/manylinux and I wonder whether Python itself is available as a manylinux compliant binary.
The core of Python could probably be made manylinux compliant, but the official Python distribution itself isn't currently compliant - it has dependencies on openSSL, Tk, and many other libraries that are outside the manylinux spec. The efforts in the PyPA around manylinux are around the distribution of Python modules that have compiled components.
Yes, that's what I figured - but how useful are modules that run anywhere when there is no Python that easily runs everywhere... guess I will have to experiment more to see why "my" Python virtual environment fails installing Toga.
(Since we're evidently both online and tinkering on this... is there a live chat forum that y'all use? BeeWare uses Gitter, but I can meet y'all wherever you are...
AppImage devs hang out on #AppImage on irc.freenode.net
Answering myself,
I recently learned about https://github.com/pypa/manylinux and I wonder whether Python itself is available as a manylinux compliant binary.
https://realpython.com/pyinstaller-python/ says:
For example, if you want to target a wide array of Linux machines, then you can build on an older version of CentOS. This will give you compatibility with most versions newer than the one you build on. This is the same strategy described in PEP 0513 and is what the PyPA recommends for building compatible wheels. In fact, you might want to investigate using the PyPA’s manylinux docker image for your Linux build environment.
This may be the key to getting Python itself compiled in manylinux form.