Refined the PyQt4 compatibility stuff.

Mon, 24 Nov 2014 18:39:19 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 24 Nov 2014 18:39:19 +0100
changeset 3937
607dd5b0079b
parent 3936
93fb2fd523f1
child 3938
d2b103d42907

Refined the PyQt4 compatibility stuff.

Toolbox/PyQt4ImportHook.py file | annotate | diff | comparison | revisions
eric6.py file | annotate | diff | comparison | revisions
install.py file | annotate | diff | comparison | revisions
--- a/Toolbox/PyQt4ImportHook.py	Sun Nov 23 18:40:40 2014 +0100
+++ b/Toolbox/PyQt4ImportHook.py	Mon Nov 24 18:39:19 2014 +0100
@@ -6,6 +6,7 @@
 import sys
 try:
     if "--pyqt4" in sys.argv:
+        sys.argv.remove("--pyqt4")
         # fake a failed PyQt5 import
         raise ImportError
     import PyQt5    # __IGNORE_WARNING__ 
--- a/eric6.py	Sun Nov 23 18:40:40 2014 +0100
+++ b/eric6.py	Mon Nov 24 18:39:19 2014 +0100
@@ -13,6 +13,13 @@
 
 from __future__ import unicode_literals
 
+import sys
+
+# generate list of arguments to be remembered for a restart
+restartArgsList = ["--nosplash", "--plugin", "--debug", "--config", "--pyqt4"]
+restartArgs = [arg for arg in sys.argv[1:]
+               if arg.split("=", 1)[0] in restartArgsList]
+
 import Toolbox.PyQt4ImportHook  # __IGNORE_WARNING__ 
 
 try:  # Only for Py2
@@ -29,7 +36,6 @@
     pass
 
 
-import sys
 import os
 import traceback
 import time
@@ -56,11 +62,6 @@
 mainWindow = None
 splash = None
 
-# generate list of arguments to be remembered for a restart
-restartArgsList = ["--nosplash", "--plugin", "--debug", "--config"]
-restartArgs = [arg for arg in sys.argv[1:]
-               if arg.split("=", 1)[0] in restartArgsList]
-
 if "--debug" in sys.argv:
     del sys.argv[sys.argv.index("--debug")]
     logging.basicConfig(level=logging.DEBUG)
--- a/install.py	Sun Nov 23 18:40:40 2014 +0100
+++ b/install.py	Mon Nov 24 18:39:19 2014 +0100
@@ -49,6 +49,7 @@
 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
     sys.exec_prefix)
 pyqtVariant = ""
+pyqtOverride = False
 
 # Define blacklisted versions of the prerequisites
 BlackLists = {
@@ -180,14 +181,16 @@
     """
     Module function to determine the PyQt variant to be used.
     """
-    global pyqtVariant
+    global pyqtVariant, pyqtOverride
     
     pyqtVariant = ""
     # need to handle the --pyqt= option here
     if "--pyqt=4" in sys.argv:
         pyqtVariant = "PyQt4"
+        pyqtOverride = True
     elif "--pyqt=5" in sys.argv:
         pyqtVariant = "PyQt5"
+        pyqtOverride = True
     else:
         try:
             import PyQt5        # __IGNORE_WARNING__
@@ -299,14 +302,14 @@
         application (boolean)
     @return the platform specific name of the wrapper (string)
     """
-    global includePythonVariant, pyqtVariant
+    global includePythonVariant, pyqtVariant, pyqtOverride
     
     if includePythonVariant:
         marker = PythonMarkers[sys.version_info.major]
     else:
         marker = ""
     
-    if pyqtVariant == "PyQt4":
+    if pyqtOverride and pyqtVariant == "PyQt4":
         pyqt4opt = " --pyqt4"
     else:
         pyqt4opt = ""
@@ -1291,7 +1294,7 @@
     global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
     global sourceDir, configName, includePythonVariant
     global macAppBundlePath, macAppBundleName, macPythonExe
-    global pyqtVariant
+    global pyqtVariant, pyqtOverride
     
     if sys.version_info < (2, 7, 0) or sys.version_info > (3, 9, 9):
         print('Sorry, eric6 requires at least Python 2.7 or '
@@ -1363,6 +1366,7 @@
                 print("Invalid PyQt version given; should be 4 or 5. Aborting")
                 exit(6)
             pyqtVariant = "PyQt{0}".format(arg)
+            pyqtOverride = True
     
     installFromSource = not os.path.isdir(sourceDir)
     if installFromSource:

eric ide

mercurial