--- a/eric6/VirtualEnv/VirtualenvManager.py Sat Jun 20 17:36:20 2020 +0200 +++ b/eric6/VirtualEnv/VirtualenvManager.py Sun Jun 21 18:26:12 2020 +0200 @@ -68,15 +68,21 @@ # path: the directory of the virtual environment # (empty for a global environment) # interpreter: the path of the Python interpreter - # variant: Python variant (2 or 3) + # variant: Python variant (always 3) # is_global: a flag indicating a global environment # is_conda: a flag indicating an Anaconda environment # is_remote: a flag indicating a remotely accessed environment # exec_path: a string to be prefixed to the PATH environment # setting # + envsToDelete = [] for venvName in environments: environment = environments[venvName] + if environment["variant"] == 2: + # Python2 environment are not supported anymore, delete them + envsToDelete.append(venvName) + continue + if ( ("is_remote" in environment and environment["is_remote"]) or os.access(environment["interpreter"], os.X_OK) @@ -91,6 +97,10 @@ environment["exec_path"] = "" self.__virtualEnvironments[venvName] = environment + # now remove unsupported environments + for venvName in envsToDelete: + del environments[venvName] + # check, if the interpreter used to run eric is in the environments defaultPy = sys.executable.replace("w.exe", ".exe") found = False @@ -104,7 +114,7 @@ self.__virtualEnvironments[VirtualenvManager.DefaultKey] = { "path": "", "interpreter": defaultPy, - "variant": sys.version_info[0], + "variant": 3, "is_global": True, "is_conda": False, "is_remote": False, @@ -186,8 +196,8 @@ dia.exec_() def addVirtualEnv(self, venvName, venvDirectory, venvInterpreter="", - venvVariant=3, isGlobal=False, isConda=False, - isRemote=False, execPath=""): + isGlobal=False, isConda=False, isRemote=False, + execPath=""): """ Public method to add a virtual environment. @@ -197,8 +207,6 @@ @type str @param venvInterpreter interpreter of the virtual environment @type str - @param venvVariant Python variant of the virtual environment - @type int @param isGlobal flag indicating a global environment @type bool @param isConda flag indicating an Anaconda virtual environment @@ -233,13 +241,13 @@ ) dlg = VirtualenvInterpreterSelectionDialog(venvName, venvDirectory) if dlg.exec_() == QDialog.Accepted: - venvInterpreter, venvVariant = dlg.getData() + venvInterpreter = dlg.getData() if venvInterpreter: self.__virtualEnvironments[venvName] = { "path": venvDirectory, "interpreter": venvInterpreter, - "variant": venvVariant, + "variant": 3, # always 3 "is_global": isGlobal, "is_conda": isConda, "is_remote": isRemote, @@ -253,8 +261,7 @@ self.__virtualenvManagerDialog.refresh() def setVirtualEnv(self, venvName, venvDirectory, venvInterpreter, - venvVariant, isGlobal, isConda, isRemote, - execPath): + isGlobal, isConda, isRemote, execPath): """ Public method to change a virtual environment. @@ -264,8 +271,6 @@ @type str @param venvInterpreter interpreter of the virtual environment @type str - @param venvVariant Python variant of the virtual environment - @type int @param isGlobal flag indicating a global environment @type bool @param isConda flag indicating an Anaconda virtual environment @@ -289,7 +294,7 @@ self.__virtualEnvironments[venvName] = { "path": venvDirectory, "interpreter": venvInterpreter, - "variant": venvVariant, + "variant": 3, # always 3 "is_global": isGlobal, "is_conda": isConda, "is_remote": isRemote, @@ -303,7 +308,7 @@ self.__virtualenvManagerDialog.refresh() def renameVirtualEnv(self, oldVenvName, venvName, venvDirectory, - venvInterpreter, venvVariant, isGlobal, isConda, + venvInterpreter, isGlobal, isConda, isRemote, execPath): """ Public method to substitute a virtual environment entry with a new @@ -317,8 +322,6 @@ @type str @param venvInterpreter interpreter of the virtual environment @type str - @param venvVariant Python variant of the virtual environment - @type int @param isGlobal flag indicating a global environment @type bool @param isConda flag indicating an Anaconda virtual environment @@ -341,8 +344,7 @@ del self.__virtualEnvironments[oldVenvName] self.addVirtualEnv(venvName, venvDirectory, venvInterpreter, - venvVariant, isGlobal, isConda, isRemote, - execPath) + isGlobal, isConda, isRemote, execPath) def deleteVirtualEnvs(self, venvNames): """ @@ -539,38 +541,6 @@ return environments - def getVirtualenvNamesForVariant(self, variant): - """ - Public method to get a list of virtual environments for a given - Python variant. - - @param variant Python variant (2 or 3) - @type int - @return list of defined virtual environments - @rtype list of str - """ - environments = [] - for venvName in self.__virtualEnvironments: - if self.__virtualEnvironments[venvName]["variant"] == variant: - environments.append(venvName) - - return environments - - def getVirtualenvVariant(self, venvName): - """ - Public method to get the variant of a virtual environment. - - @param venvName logical name for the virtual environment - @type str - @return Python variant of the environment - @rtype str - """ - if venvName in self.__virtualEnvironments: - return "Python{0}".format( - self.__virtualEnvironments[venvName]["variant"]) - else: - return "" - def isGlobalEnvironment(self, venvName): """ Public method to test, if a given environment is a global one.