diff -r 82f08c4fd930 -r 135240382a3e eric7/VirtualEnv/VirtualenvManager.py --- a/eric7/VirtualEnv/VirtualenvManager.py Fri Jun 10 11:12:50 2022 +0200 +++ b/eric7/VirtualEnv/VirtualenvManager.py Fri Jun 10 18:13:47 2022 +0200 @@ -23,8 +23,6 @@ import Preferences -# TODO: add capability to upgrade a virtual environment (venv --upgrade) -# TODO: add capability to upgrade the core dependencies (venv --upgrade-deps) class VirtualenvManager(QObject): """ Class implementing an object to manage Python virtual environments. @@ -139,6 +137,14 @@ ) Preferences.syncPreferences() + @pyqtSlot() + def reloadSettings(self): + """ + Public slot to reload the virtual environments. + """ + Preferences.syncPreferences() + self.__loadSettings() + def getDefaultEnvironment(self): """ Public method to get the default virtual environment. @@ -218,6 +224,36 @@ dia.start(resultDict["arguments"]) dia.exec() + @pyqtSlot() + def upgradeVirtualEnv(self, venvName): + """ + Public slot to upgrade a virtual environment. + + @param venvName name of the virtual environment + @type str + """ + from .VirtualenvUpgradeConfigurationDialog import ( + VirtualenvUpgradeConfigurationDialog + ) + + venvDirectory = self.getVirtualenvDirectory(venvName) + if not os.path.exists(os.path.join(venvDirectory, "pyvenv.cfg")): + # The environment was not created by the 'venv' module. + return + + dlg = VirtualenvUpgradeConfigurationDialog(venvName, venvDirectory) + if dlg.exec() == QDialog.DialogCode.Accepted: + pythonExe, args, createLog = dlg.getData() + + from .VirtualenvUpgradeExecDialog import ( + VirtualenvUpgradeExecDialog + ) + dia = VirtualenvUpgradeExecDialog( + venvName, pythonExe, createLog, self) + dia.show() + dia.start(args) + dia.exec() + def addVirtualEnv(self, venvName, venvDirectory, venvInterpreter="", isGlobal=False, isConda=False, isRemote=False, execPath=""): @@ -523,6 +559,24 @@ else: return "" + def setVirtualEnvInterpreter(self, venvName, venvInterpreter): + """ + Public method to change the interpreter for a virtual environment. + + @param venvName logical name for the virtual environment + @type str + @param venvInterpreter interpreter path to be set + @type str + """ + if venvName in self.__virtualEnvironments: + self.__virtualEnvironments[venvName]["interpreter"] = ( + venvInterpreter + ) + self.__saveSettings() + + self.virtualEnvironmentChanged.emit(venvName) + self.virtualEnvironmentsListChanged.emit() + def getVirtualenvDirectory(self, venvName): """ Public method to get the directory of a virtual environment.