56 |
56 |
57 def __loadSettings(self): |
57 def __loadSettings(self): |
58 """ |
58 """ |
59 Private slot to load the virtual environments. |
59 Private slot to load the virtual environments. |
60 """ |
60 """ |
|
61 self.__virtualEnvironmentsBaseDir = Preferences.Prefs.settings.value( |
|
62 "PyVenv/VirtualEnvironmentsBaseDir", "") |
|
63 |
61 venvString = Preferences.Prefs.settings.value( |
64 venvString = Preferences.Prefs.settings.value( |
62 "PyVenv/VirtualEnvironments", "{}") # __IGNORE_WARNING_M613__ |
65 "PyVenv/VirtualEnvironments", "{}") # __IGNORE_WARNING_M613__ |
63 environments = json.loads(venvString) |
66 environments = json.loads(venvString) |
64 |
67 |
65 self.__virtualEnvironments = {} |
68 self.__virtualEnvironments = {} |
125 def __saveSettings(self): |
128 def __saveSettings(self): |
126 """ |
129 """ |
127 Private slot to save the virtual environments. |
130 Private slot to save the virtual environments. |
128 """ |
131 """ |
129 Preferences.Prefs.settings.setValue( |
132 Preferences.Prefs.settings.setValue( |
|
133 "PyVenv/VirtualEnvironmentsBaseDir", |
|
134 self.__virtualEnvironmentsBaseDir) |
|
135 |
|
136 Preferences.Prefs.settings.setValue( |
130 "PyVenv/VirtualEnvironments", |
137 "PyVenv/VirtualEnvironments", |
131 json.dumps(self.__virtualEnvironments) |
138 json.dumps(self.__virtualEnvironments) |
132 ) |
139 ) |
133 Preferences.syncPreferences() |
140 Preferences.syncPreferences() |
134 |
141 |
136 """ |
143 """ |
137 Public method to get the default virtual environment. |
144 Public method to get the default virtual environment. |
138 |
145 |
139 Default is an environment with the key '<default>' or the first one |
146 Default is an environment with the key '<default>' or the first one |
140 having an interpreter matching sys.executable (i.e. the one used to |
147 having an interpreter matching sys.executable (i.e. the one used to |
141 execute eric6 with) |
148 execute eric with) |
142 |
149 |
143 @return tuple containing the environment name and a dictionary |
150 @return tuple containing the environment name and a dictionary |
144 containing a copy of the default virtual environment |
151 containing a copy of the default virtual environment |
145 @rtype tuple of (str, dict) |
152 @rtype tuple of (str, dict) |
146 """ |
153 """ |
162 ) |
169 ) |
163 |
170 |
164 return ("", {}) |
171 return ("", {}) |
165 |
172 |
166 @pyqtSlot() |
173 @pyqtSlot() |
167 def createVirtualEnv(self): |
174 def createVirtualEnv(self, baseDir=""): |
168 """ |
175 """ |
169 Public slot to create a new virtual environment. |
176 Public slot to create a new virtual environment. |
|
177 |
|
178 @param baseDir base directory for the virtual environments |
|
179 @type str |
170 """ |
180 """ |
171 from .VirtualenvConfigurationDialog import ( |
181 from .VirtualenvConfigurationDialog import ( |
172 VirtualenvConfigurationDialog |
182 VirtualenvConfigurationDialog |
173 ) |
183 ) |
174 |
184 |
175 dlg = VirtualenvConfigurationDialog() |
185 if not baseDir: |
|
186 baseDir = self.__virtualEnvironmentsBaseDir |
|
187 |
|
188 dlg = VirtualenvConfigurationDialog(baseDir=baseDir) |
176 if dlg.exec() == QDialog.Accepted: |
189 if dlg.exec() == QDialog.Accepted: |
177 resultDict = dlg.getData() |
190 resultDict = dlg.getData() |
178 |
191 |
179 if resultDict["envType"] == "conda": |
192 if resultDict["envType"] == "conda": |
180 # create the conda environment |
193 # create the conda environment |
600 """ |
613 """ |
601 if venvName in self.__virtualEnvironments: |
614 if venvName in self.__virtualEnvironments: |
602 return self.__virtualEnvironments[venvName]["exec_path"] |
615 return self.__virtualEnvironments[venvName]["exec_path"] |
603 else: |
616 else: |
604 return "" |
617 return "" |
|
618 |
|
619 def setVirtualEnvironmentsBaseDir(self, baseDir): |
|
620 """ |
|
621 Public method to set the base directory for the virtual environments. |
|
622 |
|
623 @param baseDir base directory for the virtual environments |
|
624 @type str |
|
625 """ |
|
626 self.__virtualEnvironmentsBaseDir = baseDir |
|
627 self.__saveSettings() |
|
628 |
|
629 def getVirtualEnvironmentsBaseDir(self): |
|
630 """ |
|
631 Public method to set the base directory for the virtual environments. |
|
632 |
|
633 @return base directory for the virtual environments |
|
634 @rtype str |
|
635 """ |
|
636 return self.__virtualEnvironmentsBaseDir |