Bug 211908 - devel/eric6: fails to start if PyQt5 is installed
Summary: devel/eric6: fails to start if PyQt5 is installed
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Boris Samorodov
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-08-16 15:20 UTC by David Naylor
Modified: 2016-08-18 15:42 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (bsam)


Attachments
Fix Eric6 when PyQt5 is also installed (955 bytes, patch)
2016-08-17 16:25 UTC, David Naylor
no flags Details | Diff
Fix typo (955 bytes, patch)
2016-08-17 16:42 UTC, David Naylor
no flags Details | Diff
Add support for both PyQt 4 and PyQt 5 (as an option) (2.89 KB, patch)
2016-08-17 19:00 UTC, David Naylor
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Naylor freebsd_committer freebsd_triage 2016-08-16 15:20:31 UTC
I have the following installed:
```
pkg info | grep -i py27-qt
py27-qt4-core-4.11.4,1         Python bindings for the Qt4 toolkit, QtCore module
py27-qt4-dbussupport-4.11.4_1  Qt event loop support for dbus-python
py27-qt4-declarative-4.11.4    Python bindings for the Qt4 toolkit, QtDeclarative module
py27-qt4-designer-4.11.4,1     Python bindings for the Qt4 toolkit, QtDesigner module
py27-qt4-gui-4.11.4,1          Python bindings for the Qt4 toolkit, QtGui module
py27-qt4-help-4.11.4           Python bindings for the Qt4 toolkit, QtHelp module
py27-qt4-network-4.11.4,1      Python bindings for the Qt4 toolkit, QtNetwork module
py27-qt4-opengl-4.11.4,1       Python bindings for the Qt4 toolkit, QtOpenGL module
py27-qt4-phonon-4.11.4         Python bindings for the Qt4 toolkit, Phonon module
py27-qt4-qscintilla2-2.9.1,1   Python bindings for QScintilla2 (PyQt4), QSci module
py27-qt4-script-4.11.4,1       Python bindings for the Qt4 toolkit, QtScript module
py27-qt4-sql-4.11.4,1          Python bindings for the Qt4 toolkit, QtSql module
py27-qt4-svg-4.11.4,1          Python bindings for the Qt4 toolkit, QtSvg module
py27-qt4-webkit-4.11.4         Python bindings for the Qt4 toolkit, QtWebKit module
py27-qt4-xml-4.11.4,1          Python bindings for the Qt4 toolkit, QtXml module
py27-qt5-core-5.5.1            Python bindings for the Qt5 toolkit, QtCore module
py27-qt5-gui-5.5.1             Python bindings for the Qt5 toolkit, QtGui module
py27-qt5-network-5.5.1         Python bindings for the Qt5 toolkit, QtNetwork module
py27-qt5-printsupport-5.5.1    Python bindings for the Qt5 toolkit, QtPrintSupport module
py27-qt5-qscintilla2-2.9.1     Python bindings for QScintilla2 (PyQt5), QSci module
py27-qt5-svg-5.5.1             Python bindings for the Qt5 toolkit, QtSvg module
py27-qt5-webkit-5.5.1          Python bindings for the Qt5 toolkit, QtWebKit module
py27-qt5-webkitwidgets-5.5.1   Python bindings for the Qt5 toolkit, QtWebKitWidgets module
py27-qt5-widgets-5.5.1         Python bindings for the Qt5 toolkit, QtWidgets module
py27-qt5-xmlpatterns-5.5.1     Python bindings for the Qt5 toolkit, QtXmlPatterns module
```

