eric7/VirtualEnv/VirtualenvManager.py

branch
eric7
changeset 8972
54816b8f740f
parent 8881
54e42bc2437a
child 9016
6f079c524e99
diff -r 0a846d71f27c -r 54816b8f740f eric7/VirtualEnv/VirtualenvManager.py
--- a/eric7/VirtualEnv/VirtualenvManager.py	Sat Mar 05 18:10:28 2022 +0100
+++ b/eric7/VirtualEnv/VirtualenvManager.py	Sun Mar 06 19:53:19 2022 +0100
@@ -156,14 +156,25 @@
             )
         
         else:
-            defaultPy = sys.executable.replace("w.exe", ".exe")
-            for venvName in self.__virtualEnvironments:
-                if (defaultPy ==
-                        self.__virtualEnvironments[venvName]["interpreter"]):
-                    return (
-                        venvName,
-                        copy.copy(self.__virtualEnvironments[venvName])
-                    )
+            return self.environmentForInterpreter(sys.executable)
+    
+    def environmentForInterpreter(self, interpreter):
+        """
+        Public method to get the environment a given interpreter belongs to.
+        
+        @param interpreter path of the interpreter
+        @type str
+        @return tuple containing the environment name and a dictionary
+            containing a copy of the default virtual environment
+        @rtype tuple of (str, dict)
+        """
+        py = interpreter.replace("w.exe", ".exe")
+        for venvName in self.__virtualEnvironments:
+            if (py == self.__virtualEnvironments[venvName]["interpreter"]):
+                return (
+                    venvName,
+                    copy.copy(self.__virtualEnvironments[venvName])
+                )
         
         return ("", {})
     

eric ide

mercurial