src/eric7/VirtualEnv/VirtualenvManager.py

branch
eric7
changeset 9434
ef86a77942f2
parent 9418
93698f6003d3
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9433:6df1aeaa4529 9434:ef86a77942f2
79 # is_global: a flag indicating a global environment 79 # is_global: a flag indicating a global environment
80 # is_conda: a flag indicating an Anaconda environment 80 # is_conda: a flag indicating an Anaconda environment
81 # is_remote: a flag indicating a remotely accessed environment 81 # is_remote: a flag indicating a remotely accessed environment
82 # exec_path: a string to be prefixed to the PATH environment 82 # exec_path: a string to be prefixed to the PATH environment
83 # setting 83 # setting
84 # description a description of the environment
84 # 85 #
85 envsToDelete = [] 86 envsToDelete = []
86 for venvName in environments: 87 for venvName in environments:
87 environment = environments[venvName] 88 environment = environments[venvName]
88 if ("is_remote" in environment and environment["is_remote"]) or os.access( 89 if ("is_remote" in environment and environment["is_remote"]) or os.access(
94 environment["is_conda"] = False 95 environment["is_conda"] = False
95 if "is_remote" not in environment: 96 if "is_remote" not in environment:
96 environment["is_remote"] = False 97 environment["is_remote"] = False
97 if "exec_path" not in environment: 98 if "exec_path" not in environment:
98 environment["exec_path"] = "" 99 environment["exec_path"] = ""
100 if "description" not in environment:
101 environment["description"] = ""
99 self.__virtualEnvironments[venvName] = environment 102 self.__virtualEnvironments[venvName] = environment
100 103
101 # now remove unsupported environments 104 # now remove unsupported environments
102 for venvName in envsToDelete: 105 for venvName in envsToDelete:
103 del environments[venvName] 106 del environments[venvName]
119 "variant": 3, 122 "variant": 3,
120 "is_global": True, 123 "is_global": True,
121 "is_conda": False, 124 "is_conda": False,
122 "is_remote": False, 125 "is_remote": False,
123 "exec_path": "", 126 "exec_path": "",
127 "description": "",
124 } 128 }
125 129
126 self.__saveSettings() 130 self.__saveSettings()
127 131
128 def __saveSettings(self): 132 def __saveSettings(self):
258 venvInterpreter="", 262 venvInterpreter="",
259 isGlobal=False, 263 isGlobal=False,
260 isConda=False, 264 isConda=False,
261 isRemote=False, 265 isRemote=False,
262 execPath="", 266 execPath="",
267 description="",
263 ): 268 ):
264 """ 269 """
265 Public method to add a virtual environment. 270 Public method to add a virtual environment.
266 271
267 @param venvName logical name for the virtual environment 272 @param venvName logical name for the virtual environment
276 @type bool 281 @type bool
277 @param isRemote flag indicating a remotely accessed environment 282 @param isRemote flag indicating a remotely accessed environment
278 @type bool 283 @type bool
279 @param execPath search path string to be prepended to the PATH 284 @param execPath search path string to be prepended to the PATH
280 environment variable 285 environment variable
286 @type str
287 @param description descriptive text for the environment
281 @type str 288 @type str
282 """ 289 """
283 if venvName in self.__virtualEnvironments: 290 if venvName in self.__virtualEnvironments:
284 ok = EricMessageBox.yesNo( 291 ok = EricMessageBox.yesNo(
285 None, 292 None,
317 "variant": 3, # always 3 324 "variant": 3, # always 3
318 "is_global": isGlobal, 325 "is_global": isGlobal,
319 "is_conda": isConda, 326 "is_conda": isConda,
320 "is_remote": isRemote, 327 "is_remote": isRemote,
321 "exec_path": execPath, 328 "exec_path": execPath,
329 "description": description,
322 } 330 }
323 331
324 self.__saveSettings() 332 self.__saveSettings()
325 333
326 self.virtualEnvironmentAdded.emit() 334 self.virtualEnvironmentAdded.emit()
333 venvInterpreter, 341 venvInterpreter,
334 isGlobal, 342 isGlobal,
335 isConda, 343 isConda,
336 isRemote, 344 isRemote,
337 execPath, 345 execPath,
346 description,
338 ): 347 ):
339 """ 348 """
340 Public method to change a virtual environment. 349 Public method to change a virtual environment.
341 350
342 @param venvName logical name of the virtual environment 351 @param venvName logical name of the virtual environment
351 @type bool 360 @type bool
352 @param isRemote flag indicating a remotely accessed environment 361 @param isRemote flag indicating a remotely accessed environment
353 @type bool 362 @type bool
354 @param execPath search path string to be prepended to the PATH 363 @param execPath search path string to be prepended to the PATH
355 environment variable 364 environment variable
365 @type str
366 @param description descriptive text for the environment
356 @type str 367 @type str
357 """ 368 """
358 if venvName not in self.__virtualEnvironments: 369 if venvName not in self.__virtualEnvironments:
359 EricMessageBox.yesNo( 370 EricMessageBox.yesNo(
360 None, 371 None,
373 "variant": 3, # always 3 384 "variant": 3, # always 3
374 "is_global": isGlobal, 385 "is_global": isGlobal,
375 "is_conda": isConda, 386 "is_conda": isConda,
376 "is_remote": isRemote, 387 "is_remote": isRemote,
377 "exec_path": execPath, 388 "exec_path": execPath,
389 "description": description,
378 } 390 }
379 391
380 self.__saveSettings() 392 self.__saveSettings()
381 393
382 self.virtualEnvironmentChanged.emit(venvName) 394 self.virtualEnvironmentChanged.emit(venvName)
390 venvInterpreter, 402 venvInterpreter,
391 isGlobal, 403 isGlobal,
392 isConda, 404 isConda,
393 isRemote, 405 isRemote,
394 execPath, 406 execPath,
407 description,
395 ): 408 ):
396 """ 409 """
397 Public method to substitute a virtual environment entry with a new 410 Public method to substitute a virtual environment entry with a new
398 name. 411 name.
399 412
411 @type bool 424 @type bool
412 @param isRemote flag indicating a remotely accessed environment 425 @param isRemote flag indicating a remotely accessed environment
413 @type bool 426 @type bool
414 @param execPath search path string to be prepended to the PATH 427 @param execPath search path string to be prepended to the PATH
415 environment variable 428 environment variable
429 @type str
430 @param description descriptive text for the environment
416 @type str 431 @type str
417 """ 432 """
418 if oldVenvName not in self.__virtualEnvironments: 433 if oldVenvName not in self.__virtualEnvironments:
419 EricMessageBox.yesNo( 434 EricMessageBox.yesNo(
420 None, 435 None,
429 444
430 del self.__virtualEnvironments[oldVenvName] 445 del self.__virtualEnvironments[oldVenvName]
431 self.addVirtualEnv( 446 self.addVirtualEnv(
432 venvName, 447 venvName,
433 venvDirectory, 448 venvDirectory,
434 venvInterpreter, 449 venvInterpreter=venvInterpreter,
435 isGlobal, 450 isGlobal=isGlobal,
436 isConda, 451 isConda=isConda,
437 isRemote, 452 isRemote=isRemote,
438 execPath, 453 execPath=execPath,
454 description=description,
439 ) 455 )
440 456
441 def deleteVirtualEnvs(self, venvNames): 457 def deleteVirtualEnvs(self, venvNames):
442 """ 458 """
443 Public method to delete virtual environments from the list and disk. 459 Public method to delete virtual environments from the list and disk.

eric ide

mercurial