And starting eric6 results in:
```
eric6
An unhandled exception occurred. Please report the problem
using the error reporting dialog or via email to <eric-bugs@eric-ide.python-projects.org>.
A log has been written to "/usr/local/home/dbn/.eric6/eric6_error.log".

Error information:
--------------------------------------------------------------------------------
2016-08-16, 17:19:39
--------------------------------------------------------------------------------
<type 'exceptions.RuntimeError'>: 
the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class
--------------------------------------------------------------------------------
  File "/usr/local/share/eric6/eric6.py", line 359, in <module>
    main()
  File "/usr/local/share/eric6/eric6.py", line 335, in main
    from UI.UserInterface import UserInterface
  File "/usr/local/share/eric6/UI/UserInterface.py", line 45, in <module>
    from E5Gui.E5ZoomWidget import E5ZoomWidget
  File "/usr/local/share/eric6/E5Gui/E5ZoomWidget.py", line 15, in <module>
    from .Ui_E5ZoomWidget import Ui_E5ZoomWidget
  File "/usr/local/share/eric6/E5Gui/Ui_E5ZoomWidget.py", line 9, in <module>
    from PyQt4 import QtCore, QtGui

--------------------------------------------------------------------------------
Version Numbers:
  Python 2.7.12
  Qt 5.5.1
  PyQt 5.5.1
  sip 4.17
  QScintilla 2.9.1
  WebKit 538.1
  eric6 6.1.7 (rev. bacf24bb4129)

Platform: freebsd10
2.7.12 (default, Jul 26 2016, 01:23:30) 
[GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)]
```

This can be fixed by added `--pyqt4` to the eric6 command.
Comment 1 Walter Schwarzenfeld freebsd_triage 2016-08-16 22:13:17 UTC
I had to add all  py27-qt5 "DEPENDS", cause it was not compile to the end.q But then it starts without problems.
+BUilD_DEPENDS= ${PYTHON_SITELIBDIR}/PyQt5/Qsci.so:devel/py-qt5-qscintilla2
+RUN_DEPENDS= ${PYTHON_SITELIBDIR}/PyQt5/QtNetwork.so:net/py-qt5-network \
+                ${PYTHON_SITELIBDIR}/PyQt5/QtSvg.so:graphics/py-qt5-svg \
+                ${PYTHON_SITELIBDIR}/PyQt5/QtSql.so:databases/py-qt5-sql \
Comment 2 David Naylor freebsd_committer freebsd_triage 2016-08-17 16:20:41 UTC
It appears that, on compilation, the Ui files are hard coded to either PyQt4 or PyQt5.  In my situation I had PyQt5 installed (but Eric was compiled against PyQt4).  This caused Eric to try PyQt5 first, until it loaded a Ui file.
Comment 3 David Naylor freebsd_committer freebsd_triage 2016-08-17 16:25:31 UTC
Created attachment 173787 [details]
Fix Eric6 when PyQt5 is also installed

Fix Eric6 when PyQt5 is installed by passing `--pyqt=4` to the install arguments.  This causes the eric6 binary to assume `--pyqt4` is passed, preventing the loading of PyQt5 if it is installed.  

