Changeset 2774

Show
Ignore:
Timestamp:
03/06/18 14:39:36 (9 months ago)
Author:
jwoithe
Message:

ffado-mixer: don't try loading PyQt?4 if Python3 is in use.

While defaulting to PyQt?4 is reasonable if Python2 is in use, this is not
generally applicable under Python3. In the Python3 case, PyQt?5 should be
used because the python3 code assumes the newer API offered by PyQt?5. This
patch applies this logic in a way which works on Python3 systems which have
both PyQt?4 and PyQt?5 installed.

Thanks to David Runge for notifying us about this issue and for an initial
patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/import_pyqt.py

    r2696 r2774  
    2121# 
    2222 
    23 ffado_pyqt_version = 4 
    24  
    25 # This module handles the importing of PyQt modules for both PyQt4 and PyQt5. 
    26 # The idea is to first try importing PyQt4.  If there's an import error it's 
    27 # assumed PyQt5 is present instead and that is tried. 
     23# This module handles the importing of PyQt modules for both PyQt4 and PyQt5 
     24# under Python2 or Python3.  If Python3 is installed it is assumed that 
     25# PyQt5 is in use (this is reasonable because PyQt5 is what everyone wants 
     26# to use under Python3).  Otherwise (that is, under Python2), an import of 
     27# PyQt4 is tried first; if an import error occurs then PyQt5 is assumed. 
    2828# 
    2929# All modules used by any part of ffado-mixer are imported.  This greatly 
     
    3131# by string variables, and there isn't a supported way to do this across  
    3232# Python2 and Python3. 
    33 try: 
     33 
     34import sys 
     35ffado_python3 = sys.version_info >= (3,) 
     36 
     37if ffado_python3: 
     38    ffado_pyqt_version = 5 
     39else: 
     40    try: 
     41        from PyQt4 import QtGui 
     42        ffado_pyqt_version = 4 
     43    except ImportError: 
     44        ffado_pyqt_version = 5 
     45 
     46if ffado_pyqt_version == 4: 
    3447    from PyQt4 import QtGui, QtCore, Qt, uic 
    3548    from PyQt4.QtCore import QByteArray, QObject, QTimer, Qt, pyqtSignal, QString, pyqtSlot 
    3649    from PyQt4.QtGui import * 
    37     ffado_pyqt_version = 4 
    38 except ImportError: 
     50else: 
    3951    from PyQt5 import QtGui, Qt, QtCore, Qt, QtWidgets, uic 
    4052    from PyQt5.QtCore import QByteArray, QObject, pyqtSignal, pyqtSlot, QTimer, Qt 
    4153    from PyQt5.QtGui import * 
    4254    from PyQt5.QtWidgets import * 
    43     ffado_pyqt_version = 5 
    44  
    45 import sys 
    46 ffado_python3 = sys.version_info >= (3,)