12 import sys |
12 import sys |
13 import json |
13 import json |
14 |
14 |
15 from PyQt5.QtCore import pyqtSlot, QObject, QProcess, QUrl, QCoreApplication |
15 from PyQt5.QtCore import pyqtSlot, QObject, QProcess, QUrl, QCoreApplication |
16 from PyQt5.QtWidgets import QDialog |
16 from PyQt5.QtWidgets import QDialog |
17 from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest, \ |
17 from PyQt5.QtNetwork import ( |
18 QNetworkReply |
18 QNetworkAccessManager, QNetworkRequest, QNetworkReply |
|
19 ) |
19 |
20 |
20 from E5Gui import E5MessageBox |
21 from E5Gui import E5MessageBox |
21 from E5Gui.E5Application import e5App |
22 from E5Gui.E5Application import e5App |
22 |
23 |
23 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired |
24 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired |
182 @type str |
183 @type str |
183 @return interpreter path |
184 @return interpreter path |
184 @rtype str |
185 @rtype str |
185 """ |
186 """ |
186 if venvName == self.getProjectEnvironmentString(): |
187 if venvName == self.getProjectEnvironmentString(): |
187 venvName = \ |
188 venvName = ( |
188 e5App().getObject("Project").getDebugProperty("VIRTUALENV") |
189 e5App().getObject("Project") |
|
190 .getDebugProperty("VIRTUALENV") |
|
191 ) |
189 if not venvName: |
192 if not venvName: |
190 # fall back to interpreter used to run eric6 |
193 # fall back to interpreter used to run eric6 |
191 return sys.executable |
194 return sys.executable |
192 |
195 |
193 interpreter = \ |
196 interpreter = ( |
194 e5App().getObject("VirtualEnvManager").getVirtualenvInterpreter( |
197 e5App().getObject("VirtualEnvManager") |
195 venvName) |
198 .getVirtualenvInterpreter(venvName) |
|
199 ) |
196 if not interpreter: |
200 if not interpreter: |
197 E5MessageBox.critical( |
201 E5MessageBox.critical( |
198 None, |
202 None, |
199 self.tr("Interpreter for Virtual Environment"), |
203 self.tr("Interpreter for Virtual Environment"), |
200 self.tr("""No interpreter configured for the selected""" |
204 self.tr("""No interpreter configured for the selected""" |
391 interpreter = self.getVirtualenvInterpreter(venvName) |
395 interpreter = self.getVirtualenvInterpreter(venvName) |
392 if not interpreter: |
396 if not interpreter: |
393 return |
397 return |
394 |
398 |
395 if Preferences.getPip("PipSearchIndex"): |
399 if Preferences.getPip("PipSearchIndex"): |
396 indexUrl = Preferences.getPip("PipSearchIndex") + \ |
400 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple" |
397 "/simple" |
|
398 args = ["-m", "pip", "install", "--index-url", indexUrl] |
401 args = ["-m", "pip", "install", "--index-url", indexUrl] |
399 else: |
402 else: |
400 args = ["-m", "pip", "install"] |
403 args = ["-m", "pip", "install"] |
401 if user: |
404 if user: |
402 args.append("--user") |
405 args.append("--user") |
417 @return flag indicating a successful execution |
420 @return flag indicating a successful execution |
418 @rtype bool |
421 @rtype bool |
419 """ |
422 """ |
420 res = False |
423 res = False |
421 if packages and venvName: |
424 if packages and venvName: |
422 from UI.DeleteFilesConfirmationDialog import \ |
425 from UI.DeleteFilesConfirmationDialog import ( |
423 DeleteFilesConfirmationDialog |
426 DeleteFilesConfirmationDialog |
|
427 ) |
424 dlg = DeleteFilesConfirmationDialog( |
428 dlg = DeleteFilesConfirmationDialog( |
425 self.parent(), |
429 self.parent(), |
426 self.tr("Uninstall Packages"), |
430 self.tr("Uninstall Packages"), |
427 self.tr( |
431 self.tr( |
428 "Do you really want to uninstall these packages?"), |
432 "Do you really want to uninstall these packages?"), |
457 reqs = f.read().splitlines() |
461 reqs = f.read().splitlines() |
458 f.close() |
462 f.close() |
459 except (OSError, IOError): |
463 except (OSError, IOError): |
460 return |
464 return |
461 |
465 |
462 from UI.DeleteFilesConfirmationDialog import \ |
466 from UI.DeleteFilesConfirmationDialog import ( |
463 DeleteFilesConfirmationDialog |
467 DeleteFilesConfirmationDialog |
|
468 ) |
464 dlg = DeleteFilesConfirmationDialog( |
469 dlg = DeleteFilesConfirmationDialog( |
465 self.parent(), |
470 self.parent(), |
466 self.tr("Uninstall Packages"), |
471 self.tr("Uninstall Packages"), |
467 self.tr( |
472 self.tr( |
468 "Do you really want to uninstall these packages?"), |
473 "Do you really want to uninstall these packages?"), |