While here fix the warning about absolute symlinks.
Comment 4 Walter Schwarzenfeld freebsd_triage 2016-08-17 16:32:55 UTC
(In reply to David Naylor from comment #3)
I see in the patch you are adding -pyqt=5 not -pyqt=4.
Comment 5 David Naylor freebsd_committer freebsd_triage 2016-08-17 16:42:59 UTC
Created attachment 173788 [details]
Fix typo

Sorry, change got lost in my attempt to add PyQt5 support to the port (in progress) and then retrospectively redid the change.
Comment 6 Boris Samorodov freebsd_committer freebsd_triage 2016-08-17 16:54:17 UTC
David, are you interested in maintaining this port? I've switched to other editors, so do not use it any more.
Comment 7 David Naylor freebsd_committer freebsd_triage 2016-08-17 18:29:02 UTC
Boris, happy to maintain eric.  Out of interest, what editors are you using now?
Comment 8 Boris Samorodov freebsd_committer freebsd_triage 2016-08-17 18:40:26 UTC
David, please do. I'll be happy to pass the port to you.
For python I use java/intellij-pycharm.
Comment 9 David Naylor freebsd_committer freebsd_triage 2016-08-17 19:00:53 UTC
Created attachment 173797 [details]
Add support for both PyQt 4 and PyQt 5 (as an option)

Currently this does not work:
```

(gdb) bt
#0  0x000001bb00000db4 in ?? ()
#1  0x0000000806ca47f5 in parsePass1 () from /usr/local/lib/python2.7/site-packages/sip.so
#2  0x0000000806ca2b6f in parseKwdArgs () from /usr/local/lib/python2.7/site-packages/sip.so
#3  0x0000000806ca040b in sip_api_parse_kwd_args () from /usr/local/lib/python2.7/site-packages/sip.so
#4  0x000000080fcd166e in init_type_QsciScintilla () from /usr/local/lib/python2.7/site-packages/PyQt5/Qsci.so
#5  0x0000000806c9b602 in sipSimpleWrapper_init () from /usr/local/lib/python2.7/site-packages/sip.so
#6  0x0000000800aea50c in _PyObject_SlotCompare () from /usr/local/lib/libpython2.7.so.1
#7  0x0000000800a93864 in PyObject_Call () from /usr/local/lib/libpython2.7.so.1
```
Comment 10 Walter Schwarzenfeld freebsd_triage 2016-08-17 19:40:21 UTC
Is the question why. I tested the patch on my system (10.3-RELEASE) and it works. I see the difference between qt4 and   qt5 cause it has on my system different configuration (e.g. fonts).
And both seems to work, compiles, installs and starts without problems.
(A weak try: reinstall py-sip and py-setuptools, and see if you have a better result. This solves some problems with python in the past).
Comment 11 David Naylor freebsd_committer freebsd_triage 2016-08-17 20:10:04 UTC
Strange, I can reproduce it with this simple script:
```
#!/usr/bin/env python
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.Qsci import QsciScintilla

app = QApplication([])
widget = QWidget()
qsci = QsciScintilla(widget)
```

I also install the required dependencies from packages, maybe I need to reinstall (or try from source).
Comment 12 Walter Schwarzenfeld freebsd_triage 2016-08-17 22:18:20 UTC
Little bit strange, sometime I got the error-message on commandline, sometimes in the debug window, but mostly not.
My idea:
Put in
 /usr/local/share/eric6/eric6.py
restartArgsList = ["--nosplash", "--plugin", "--debug", "--config", "--pyqt4"
                   "--settings"]

"--pygt4" on first place in the ArgsList - maybe, it is only the debug message.

Sometimes it runs still (mostly not), if I close the windows, but I am not sure if this is not a "shell-thing".
Comment 13 Walter Schwarzenfeld freebsd_triage 2016-08-17 22:56:43 UTC
i can't test, see above, not always came the error message:
Another way maybe (don't know if the syntax is right)
49     from PyQt5.QtCore import qWarning, QLibraryInfo, QTimer, QCoreApplicatio
50 except ImportError:
51     use("Qt4Agg")
and
87         from PyQt5.QtCore import QSettings
88         use("Qt4Agg")
Comment 14 commit-hook freebsd_committer freebsd_triage 2016-08-18 15:40:18 UTC
A commit references this bug:

Author: dbn
Date: Thu Aug 18 15:39:56 UTC 2016
New revision: 420409
URL: https://svnweb.freebsd.org/changeset/ports/420409

Log:
  devel/eric6: add option to use PyQt5, fix PyQt4.

   - Fix the use of PyQt4 when PyQt5 is installed:
     - Specify which version of PyQt to target on installation
   - Add support for switching between PyQt4 and PyQt5 for the GUI.
   - Fix stage-qa warning:
     - Make symlink to pixmap relative.
   - Take over maintainership

  PR:		211908

Changes:
  head/devel/eric6/Makefile
  head/devel/eric6/Makefile.inc
Comment 15 David Naylor freebsd_committer freebsd_triage 2016-08-18 15:42:41 UTC
Commit fixed, and taken maintainership.  Thank you for maintaining this port.