--- a/VirtualEnv/VirtualenvManager.py Sat Nov 03 14:16:43 2018 +0100 +++ b/VirtualEnv/VirtualenvManager.py Sat Nov 03 14:19:21 2018 +0100 @@ -59,6 +59,9 @@ # interpreter: the path of the Python interpreter # variant: Python variant (2 or 3) # is_global: a flag indicating a global environment + # is_conda: a flag indicating an Anaconda environment + # exec_path: a string to be prefixed to the PATH environment + # setting # for venvName in environments: interpreter = environments[venvName]["interpreter"] @@ -66,6 +69,10 @@ environment = environments[venvName] if "is_global" not in environment: environment["is_global"] = environment["path"] == "" + if "is_conda" not in environment: + environment["is_conda"] = False + if "exec_path" not in environment: + environment["exec_path"] = "" self.__virtualEnvironments[venvName] = environment # check, if the interpreter used to run eric is in the environments @@ -83,6 +90,8 @@ "interpreter": defaultPy, "variant": sys.version_info[0], "is_global": True, + "is_conda": False, + "exec_path": "", } self.__saveSettings() @@ -150,7 +159,8 @@ dia.exec_() def addVirtualEnv(self, venvName, venvDirectory, venvInterpreter="", - venvVariant=3, isGlobal=False): + venvVariant=3, isGlobal=False, isConda=False, + execPath=""): """ Public method to add a virtual environment. @@ -164,6 +174,11 @@ @type int @param isGlobal flag indicating a global environment @type bool + @param isConda flag indicating an Anaconda virtual environment + @type bool + @param execPath search path string to be prepended to the PATH + environment variable + @type str """ if venvName in self.__virtualEnvironments: ok = E5MessageBox.yesNo( @@ -190,6 +205,8 @@ "interpreter": venvInterpreter, "variant": venvVariant, "is_global": isGlobal, + "is_conda": isConda, + "exec_path": execPath, } self.__saveSettings() @@ -198,7 +215,7 @@ self.__virtualenvManagerDialog.refresh() def setVirtualEnv(self, venvName, venvDirectory, venvInterpreter, - venvVariant, isGlobal): + venvVariant, isGlobal, isConda, execPath): """ Public method to change a virtual environment. @@ -212,6 +229,11 @@ @type int @param isGlobal flag indicating a global environment @type bool + @param isConda flag indicating an Anaconda virtual environment + @type bool + @param execPath search path string to be prepended to the PATH + environment variable + @type str """ if venvName not in self.__virtualEnvironments: E5MessageBox.yesNo( @@ -228,6 +250,8 @@ "interpreter": venvInterpreter, "variant": venvVariant, "is_global": isGlobal, + "is_conda": isConda, + "exec_path": execPath, } self.__saveSettings() @@ -236,7 +260,8 @@ self.__virtualenvManagerDialog.refresh() def renameVirtualEnv(self, oldVenvName, venvName, venvDirectory, - venvInterpreter, venvVariant, isGlobal): + venvInterpreter, venvVariant, isGlobal, isConda, + execPath): """ Public method to substitute a virtual environment entry with a new name. @@ -253,6 +278,11 @@ @type int @param isGlobal flag indicating a global environment @type bool + @param isConda flag indicating an Anaconda virtual environment + @type bool + @param execPath search path string to be prepended to the PATH + environment variable + @type str """ if oldVenvName not in self.__virtualEnvironments: E5MessageBox.yesNo( @@ -266,7 +296,7 @@ del self.__virtualEnvironments[oldVenvName] self.addVirtualEnv(venvName, venvDirectory, venvInterpreter, - venvVariant, isGlobal) + venvVariant, isGlobal, isConda, execPath) def deleteVirtualEnvs(self, venvNames): """ @@ -468,4 +498,36 @@ @return flag indicating a global environment @rtype bool """ - return self.__virtualEnvironments[venvName]["is_global"] + if venvName in self.__virtualEnvironments: + return self.__virtualEnvironments[venvName]["is_global"] + else: + return False + + def isCondaEnvironment(self, venvName): + """ + Public method to test, if a given environment is an Anaconda + environment. + + @param venvName logical name of the virtual environment + @type str + @return flag indicating an Anaconda environment + @rtype bool + """ + if venvName in self.__virtualEnvironments: + return self.__virtualEnvironments[venvName]["is_conda"] + else: + return False + + def getVirtualenvExecPath(self, venvName): + """ + Public method to get the search path prefix of a virtual environment. + + @param venvName logical name for the virtual environment + @type str + @return search path prefix + @rtype str + """ + if venvName in self.__virtualEnvironments: + return self.__virtualEnvironments[venvName]["exec_path"] + else: + return ""