eric6/VirtualEnv/VirtualenvManager.py

Sat, 11 Apr 2020 14:13:25 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 11 Apr 2020 14:13:25 +0200
changeset 7522
e0e05a1b576f
parent 7360
9190402e4505
child 7628
f904d0eef264
permissions
-rw-r--r--

Styles: added some Qt style sheets and some highlighter styles.

6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7259
diff changeset
3 # Copyright (c) 2018 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a class to manage Python virtual environments.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import sys
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import shutil
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
14 import json
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
15 import copy
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
17 from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from PyQt5.QtWidgets import QDialog
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from E5Gui import E5MessageBox
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
21 from E5Gui.E5Application import e5App
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import Preferences
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class VirtualenvManager(QObject):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Class implementing an object to manage Python virtual environments.
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
29
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
30 @signal virtualEnvironmentAdded() emitted to indicate the addition of
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
31 a virtual environment
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
32 @signal virtualEnvironmentRemoved() emitted to indicate the removal and
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
33 deletion of a virtual environment
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
34 @signal virtualEnvironmentChanged(name) emitted to indicate a change of
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
35 a virtual environment
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
6503
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
37 DefaultKey = "<default>"
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
38
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
39 virtualEnvironmentAdded = pyqtSignal()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
40 virtualEnvironmentRemoved = pyqtSignal()
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
41 virtualEnvironmentChanged = pyqtSignal(str)
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
42
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 def __init__(self, parent=None):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 Constructor
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @param parent reference to the parent object
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @type QWidget
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 super(VirtualenvManager, self).__init__(parent)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.__ui = parent
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
54 self.__loadSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
55
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
56 self.__virtualenvManagerDialog = None
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
58 def __loadSettings(self):
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
59 """
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
60 Private slot to load the virtual environments.
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
61 """
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
62 venvString = Preferences.Prefs.settings.value(
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
63 "PyVenv/VirtualEnvironments", "{}") # __IGNORE_WARNING_M613__
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
64 environments = json.loads(venvString)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
65
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
66 self.__virtualEnvironments = {}
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
67 # each environment entry is a dictionary:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
68 # path: the directory of the virtual environment
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
69 # (empty for a global environment)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
70 # interpreter: the path of the Python interpreter
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
71 # variant: Python variant (2 or 3)
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
72 # is_global: a flag indicating a global environment
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
73 # is_conda: a flag indicating an Anaconda environment
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
74 # is_remote: a flag indicating a remotely accessed environment
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
75 # exec_path: a string to be prefixed to the PATH environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
76 # setting
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
77 #
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
78 for venvName in environments:
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
79 environment = environments[venvName]
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
80 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
81 ("is_remote" in environment and environment["is_remote"]) or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
82 os.access(environment["interpreter"], os.X_OK)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
83 ):
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
84 if "is_global" not in environment:
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
85 environment["is_global"] = environment["path"] == ""
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
86 if "is_conda" not in environment:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
87 environment["is_conda"] = False
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
88 if "is_remote" not in environment:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
89 environment["is_remote"] = False
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
90 if "exec_path" not in environment:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
91 environment["exec_path"] = ""
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
92 self.__virtualEnvironments[venvName] = environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
93
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
94 # check, if the interpreter used to run eric is in the environments
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
95 defaultPy = sys.executable.replace("w.exe", ".exe")
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
96 found = False
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
97 for venvName in self.__virtualEnvironments:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
98 if (defaultPy ==
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
99 self.__virtualEnvironments[venvName]["interpreter"]):
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
100 found = True
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
101 break
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
102 if not found:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
103 # add an environment entry for the default interpreter
6503
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
104 self.__virtualEnvironments[VirtualenvManager.DefaultKey] = {
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
105 "path": "",
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
106 "interpreter": defaultPy,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
107 "variant": sys.version_info[0],
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
108 "is_global": True,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
109 "is_conda": False,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
110 "is_remote": False,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
111 "exec_path": "",
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
112 }
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
113
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
114 self.__saveSettings()
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
115
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
116 def __saveSettings(self):
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 Private slot to save the virtual environments.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 Preferences.Prefs.settings.setValue(
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
121 "PyVenv/VirtualEnvironments",
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
122 json.dumps(self.__virtualEnvironments)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
123 )
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
124 Preferences.syncPreferences()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
6503
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
126 def getDefaultEnvironment(self):
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
127 """
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
128 Public method to get the default virtual environment.
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
129
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
130 Default is an environment with the key '<default>' or the first one
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
131 having an interpreter matching sys.executable (i.e. the one used to
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
132 execute eric6 with)
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
133
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
134 @return tuple containing the environment name and a dictionary
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
135 containing a copy of the default virtual environment
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
136 @rtype tuple of (str, dict)
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
137 """
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
138 if VirtualenvManager.DefaultKey in self.__virtualEnvironments:
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
139 return (
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
140 VirtualenvManager.DefaultKey,
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
141 copy.copy(
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
142 self.__virtualEnvironments[VirtualenvManager.DefaultKey])
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
143 )
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
144
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
145 else:
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
146 defaultPy = sys.executable.replace("w.exe", ".exe")
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
147 for venvName in self.__virtualEnvironments:
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
148 if (defaultPy ==
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
149 self.__virtualEnvironments[venvName]["interpreter"]):
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
150 return (
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
151 venvName,
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
152 copy.copy(self.__virtualEnvironments[venvName])
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
153 )
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
154
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
155 return ("", {})
e617c58807e8 VirtualenvManager, DebuggerPropertiesDialog, DebuggerInterfacePython: added code to use the default virtual environment, if none has been configured yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6386
diff changeset
156
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 @pyqtSlot()
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 def createVirtualEnv(self):
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 Public slot to create a new virtual environment.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
162 from .VirtualenvConfigurationDialog import (
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 VirtualenvConfigurationDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
164 )
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 dlg = VirtualenvConfigurationDialog()
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 if dlg.exec_() == QDialog.Accepted:
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
168 resultDict = dlg.getData()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
170 if resultDict["envType"] == "conda":
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
171 # create the conda environment
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
172 conda = e5App().getObject("Conda")
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
173 ok, prefix, interpreter = conda.createCondaEnvironment(
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
174 resultDict["arguments"])
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
175 if ok and "--dry-run" not in resultDict["arguments"]:
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
176 self.addVirtualEnv(resultDict["logicalName"],
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
177 prefix,
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
178 venvInterpreter=interpreter,
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
179 isConda=True)
6672
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
180 else:
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
181 # now do the call
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
182 from .VirtualenvExecDialog import VirtualenvExecDialog
2af01e538c57 Started implementing support conda virtual environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
183 dia = VirtualenvExecDialog(resultDict, self)
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
184 dia.show()
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
185 dia.start(resultDict["arguments"])
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
186 dia.exec_()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
188 def addVirtualEnv(self, venvName, venvDirectory, venvInterpreter="",
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
189 venvVariant=3, isGlobal=False, isConda=False,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
190 isRemote=False, execPath=""):
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 Public method to add a virtual environment.
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @param venvName logical name for the virtual environment
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
196 @param venvDirectory directory of the virtual environment
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
198 @param venvInterpreter interpreter of the virtual environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
199 @type str
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
200 @param venvVariant Python variant of the virtual environment
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
201 @type int
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
202 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
203 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
204 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
205 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
206 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
207 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
208 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
209 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
210 @type str
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 if venvName in self.__virtualEnvironments:
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 ok = E5MessageBox.yesNo(
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 None,
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.tr("Add Virtual Environment"),
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.tr("""A virtual environment named <b>{0}</b> exists"""
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """ already. Shall it be replaced?""")
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 .format(venvName),
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 icon=E5MessageBox.Warning)
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 if not ok:
6677
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
221 from .VirtualenvNameDialog import VirtualenvNameDialog
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
222 dlg = VirtualenvNameDialog(
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
223 list(self.__virtualEnvironments.keys()),
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
224 venvName)
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
225 if dlg.exec_() != QDialog.Accepted:
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
226 return
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
227
6299d69a218a Continued implementing environment creation with conda.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6676
diff changeset
228 venvName = dlg.getName()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
230 if not venvInterpreter:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
231 from .VirtualenvInterpreterSelectionDialog import (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
232 VirtualenvInterpreterSelectionDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
233 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
234 dlg = VirtualenvInterpreterSelectionDialog(venvName, venvDirectory)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
235 if dlg.exec_() == QDialog.Accepted:
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
236 venvInterpreter, venvVariant = dlg.getData()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
237
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
238 if venvInterpreter:
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
239 self.__virtualEnvironments[venvName] = {
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
240 "path": venvDirectory,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
241 "interpreter": venvInterpreter,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
242 "variant": venvVariant,
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
243 "is_global": isGlobal,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
244 "is_conda": isConda,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
245 "is_remote": isRemote,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
246 "exec_path": execPath,
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
247 }
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
249 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
250
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
251 self.virtualEnvironmentAdded.emit()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
252 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
253 self.__virtualenvManagerDialog.refresh()
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
255 def setVirtualEnv(self, venvName, venvDirectory, venvInterpreter,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
256 venvVariant, isGlobal, isConda, isRemote,
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
257 execPath):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
258 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
259 Public method to change a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
260
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
261 @param venvName logical name of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
262 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
263 @param venvDirectory directory of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
264 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
265 @param venvInterpreter interpreter of the virtual environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
266 @type str
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
267 @param venvVariant Python variant of the virtual environment
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
268 @type int
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
269 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
270 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
271 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
272 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
273 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
274 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
275 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
276 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
277 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
278 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
279 if venvName not in self.__virtualEnvironments:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
280 E5MessageBox.yesNo(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
281 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
282 self.tr("Change Virtual Environment"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
283 self.tr("""A virtual environment named <b>{0}</b> does not"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
284 """ exist. Aborting!""")
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
285 .format(venvName),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
286 icon=E5MessageBox.Warning)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
287 return
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
288
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
289 self.__virtualEnvironments[venvName] = {
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
290 "path": venvDirectory,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
291 "interpreter": venvInterpreter,
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
292 "variant": venvVariant,
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
293 "is_global": isGlobal,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
294 "is_conda": isConda,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
295 "is_remote": isRemote,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
296 "exec_path": execPath,
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
297 }
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
298
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
299 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
300
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
301 self.virtualEnvironmentChanged.emit(venvName)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
302 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
303 self.__virtualenvManagerDialog.refresh()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
304
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
305 def renameVirtualEnv(self, oldVenvName, venvName, venvDirectory,
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
306 venvInterpreter, venvVariant, isGlobal, isConda,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
307 isRemote, execPath):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
308 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
309 Public method to substitute a virtual environment entry with a new
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
310 name.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
311
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
312 @param oldVenvName old name of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
313 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
314 @param venvName logical name for the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
315 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
316 @param venvDirectory directory of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
317 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
318 @param venvInterpreter interpreter of the virtual environment
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
319 @type str
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
320 @param venvVariant Python variant of the virtual environment
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
321 @type int
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
322 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
323 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
324 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
325 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
326 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
327 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
328 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
329 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
330 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
331 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
332 if oldVenvName not in self.__virtualEnvironments:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
333 E5MessageBox.yesNo(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
334 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
335 self.tr("Rename Virtual Environment"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
336 self.tr("""A virtual environment named <b>{0}</b> does not"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
337 """ exist. Aborting!""")
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
338 .format(oldVenvName),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
339 icon=E5MessageBox.Warning)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
340 return
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
341
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
342 del self.__virtualEnvironments[oldVenvName]
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
343 self.addVirtualEnv(venvName, venvDirectory, venvInterpreter,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
344 venvVariant, isGlobal, isConda, isRemote,
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
345 execPath)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
346
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
347 def deleteVirtualEnvs(self, venvNames):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
348 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
349 Public method to delete virtual environments from the list and disk.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
350
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
351 @param venvNames list of logical names for the virtual environments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
352 @type list of str
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 """
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
354 venvMessages = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
355 for venvName in venvNames:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
356 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
357 venvName in self.__virtualEnvironments and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
358 bool(self.__virtualEnvironments[venvName]["path"])
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
359 ):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
360 venvMessages.append(self.tr("{0} - {1}").format(
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
361 venvName, self.__virtualEnvironments[venvName]["path"]))
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
362 if venvMessages:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
363 from UI.DeleteFilesConfirmationDialog import (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
364 DeleteFilesConfirmationDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
365 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
366 dlg = DeleteFilesConfirmationDialog(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
367 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
368 self.tr("Delete Virtual Environments"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
369 self.tr("""Do you really want to delete these virtual"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
370 """ environments?"""),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
371 venvMessages
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
372 )
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
373 if dlg.exec_() == QDialog.Accepted:
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
374 for venvName in venvNames:
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
375 if self.__isEnvironmentDeleteable(venvName):
6697
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
376 if self.isCondaEnvironment(venvName):
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
377 conda = e5App().getObject("Conda")
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
378 path = self.__virtualEnvironments[venvName]["path"]
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
379 res = conda.removeCondaEnvironment(prefix=path)
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
380 if res:
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
381 del self.__virtualEnvironments[venvName]
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
382 else:
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
383 shutil.rmtree(
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
384 self.__virtualEnvironments[venvName]["path"],
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
385 True)
2f5c951bdf14 Conda interface: added capability to remove conda environments the conda way.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6696
diff changeset
386 del self.__virtualEnvironments[venvName]
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
387
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
388 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
389
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
390 self.virtualEnvironmentRemoved.emit()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
391 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
392 self.__virtualenvManagerDialog.refresh()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
393
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
394 def __isEnvironmentDeleteable(self, venvName):
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
395 """
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
396 Private method to check, if a virtual environment can be deleted from
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
397 disk.
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
398
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
399 @param venvName name of the virtual environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
400 @type str
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
401 @return flag indicating it can be deleted
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
402 @rtype bool
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
403 """
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
404 ok = False
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
405 if venvName in self.__virtualEnvironments:
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
406 ok = True
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
407 ok &= bool(self.__virtualEnvironments[venvName]["path"])
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
408 ok &= not self.__virtualEnvironments[venvName]["is_global"]
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
409 ok &= not self.__virtualEnvironments[venvName]["is_remote"]
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
410 ok &= os.access(self.__virtualEnvironments[venvName]["path"],
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
411 os.W_OK)
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
412
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
413 return ok
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
414
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
415 def removeVirtualEnvs(self, venvNames):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
416 """
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
417 Public method to delete virtual environment from the list.
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
418
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
419 @param venvNames list of logical names for the virtual environments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
420 @type list of str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
421 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
422 venvMessages = []
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
423 for venvName in venvNames:
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
424 if venvName in self.__virtualEnvironments:
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
425 venvMessages.append(self.tr("{0} - {1}").format(
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
426 venvName, self.__virtualEnvironments[venvName]["path"]))
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
427 if venvMessages:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
428 from UI.DeleteFilesConfirmationDialog import (
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
429 DeleteFilesConfirmationDialog
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
430 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
431 dlg = DeleteFilesConfirmationDialog(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
432 None,
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
433 self.tr("Remove Virtual Environments"),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
434 self.tr("""Do you really want to remove these virtual"""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
435 """ environments?"""),
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
436 venvMessages
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
437 )
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
438 if dlg.exec_() == QDialog.Accepted:
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
439 for venvName in venvNames:
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
440 if venvName in self.__virtualEnvironments:
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
441 del self.__virtualEnvironments[venvName]
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
442
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
443 self.__saveSettings()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
444
6792
9dd854f05c83 PipInterface: continued with the pip interface widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6740
diff changeset
445 self.virtualEnvironmentRemoved.emit()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
446 if self.__virtualenvManagerDialog:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
447 self.__virtualenvManagerDialog.refresh()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
448
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
449 def getEnvironmentEntries(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
450 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
451 Public method to get a dictionary containing the defined virtual
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
452 environment entries.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
453
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
454 @return dictionary containing a copy of the defined virtual
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
455 environments
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
456 @rtype dict
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
457 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
458 return copy.deepcopy(self.__virtualEnvironments)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
459
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
460 @pyqtSlot()
6381
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
461 def showVirtualenvManagerDialog(self, modal=False):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
462 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
463 Public slot to show the virtual environment manager dialog.
6381
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
464
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
465 @param modal flag indicating that the dialog should be shown in
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
466 a blocking mode
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
467 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
468 if self.__virtualenvManagerDialog is None:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
469 from .VirtualenvManagerDialog import VirtualenvManagerDialog
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
470 self.__virtualenvManagerDialog = VirtualenvManagerDialog(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
471 self, self.__ui)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
472
6381
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
473 if modal:
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
474 self.__virtualenvManagerDialog.exec_()
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
475 else:
37f23590dbbc Configuration pages for Python: harmonized the Python debugger pages and the Python page and added a button to show the virtual environment manager dialog to the Python configuration pages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
476 self.__virtualenvManagerDialog.show()
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
477
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
478 def shutdown(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
479 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
480 Public method to shutdown the manager.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
481 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
482 if self.__virtualenvManagerDialog is not None:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
483 self.__virtualenvManagerDialog.close()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
484 self.__virtualenvManagerDialog = None
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
485
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
486 def isUnique(self, venvName):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
487 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
488 Public method to check, if the give logical name is unique.
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 @param venvName logical name for the virtual environment
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
492 @return flag indicating uniqueness
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
493 @rtype bool
6337
c6af560e0039 VirtualEnv: started implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 """
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
495 return venvName not in self.__virtualEnvironments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
496
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
497 def getVirtualenvInterpreter(self, venvName):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
498 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
499 Public method to get the interpreter for a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
500
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
501 @param venvName logical name for the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
502 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
503 @return interpreter path
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
504 @rtype str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
505 """
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
506 if venvName in self.__virtualEnvironments:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
507 return self.__virtualEnvironments[venvName]["interpreter"]
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
508 else:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
509 return ""
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
510
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
511 def getVirtualenvDirectory(self, venvName):
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
512 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
513 Public method to get the directory of a virtual environment.
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
514
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
515 @param venvName logical name for the virtual environment
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
516 @type str
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
517 @return directory path
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
518 @rtype str
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
519 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
520 if venvName in self.__virtualEnvironments:
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
521 return self.__virtualEnvironments[venvName]["path"]
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
522 else:
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
523 return ""
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
524
6975
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
525 def getVirtualenvNames(self, noRemote=False):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
526 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
527 Public method to get a list of defined virtual environments.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
528
6975
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
529 @param noRemote flag indicating to exclude environments for remote
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
530 debugging
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
531 @type bool
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
532 @return list of defined virtual environments
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
533 @rtype list of str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6337
diff changeset
534 """
6975
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
535 environments = list(self.__virtualEnvironments.keys())
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
536 if noRemote:
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
537 environments = [name for name in environments
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
538 if not self.isRemoteEnvironment(name)]
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
539
3325bf3e7b2c Pip, PipPackagesWidget, VirtualenvManager: fixed an issue causing environments for remote debugging being shown in the selection list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
540 return environments
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
541
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
542 def getVirtualenvNamesForVariant(self, variant):
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
543 """
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
544 Public method to get a list of virtual environments for a given
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
545 Python variant.
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
546
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
547 @param variant Python variant (2 or 3)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
548 @type int
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
549 @return list of defined virtual environments
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
550 @rtype list of str
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
551 """
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
552 assert variant in (2, 3)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
553
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
554 environments = []
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
555 for venvName in self.__virtualEnvironments:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
556 if self.__virtualEnvironments[venvName]["variant"] == variant:
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
557 environments.append(venvName)
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
558
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
559 return environments
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
560
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
561 def getVirtualenvVariant(self, venvName):
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
562 """
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
563 Public method to get the variant of a virtual environment.
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
564
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
565 @param venvName logical name for the virtual environment
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
566 @type str
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
567 @return Python variant of the environment
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
568 @rtype str
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
569 """
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
570 if venvName in self.__virtualEnvironments:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
571 return "Python{0}".format(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
572 self.__virtualEnvironments[venvName]["variant"])
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
573 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
574 return ""
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6792
diff changeset
575
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
576 def isGlobalEnvironment(self, venvName):
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
577 """
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
578 Public method to test, if a given environment is a global one.
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
579
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
580 @param venvName logical name of the virtual environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
581 @type str
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
582 @return flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
583 @rtype bool
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
584 """
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
585 if venvName in self.__virtualEnvironments:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
586 return self.__virtualEnvironments[venvName]["is_global"]
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
587 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
588 return False
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
589
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
590 def isCondaEnvironment(self, venvName):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
591 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
592 Public method to test, if a given environment is an Anaconda
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
593 environment.
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
594
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
595 @param venvName logical name of the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
596 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
597 @return flag indicating an Anaconda environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
598 @rtype bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
599 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
600 if venvName in self.__virtualEnvironments:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
601 return self.__virtualEnvironments[venvName]["is_conda"]
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
602 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
603 return False
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
604
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
605 def isRemoteEnvironment(self, venvName):
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
606 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
607 Public method to test, if a given environment is a remotely accessed
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
608 environment.
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
609
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
610 @param venvName logical name of the virtual environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
611 @type str
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
612 @return flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
613 @rtype bool
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
614 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
615 if venvName in self.__virtualEnvironments:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
616 return self.__virtualEnvironments[venvName]["is_remote"]
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
617 else:
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
618 return False
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6673
diff changeset
619
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
620 def getVirtualenvExecPath(self, venvName):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
621 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
622 Public method to get the search path prefix of a virtual environment.
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
623
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
624 @param venvName logical name for the virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
625 @type str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
626 @return search path prefix
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
627 @rtype str
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
628 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
629 if venvName in self.__virtualEnvironments:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
630 return self.__virtualEnvironments[venvName]["exec_path"]
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
631 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6503
diff changeset
632 return ""

eric ide

mercurial