eric7/Globals/__init__.py

branch
eric7
changeset 9154
e8ca7b41a7d8
parent 9066
a219ade50f7c
child 9192
a763d57e23bc
--- a/eric7/Globals/__init__.py	Fri Jun 17 16:36:14 2022 +0200
+++ b/eric7/Globals/__init__.py	Fri Jun 17 17:34:46 2022 +0200
@@ -299,70 +299,94 @@
     """
     import Preferences
     
-    path = ""
+    toolsPath = ""
     
     # step 1: check, if the user has configured a tools path
     if version == 5:
-        path = Preferences.getQt("PyQtToolsDir")
+        toolsPath = Preferences.getQt("PyQtToolsDir")
     elif version == 6:
-        path = Preferences.getQt("PyQt6ToolsDir")
+        toolsPath = Preferences.getQt("PyQt6ToolsDir")
     
     # step 2: determine from used Python interpreter (pylupdate is test object)
-    if not path:
+    if not toolsPath:
         program = "pylupdate{0}".format(version)
         if isWindowsPlatform():
             program += ".exe"
             dirName = os.path.dirname(sys.executable)
             if os.path.exists(os.path.join(dirName, program)):
-                path = dirName
+                toolsPath = dirName
             elif os.path.exists(os.path.join(dirName, "Scripts", program)):
-                path = os.path.join(dirName, "Scripts")
+                toolsPath = os.path.join(dirName, "Scripts")
         else:
             dirName = os.path.dirname(sys.executable)
             if os.path.exists(os.path.join(dirName, program)):
-                path = dirName
+                toolsPath = dirName
     
-    return path
+    return toolsPath
 
 
-def getQtBinariesPath():
+def getQtBinariesPath(libexec=False):
     """
     Module function to get the path of the Qt binaries.
     
+    @param libexec flag indicating to get the path of the executable library
+        (defaults to False)
+    @type bool (optional)
     @return path of the Qt binaries
     @rtype str
     """
     import Preferences
     
-    path = ""
+    binPath = ""
     
     # step 1: check, if the user has configured a tools path
-    path = Preferences.getQt("QtToolsDir")
+    qtToolsDir = Preferences.getQt("QtToolsDir")
+    if qtToolsDir:
+        if libexec:
+            binPath = os.path.join(qtToolsDir, "..", "libexec")
+            if not os.path.exists(binPath):
+                binPath = qtToolsDir
+        else:
+            binPath = Preferences.getQt("QtToolsDir")
+        if not os.path.exists(binPath):
+            binPath = ""
     
     # step 2: try the qt6_applications package
-    if not path:
+    if not binPath:
         with contextlib.suppress(ImportError):
+            # if qt6-applications is not installed just go to the next step
             import qt6_applications
-            path = os.path.join(os.path.dirname(qt6_applications.__file__),
-                                "Qt", "bin")
-            # if qt6-applications is not installed just go to the next step
+            if libexec:
+                binPath = os.path.join(
+                    os.path.dirname(qt6_applications.__file__),
+                    "Qt", "libexec")
+                if not os.path.exists(binPath):
+                    binPath = os.path.join(
+                        os.path.dirname(qt6_applications.__file__),
+                        "Qt", "bin")
+            else:
+                binPath = os.path.join(
+                    os.path.dirname(qt6_applications.__file__),
+                    "Qt", "bin")
+            if not os.path.exists(binPath):
+                binPath = ""
     
     # step 3: determine from used Python interpreter (designer is test object)
-    if not path:
+    if not binPath:
         program = "designer"
         if isWindowsPlatform():
             program += ".exe"
             dirName = os.path.dirname(sys.executable)
             if os.path.exists(os.path.join(dirName, program)):
-                path = dirName
+                binPath = dirName
             elif os.path.exists(os.path.join(dirName, "Scripts", program)):
-                path = os.path.join(dirName, "Scripts")
+                binPath = os.path.join(dirName, "Scripts")
         else:
             dirName = os.path.dirname(sys.executable)
             if os.path.exists(os.path.join(dirName, program)):
-                path = dirName
+                binPath = dirName
     
-    return QDir.toNativeSeparators(path)
+    return QDir.toNativeSeparators(binPath)
 
 
 ###############################################################################

eric ide

mercurial