src/eric7/Globals/__init__.py

branch
eric7-maintenance
changeset 9371
1da8bc75946f
parent 9264
18a7312cfdb3
parent 9361
718bc86e1c3f
child 9442
906485dcd210
--- a/src/eric7/Globals/__init__.py	Fri Sep 02 14:10:44 2022 +0200
+++ b/src/eric7/Globals/__init__.py	Sat Oct 01 13:06:10 2022 +0200
@@ -17,11 +17,12 @@
 import sys
 
 from PyQt6.QtCore import (
-    QDir,
     QByteArray,
     QCoreApplication,
+    QDir,
+    QLibraryInfo,
+    QProcess,
     QT_VERSION,
-    QProcess,
     qVersion,
 )
 
@@ -310,23 +311,33 @@
     # step 1: check, if the user has configured a tools path
     if version == 5:
         toolsPath = Preferences.getQt("PyQtToolsDir")
+        venvName = Preferences.getQt("PyQtVenvName")
     elif version == 6:
         toolsPath = Preferences.getQt("PyQt6ToolsDir")
+        venvName = Preferences.getQt("PyQt6VenvName")
 
     # step 2: determine from used Python interpreter (pylupdate is test object)
     if not toolsPath:
         program = "pylupdate{0}".format(version)
+        if venvName:
+            from EricWidgets.EricApplication import ericApp
+
+            venvManager = ericApp().getObject("VirtualEnvManager")
+            dirName = venvManager.getVirtualenvDirectory(venvName)
+        else:
+            dirName = os.path.dirname(sys.executable)
+
         if isWindowsPlatform():
             program += ".exe"
-            dirName = os.path.dirname(sys.executable)
             if os.path.exists(os.path.join(dirName, program)):
                 toolsPath = dirName
             elif os.path.exists(os.path.join(dirName, "Scripts", program)):
                 toolsPath = os.path.join(dirName, "Scripts")
         else:
-            dirName = os.path.dirname(sys.executable)
             if os.path.exists(os.path.join(dirName, program)):
                 toolsPath = dirName
+            elif os.path.exists(os.path.join(dirName, "bin", program)):
+                toolsPath = os.path.join(dirName, "bin")
 
     return toolsPath
 
@@ -378,7 +389,15 @@
             if not os.path.exists(binPath):
                 binPath = ""
 
-    # step 3: determine from used Python interpreter (designer is test object)
+    # step3: determine via QLibraryInfo
+    if not binPath:
+        binPath = (
+            QLibraryInfo.path(QLibraryInfo.LibraryPath.LibraryExecutablesPath)
+            if libexec
+            else QLibraryInfo.path(QLibraryInfo.LibraryPath.BinariesPath)
+        )
+
+    # step 4: determine from used Python interpreter (designer is test object)
     if not binPath:
         program = "designer"
         if isWindowsPlatform():

eric ide

mercurial