16 from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit |
16 from PyQt6.QtWidgets import QDialog, QInputDialog, QLineEdit |
17 from PyQt6.QtNetwork import ( |
17 from PyQt6.QtNetwork import ( |
18 QNetworkAccessManager, QNetworkRequest, QNetworkReply |
18 QNetworkAccessManager, QNetworkRequest, QNetworkReply |
19 ) |
19 ) |
20 |
20 |
21 from E5Gui import E5MessageBox |
21 from E5Gui import EricMessageBox |
22 from E5Gui.E5Application import e5App |
22 from E5Gui.EricApplication import ericApp |
23 |
23 |
24 from EricNetwork.EricNetworkProxyFactory import proxyAuthenticationRequired |
24 from EricNetwork.EricNetworkProxyFactory import proxyAuthenticationRequired |
25 try: |
25 try: |
26 from EricNetwork.EricSslErrorHandler import EricSslErrorHandler |
26 from EricNetwork.EricSslErrorHandler import EricSslErrorHandler |
27 SSL_AVAILABLE = True |
27 SSL_AVAILABLE = True |
153 # Unix, OS X: $VIRTUAL_ENV/pip.conf |
153 # Unix, OS X: $VIRTUAL_ENV/pip.conf |
154 # Windows: %VIRTUAL_ENV%\pip.ini |
154 # Windows: %VIRTUAL_ENV%\pip.ini |
155 |
155 |
156 pip = "pip.ini" if Globals.isWindowsPlatform() else "pip.conf" |
156 pip = "pip.ini" if Globals.isWindowsPlatform() else "pip.conf" |
157 |
157 |
158 venvManager = e5App().getObject("VirtualEnvManager") |
158 venvManager = ericApp().getObject("VirtualEnvManager") |
159 venvDirectory = ( |
159 venvDirectory = ( |
160 os.path.dirname(self.getUserConfig()) |
160 os.path.dirname(self.getUserConfig()) |
161 if venvManager.isGlobalEnvironment(venvName) else |
161 if venvManager.isGlobalEnvironment(venvName) else |
162 venvManager.getVirtualenvDirectory(venvName) |
162 venvManager.getVirtualenvDirectory(venvName) |
163 ) |
163 ) |
171 Public method to get the string for the project environment. |
171 Public method to get the string for the project environment. |
172 |
172 |
173 @return string for the project environment |
173 @return string for the project environment |
174 @rtype str |
174 @rtype str |
175 """ |
175 """ |
176 if e5App().getObject("Project").isOpen(): |
176 if ericApp().getObject("Project").isOpen(): |
177 return self.tr("<project>") |
177 return self.tr("<project>") |
178 else: |
178 else: |
179 return "" |
179 return "" |
180 |
180 |
181 def getVirtualenvInterpreter(self, venvName): |
181 def getVirtualenvInterpreter(self, venvName): |
187 @return interpreter path |
187 @return interpreter path |
188 @rtype str |
188 @rtype str |
189 """ |
189 """ |
190 if venvName == self.getProjectEnvironmentString(): |
190 if venvName == self.getProjectEnvironmentString(): |
191 venvName = ( |
191 venvName = ( |
192 e5App().getObject("Project") |
192 ericApp().getObject("Project") |
193 .getDebugProperty("VIRTUALENV") |
193 .getDebugProperty("VIRTUALENV") |
194 ) |
194 ) |
195 if not venvName: |
195 if not venvName: |
196 # fall back to interpreter used to run eric7 |
196 # fall back to interpreter used to run eric7 |
197 return sys.executable |
197 return sys.executable |
198 |
198 |
199 interpreter = ( |
199 interpreter = ( |
200 e5App().getObject("VirtualEnvManager") |
200 ericApp().getObject("VirtualEnvManager") |
201 .getVirtualenvInterpreter(venvName) |
201 .getVirtualenvInterpreter(venvName) |
202 ) |
202 ) |
203 if not interpreter: |
203 if not interpreter: |
204 E5MessageBox.critical( |
204 EricMessageBox.critical( |
205 None, |
205 None, |
206 self.tr("Interpreter for Virtual Environment"), |
206 self.tr("Interpreter for Virtual Environment"), |
207 self.tr("""No interpreter configured for the selected""" |
207 self.tr("""No interpreter configured for the selected""" |
208 """ virtual environment.""")) |
208 """ virtual environment.""")) |
209 |
209 |
220 @type bool |
220 @type bool |
221 @return sorted list of virtual environment names |
221 @return sorted list of virtual environment names |
222 @rtype list of str |
222 @rtype list of str |
223 """ |
223 """ |
224 return sorted( |
224 return sorted( |
225 e5App().getObject("VirtualEnvManager").getVirtualenvNames( |
225 ericApp().getObject("VirtualEnvManager").getVirtualenvNames( |
226 noRemote=noRemote, noConda=noConda)) |
226 noRemote=noRemote, noConda=noConda)) |
227 |
227 |
228 def installPip(self, venvName, userSite=False): |
228 def installPip(self, venvName, userSite=False): |
229 """ |
229 """ |
230 Public method to install pip. |
230 Public method to install pip. |
298 pyqtPackages = [p for p in packages |
298 pyqtPackages = [p for p in packages |
299 if p.lower() in ["pyqt5", "pyqt5-sip", "pyqtwebengine", |
299 if p.lower() in ["pyqt5", "pyqt5-sip", "pyqtwebengine", |
300 "qscintilla", "sip"]] |
300 "qscintilla", "sip"]] |
301 |
301 |
302 abort = ( |
302 abort = ( |
303 not E5MessageBox.yesNo( |
303 not EricMessageBox.yesNo( |
304 None, |
304 None, |
305 self.tr("Upgrade Packages"), |
305 self.tr("Upgrade Packages"), |
306 self.tr( |
306 self.tr( |
307 """You are trying to upgrade PyQt packages. This might""" |
307 """You are trying to upgrade PyQt packages. This might""" |
308 """ not work for the current instance of Python ({0}).""" |
308 """ not work for the current instance of Python ({0}).""" |
309 """ Do you want to continue?""").format(sys.executable), |
309 """ Do you want to continue?""").format(sys.executable), |
310 icon=E5MessageBox.Critical) |
310 icon=EricMessageBox.Critical) |
311 if bool(pyqtPackages) else |
311 if bool(pyqtPackages) else |
312 False |
312 False |
313 ) |
313 ) |
314 |
314 |
315 return abort |
315 return abort |
771 @type str |
771 @type str |
772 """ |
772 """ |
773 if venvName: |
773 if venvName: |
774 interpreter = self.getVirtualenvInterpreter(venvName) |
774 interpreter = self.getVirtualenvInterpreter(venvName) |
775 if interpreter: |
775 if interpreter: |
776 ok = E5MessageBox.yesNo( |
776 ok = EricMessageBox.yesNo( |
777 None, |
777 None, |
778 self.tr("Purge Cache"), |
778 self.tr("Purge Cache"), |
779 self.tr("Do you really want to purge the pip cache? All" |
779 self.tr("Do you really want to purge the pip cache? All" |
780 " files need to be downloaded again.")) |
780 " files need to be downloaded again.")) |
781 if ok: |
781 if ok: |