alfiopuglisi / guietta

https://guietta.readthedocs.io
MIT License
1.96k stars 93 forks source link

Cannot install guietta on Raspberry Pi OS #21

Open fidergo-stephane-gourichon opened 3 years ago

fidergo-stephane-gourichon commented 3 years ago

Hi,

Doc says

https://github.com/alfiopuglisi/guietta says:

Installation

pip install guietta

Steps to reproduce

On a Rasbperry Pi running recent version of Raspberry Pi OS:

$ uname -a
(various values returned depending on Pi used)
Linux somepi1 4.19.118+ #1311 Mon Apr 27 14:16:15 BST 2020 armv6l GNU/Linux
Linux somepi3 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
Linux somepi4 4.19.118-v7l+ #1311 SMP Mon Apr 27 14:26:42 BST 2020 armv7l GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
$ pip3 install guietta
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting guietta
  Using cached https://files.pythonhosted.org/packages/80/08/08b9e63c7aba8652284d4dafe5b60a6ad68741a4b7cac74fe9e894c74b7f/guietta-0.3.5-py2.py3-none-any.whl
Collecting PySide2 (from guietta)
  Could not find a version that satisfies the requirement PySide2 (from guietta) (from versions: )
No matching distribution found for PySide2 (from guietta)

Search before posting

Installing PySide2 on the Pi was discussed in several places:

Tried the provided steps (below) on a Pi 1, Pi 3 a Pi 4, the original symptom remains.

sudo apt-get install python3-pyside2.qt3dcore python3-pyside2.qt3dinput python3-pyside2.qt3dlogic python3-pyside2.qt3drender python3-pyside2.qtcharts python3-pyside2.qtconcurrent python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qthelp python3-pyside2.qtlocation python3-pyside2.qtmultimedia python3-pyside2.qtmultimediawidgets python3-pyside2.qtnetwork python3-pyside2.qtopengl python3-pyside2.qtpositioning python3-pyside2.qtprintsupport python3-pyside2.qtqml python3-pyside2.qtquick python3-pyside2.qtquickwidgets python3-pyside2.qtscript python3-pyside2.qtscripttools python3-pyside2.qtsensors python3-pyside2.qtsql python3-pyside2.qtsvg python3-pyside2.qttest python3-pyside2.qttexttospeech python3-pyside2.qtuitools python3-pyside2.qtwebchannel python3-pyside2.qtwebsockets python3-pyside2.qtwidgets python3-pyside2.qtx11extras python3-pyside2.qtxml python3-pyside2.qtxmlpatterns python3-pyside2uic

Other attempts:

Workaround

In practice

sudo apt-get install python3-qtpy
git clone -b qt_via_qtpy https://github.com/fidergo-stephane-gourichon
cd guietta
pip3 install -e $PWD
cd ../my_app_using_guietta
python3 my_app_using_guietta.py

Success!

Not sure this is the best thing to do, anyway it works for me. Will open PR if you want to follow this. It might help adoption of guietta, perhaps a lot, I don't know.

alfiopuglisi commented 3 years ago

Very interesting, thanks. Changing from PySide2 to QtPy in my opinion is not so minor, although I have already done something similar (trying PySide2 and then, if it fails, falling back to PyQt5) in order to be able to run on older Macs. I will not merge your pull request immediately, maybe I will try to do a development branch with it instead, in order to test things.

alfiopuglisi commented 3 years ago

One problem is that, if one uses a wrapper like qtpy, what happens to dependencies? If one installs guietta using pip, at least one of PySide2 or PyQt5 should be specified as a dependency, otherwise the package will not work out of the box. I browsed the qtpy project but did not find hints on this. What do you think?

fidergo-stephane-gourichon commented 3 years ago

One problem is that, if one uses a wrapper like qtpy, what happens to dependencies? If one installs guietta using pip, at least one of PySide2 or PyQt5 should be specified as a dependency, otherwise the package will not work out of the box. I browsed the qtpy project but did not find hints on this. What do you think?

Mmhh, I think I see what you mean. That would an issue to discuss with QtPy people.

On Ubuntu, installing qtpy package automatically pulls the PyQt5 option. So, in practice it works. It's a little Debianish way (choose the GPL option).

Thanks for the change you made, but I had to revert to using my branch.

I saw that you try to import PySide2 with fallback to PyQt5, on https://github.com/alfiopuglisi/guietta/pull/14/commits/3bf9cbad5bc89425c7047235b02fd59ce6b1651d#diff-4a60ed8f52256b01ee98d3e645f9e341 .

That works in the simplest examples, but breaks as soon as client code runs

someQtWidget = QComboBox()

gui = Gui( [ someQtWidget ] )

it fails like this:

python3 mycode.py

Traceback (most recent call last): File "mycode.py", line 34, in gui = Gui( File "/.../guietta/guietta/guietta.py", line 1488, in init self._rows.map_in_place(_check_widget) File "/.../guietta/guietta/guietta.py", line 1279, in map_in_place row[i] = func(row[i]) File "/.../guietta/guietta/guietta.py", line 1130, in _check_widget raise ValueError('Element ' + str(x) + ' must be a widget ' ValueError: Element <PyQt5.QtWidgets.QComboBox object at 0x7f99ba9d5160> must be a widget or a (widget, name) tuple

qtpy benefit goes further than just try import one and try import the other.

alfiopuglisi commented 3 years ago

Actually I had made the change with the PyQt5 fallback for other reasons (mostly, to make it run on my older Mac which does not have a PySide2 package available), but I see the problem: once two different Qt modules are available, it becomes difficult to check if a class is an instance of QWidget or not, because there are now two possible QWidgets.

I will experimen with qtpy then :)

alfiopuglisi commented 3 years ago

Ok, I could reproduce your problem, even using qtpy! If qtpy selects PyQt5 and then I import a widget from PySide2, I get your traceback. Same with reversing the two imports. At this point, any widget import outside guietta should be done using qtpy too, in order to select the correct library.

I see no way out of this PyQt5/PySide2 mess. Maybe an option is to produce two different pip packages. A big difference is that PyQt is GPL, while PySide2 is LGPL, and this makes a difference if you want to redistribute your program.