eric7/Project/Project.py

branch
unittest
changeset 9056
af7c8c7b7c62
parent 8943
23f9c7b9e18e
child 9065
39405e6eba20
--- a/eric7/Project/Project.py	Sat May 07 16:30:34 2022 +0200
+++ b/eric7/Project/Project.py	Sun May 08 15:44:29 2022 +0200
@@ -39,6 +39,7 @@
 
 from EricGui.EricAction import EricAction, createActionGroup
 
+import Globals
 import Preferences
 import Utilities
 
@@ -3704,6 +3705,67 @@
         """
         return self.pdata["DESCRIPTION"]
     
+    def getProjectVenv(self, resolveDebugger=True):
+        """
+        Public method to get the name of the virtual environment used by the
+        project.
+        
+        @param resolveDebugger flag indicating to resolve the virtual
+            environment name via the debugger settings if none was configured
+        @type bool
+        @return name of the project's virtual environment
+        @rtype str
+        """
+        venvName = self.getDebugProperty("VIRTUALENV")
+        if (
+            not venvName and
+            resolveDebugger and
+            self.getProjectLanguage() in ("Python3", "MicroPython", "Cython")
+        ):
+            venvName = Preferences.getDebugger("Python3VirtualEnv")
+        
+        return venvName
+    
+    def getProjectInterpreter(self, resolveGlobal=True):
+        """
+        Public method to get the path of the interpreter used by the project.
+        
+        @param resolveGlobal flag indicating to resolve the interpreter using
+            the global interpreter if no project of debugger specific
+            environment was configured
+        @type bool
+        @return path of the project's interpreter
+        @rtype str
+        """
+        interpreter = ""
+        venvName = self.getProjectVenv()
+        if venvName:
+            interpreter = (
+                ericApp().getObject("VirtualEnvManager")
+                .getVirtualenvInterpreter(venvName)
+            )
+        if not interpreter and resolveGlobal:
+            interpreter = Globals.getPythonExecutable()
+        
+        return interpreter
+    
+    def getProjectExecPath(self):
+        """
+        Public method to get the executable search path prefix of the project.
+        
+        @return executable search path prefix
+        @rtype str
+        """
+        execPath = ""
+        venvName = self.getProjectVenv()
+        if venvName:
+            execPath = (
+                ericApp().getObject("VirtualEnvManager")
+                .getVirtualenvExecPath(venvName)
+            )
+        
+        return execPath
+    
     def __isInPdata(self, fn):
         """
         Private method used to check, if the passed in filename is project

eric ide

mercurial