137 "PyVenv/VirtualEnvironments", |
135 "PyVenv/VirtualEnvironments", |
138 json.dumps(self.__virtualEnvironments) |
136 json.dumps(self.__virtualEnvironments) |
139 ) |
137 ) |
140 Preferences.syncPreferences() |
138 Preferences.syncPreferences() |
141 |
139 |
|
140 @pyqtSlot() |
|
141 def reloadSettings(self): |
|
142 """ |
|
143 Public slot to reload the virtual environments. |
|
144 """ |
|
145 Preferences.syncPreferences() |
|
146 self.__loadSettings() |
|
147 |
142 def getDefaultEnvironment(self): |
148 def getDefaultEnvironment(self): |
143 """ |
149 """ |
144 Public method to get the default virtual environment. |
150 Public method to get the default virtual environment. |
145 |
151 |
146 Default is an environment with the key '<default>' or the first one |
152 Default is an environment with the key '<default>' or the first one |
216 dia = VirtualenvExecDialog(resultDict, self) |
222 dia = VirtualenvExecDialog(resultDict, self) |
217 dia.show() |
223 dia.show() |
218 dia.start(resultDict["arguments"]) |
224 dia.start(resultDict["arguments"]) |
219 dia.exec() |
225 dia.exec() |
220 |
226 |
|
227 @pyqtSlot() |
|
228 def upgradeVirtualEnv(self, venvName): |
|
229 """ |
|
230 Public slot to upgrade a virtual environment. |
|
231 |
|
232 @param venvName name of the virtual environment |
|
233 @type str |
|
234 """ |
|
235 from .VirtualenvUpgradeConfigurationDialog import ( |
|
236 VirtualenvUpgradeConfigurationDialog |
|
237 ) |
|
238 |
|
239 venvDirectory = self.getVirtualenvDirectory(venvName) |
|
240 if not os.path.exists(os.path.join(venvDirectory, "pyvenv.cfg")): |
|
241 # The environment was not created by the 'venv' module. |
|
242 return |
|
243 |
|
244 dlg = VirtualenvUpgradeConfigurationDialog(venvName, venvDirectory) |
|
245 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
246 pythonExe, args, createLog = dlg.getData() |
|
247 |
|
248 from .VirtualenvUpgradeExecDialog import ( |
|
249 VirtualenvUpgradeExecDialog |
|
250 ) |
|
251 dia = VirtualenvUpgradeExecDialog( |
|
252 venvName, pythonExe, createLog, self) |
|
253 dia.show() |
|
254 dia.start(args) |
|
255 dia.exec() |
|
256 |
221 def addVirtualEnv(self, venvName, venvDirectory, venvInterpreter="", |
257 def addVirtualEnv(self, venvName, venvDirectory, venvInterpreter="", |
222 isGlobal=False, isConda=False, isRemote=False, |
258 isGlobal=False, isConda=False, isRemote=False, |
223 execPath=""): |
259 execPath=""): |
224 """ |
260 """ |
225 Public method to add a virtual environment. |
261 Public method to add a virtual environment. |
521 .replace("w.exe", ".exe") |
557 .replace("w.exe", ".exe") |
522 ) |
558 ) |
523 else: |
559 else: |
524 return "" |
560 return "" |
525 |
561 |
|
562 def setVirtualEnvInterpreter(self, venvName, venvInterpreter): |
|
563 """ |
|
564 Public method to change the interpreter for a virtual environment. |
|
565 |
|
566 @param venvName logical name for the virtual environment |
|
567 @type str |
|
568 @param venvInterpreter interpreter path to be set |
|
569 @type str |
|
570 """ |
|
571 if venvName in self.__virtualEnvironments: |
|
572 self.__virtualEnvironments[venvName]["interpreter"] = ( |
|
573 venvInterpreter |
|
574 ) |
|
575 self.__saveSettings() |
|
576 |
|
577 self.virtualEnvironmentChanged.emit(venvName) |
|
578 self.virtualEnvironmentsListChanged.emit() |
|
579 |
526 def getVirtualenvDirectory(self, venvName): |
580 def getVirtualenvDirectory(self, venvName): |
527 """ |
581 """ |
528 Public method to get the directory of a virtual environment. |
582 Public method to get the directory of a virtual environment. |
529 |
583 |
530 @param venvName logical name for the virtual environment |
584 @param venvName logical name for the virtual environment |