PipInterface/Pip.py

branch
pypi
changeset 6785
058d63c537a4
parent 6782
390a45748883
child 6792
9dd854f05c83
equal deleted inserted replaced
6784:f5d29245dbb9 6785:058d63c537a4
26 from .PipDialog import PipDialog 26 from .PipDialog import PipDialog
27 from . import DefaultIndexUrlXml 27 from . import DefaultIndexUrlXml
28 28
29 import Preferences 29 import Preferences
30 import Globals 30 import Globals
31 31 ##
32 import UI.PixmapCache 32 ##import UI.PixmapCache
33 33
34 34
35 class Pip(QObject): 35 class Pip(QObject):
36 """ 36 """
37 Class implementing the pip GUI logic. 37 Class implementing the pip GUI logic.
38 """ 38 """
39 def __init__(self, plugin, parent=None): 39 def __init__(self, parent=None):
40 """ 40 """
41 Constructor 41 Constructor
42 42
43 @param plugin reference to the plugin object
44 @type PipInterfacePlugin
45 @param parent parent 43 @param parent parent
46 @type QObject 44 @type QObject
47 """ 45 """
48 super(Pip, self).__init__(parent) 46 super(Pip, self).__init__(parent)
49 47
50 self.__plugin = plugin
51 self.__ui = parent
52
53 self.__virtualenvManager = e5App().getObject("VirtualEnvManager") 48 self.__virtualenvManager = e5App().getObject("VirtualEnvManager")
54 self.__project = e5App().getObject("Project") 49 ## self.__project = e5App().getObject("Project")
55 50
56 self.__menus = {} # dictionary with references to menus 51 self.__menus = {} # dictionary with references to menus
57 52
58 self.__plugin.currentEnvironmentChanged.connect( 53 ## self.__plugin.currentEnvironmentChanged.connect(
59 self.__handleTearOffMenu) 54 ## self.__handleTearOffMenu)
60 55
61 def initActions(self): 56 def initActions(self):
62 """ 57 """
63 Public method to define the actions. 58 Public method to define the actions.
64 """ 59 """
77 """</p>""" 72 """</p>"""
78 )) 73 ))
79 self.selectEnvironmentAct.triggered.connect(self.__selectPipVirtualenv) 74 self.selectEnvironmentAct.triggered.connect(self.__selectPipVirtualenv)
80 self.actions.append(self.selectEnvironmentAct) 75 self.actions.append(self.selectEnvironmentAct)
81 76
82 ############################################## 77 ## ##############################################
83 ## Actions for listing packages 78 ## ## Actions for listing packages
84 ############################################## 79 ## ##############################################
85 80 ##
86 self.listPackagesAct = E5Action( 81 ## self.listPackagesAct = E5Action(
87 self.tr('List Installed Packages'), 82 ## self.tr('List Installed Packages'),
88 self.tr('&List Installed Packages...'), 83 ## self.tr('&List Installed Packages...'),
89 0, 0, 84 ## 0, 0,
90 self, 'pip_list_packages') 85 ## self, 'pip_list_packages')
91 self.listPackagesAct.setStatusTip(self.tr( 86 ## self.listPackagesAct.setStatusTip(self.tr(
92 'List all installed packages with versions')) 87 ## 'List all installed packages with versions'))
93 self.listPackagesAct.setWhatsThis(self.tr( 88 ## self.listPackagesAct.setWhatsThis(self.tr(
94 """<b>List Installed Packages</b>""" 89 ## """<b>List Installed Packages</b>"""
95 """<p>This lists all the installed packages together""" 90 ## """<p>This lists all the installed packages together"""
96 """ with their versions.</p>""" 91 ## """ with their versions.</p>"""
97 )) 92 ## ))
98 self.listPackagesAct.triggered.connect(self.__listPackages) 93 ## self.listPackagesAct.triggered.connect(self.__listPackages)
99 self.actions.append(self.listPackagesAct) 94 ## self.actions.append(self.listPackagesAct)
100 95 ##
101 self.listUptodatePackagesAct = E5Action( 96 ## self.listUptodatePackagesAct = E5Action(
102 self.tr('List Up-to-date Packages'), 97 ## self.tr('List Up-to-date Packages'),
103 self.tr('List Up-to-&date Packages...'), 98 ## self.tr('List Up-to-&date Packages...'),
104 0, 0, 99 ## 0, 0,
105 self, 'pip_list_uptodate_packages') 100 ## self, 'pip_list_uptodate_packages')
106 self.listUptodatePackagesAct.setStatusTip(self.tr( 101 ## self.listUptodatePackagesAct.setStatusTip(self.tr(
107 'List all installed, up-to-date packages with versions')) 102 ## 'List all installed, up-to-date packages with versions'))
108 self.listUptodatePackagesAct.setWhatsThis(self.tr( 103 ## self.listUptodatePackagesAct.setWhatsThis(self.tr(
109 """<b>List Up-to-date Packages</b>""" 104 ## """<b>List Up-to-date Packages</b>"""
110 """<p>This lists all the installed, up-to-date packages together""" 105 ## """<p>This lists all the installed, up-to-date packages together"""
111 """ with their versions.</p>""" 106 ## """ with their versions.</p>"""
112 )) 107 ## ))
113 self.listUptodatePackagesAct.triggered.connect( 108 ## self.listUptodatePackagesAct.triggered.connect(
114 self.__listUptodatePackages) 109 ## self.__listUptodatePackages)
115 self.actions.append(self.listUptodatePackagesAct) 110 ## self.actions.append(self.listUptodatePackagesAct)
116 111 ##
117 self.listOutdatedPackagesAct = E5Action( 112 ## self.listOutdatedPackagesAct = E5Action(
118 self.tr('List Outdated Packages'), 113 ## self.tr('List Outdated Packages'),
119 self.tr('List &Outdated Packages...'), 114 ## self.tr('List &Outdated Packages...'),
120 0, 0, 115 ## 0, 0,
121 self, 'pip_list_outdated_packages') 116 ## self, 'pip_list_outdated_packages')
122 self.listOutdatedPackagesAct.setStatusTip(self.tr( 117 ## self.listOutdatedPackagesAct.setStatusTip(self.tr(
123 'List all installed, outdated packages with versions')) 118 ## 'List all installed, outdated packages with versions'))
124 self.listOutdatedPackagesAct.setWhatsThis(self.tr( 119 ## self.listOutdatedPackagesAct.setWhatsThis(self.tr(
125 """<b>List Up-to-date Packages</b>""" 120 ## """<b>List Up-to-date Packages</b>"""
126 """<p>This lists all the installed, outdated packages together""" 121 ## """<p>This lists all the installed, outdated packages together"""
127 """ with their current and latest versions.</p>""" 122 ## """ with their current and latest versions.</p>"""
128 )) 123 ## ))
129 self.listOutdatedPackagesAct.triggered.connect( 124 ## self.listOutdatedPackagesAct.triggered.connect(
130 self.__listOutdatedPackages) 125 ## self.__listOutdatedPackages)
131 self.actions.append(self.listOutdatedPackagesAct) 126 ## self.actions.append(self.listOutdatedPackagesAct)
132 127 ##
133 ############################################## 128 ##############################################
134 ## Actions for installing packages 129 ## Actions for installing packages
135 ############################################## 130 ##############################################
136 131
137 self.installPackagesAct = E5Action( 132 self.installPackagesAct = E5Action(
365 @return the menu generated 360 @return the menu generated
366 @rtype QMenu 361 @rtype QMenu
367 """ 362 """
368 self.__menus = {} # clear menus references 363 self.__menus = {} # clear menus references
369 364
370 menu = QMenu(self.tr('P&ython Package Management'), self.__ui) 365 menu = QMenu()
371 menu.setTearOffEnabled(True) 366 ## menu.setTearOffEnabled(True)
372 menu.setIcon(UI.PixmapCache.getIcon("pypi.png")) 367 ## menu.setIcon(UI.PixmapCache.getIcon("pypi.png"))
373 368
374 menu.addAction(self.selectEnvironmentAct) 369 menu.addAction(self.selectEnvironmentAct)
375 menu.addSeparator() 370 menu.addSeparator()
376 menu.addAction(self.listPackagesAct) 371 ## menu.addAction(self.listPackagesAct)
377 menu.addAction(self.listUptodatePackagesAct) 372 ## menu.addAction(self.listUptodatePackagesAct)
378 menu.addAction(self.listOutdatedPackagesAct) 373 ## menu.addAction(self.listOutdatedPackagesAct)
379 menu.addSeparator() 374 ## menu.addSeparator()
380 menu.addAction(self.installPipAct) 375 menu.addAction(self.installPipAct)
381 menu.addSeparator() 376 menu.addSeparator()
382 menu.addAction(self.installPackagesAct) 377 menu.addAction(self.installPackagesAct)
383 menu.addAction(self.installLocalPackageAct) 378 menu.addAction(self.installLocalPackageAct)
384 menu.addAction(self.installRequirementsAct) 379 menu.addAction(self.installRequirementsAct)
385 menu.addSeparator() 380 menu.addSeparator()
386 menu.addAction(self.upgradePipAct) 381 menu.addAction(self.upgradePipAct)
387 menu.addAction(self.upgradePackagesAct) 382 ## menu.addAction(self.upgradePackagesAct)
388 menu.addSeparator() 383 menu.addSeparator()
389 menu.addAction(self.uninstallPackagesAct) 384 ## menu.addAction(self.uninstallPackagesAct)
390 menu.addAction(self.uninstallRequirementsAct) 385 menu.addAction(self.uninstallRequirementsAct)
391 menu.addSeparator() 386 menu.addSeparator()
392 menu.addAction(self.generateRequirementsAct) 387 menu.addAction(self.generateRequirementsAct)
393 menu.addSeparator() 388 menu.addSeparator()
394 menu.addAction(self.searchPyPIAct) 389 ## menu.addAction(self.searchPyPIAct)
395 menu.addSeparator() 390 ## menu.addSeparator()
396 menu.addAction(self.repairPipAct) 391 menu.addAction(self.repairPipAct)
397 menu.addSeparator() 392 menu.addSeparator()
398 menu.addAction(self.editUserConfigAct) 393 menu.addAction(self.editUserConfigAct)
399 menu.addAction(self.editVirtualenvConfigAct) 394 menu.addAction(self.editVirtualenvConfigAct)
400 menu.addSeparator() 395 menu.addSeparator()
408 403
409 def __aboutToShowMenu(self): 404 def __aboutToShowMenu(self):
410 """ 405 """
411 Private slot to set the action enabled status. 406 Private slot to set the action enabled status.
412 """ 407 """
413 enable = bool(self.__plugin.getPreferences("CurrentEnvironment")) 408 enable = bool(Preferences.getPip("CurrentEnvironment"))
414 for act in self.actions: 409 for act in self.actions:
415 if act not in [self.selectEnvironmentAct, 410 if act not in [self.selectEnvironmentAct,
416 self.installPipAct, 411 self.installPipAct,
417 self.editUserConfigAct, 412 self.editUserConfigAct,
418 self.editVirtualenvConfigAct, 413 self.editVirtualenvConfigAct,
544 else: 539 else:
545 pip = "pip.conf" 540 pip = "pip.conf"
546 try: 541 try:
547 venvDirectory = os.environ["VIRTUAL_ENV"] 542 venvDirectory = os.environ["VIRTUAL_ENV"]
548 except KeyError: 543 except KeyError:
549 venvName = self.__plugin.getPreferences("CurrentEnvironment") 544 venvName = Preferences.getPip("CurrentEnvironment")
550 if not venvName: 545 if not venvName:
551 self.__selectPipVirtualenv() 546 self.__selectPipVirtualenv()
552 venvName = self.__plugin.getPreferences("CurrentEnvironment") 547 venvName = Preferences.getPip("CurrentEnvironment")
553 if self.__virtualenvManager.isGlobalEnvironment(venvName): 548 if self.__virtualenvManager.isGlobalEnvironment(venvName):
554 venvDirectory = self.__getUserConfig() 549 venvDirectory = self.__getUserConfig()
555 else: 550 else:
556 venvDirectory = \ 551 venvDirectory = \
557 self.__virtualenvManager.getVirtualenvDirectory(venvName) 552 self.__virtualenvManager.getVirtualenvDirectory(venvName)
558 553
559 return os.path.join(venvDirectory, pip) 554 if venvDirectory:
555 config = os.path.join(venvDirectory, pip)
556 else:
557 config = ""
558
559 return config
560 560
561 def getDefaultEnvironmentString(self): 561 def getDefaultEnvironmentString(self):
562 """ 562 """
563 Public method to get the string for the default environment. 563 Public method to get the string for the default environment.
564 564
572 Public method to get the string for the project environment. 572 Public method to get the string for the project environment.
573 573
574 @return string for the project environment 574 @return string for the project environment
575 @rtype str 575 @rtype str
576 """ 576 """
577 if self.__project.isOpen(): 577 if e5App().getObject("Project").isOpen():
578 return self.tr("<project>") 578 return self.tr("<project>")
579 else: 579 else:
580 return "" 580 return ""
581 581
582 def getVirtualenvInterpreter(self, venvName): 582 def getVirtualenvInterpreter(self, venvName):
587 @type str 587 @type str
588 @return interpreter path 588 @return interpreter path
589 @rtype str 589 @rtype str
590 """ 590 """
591 if venvName == self.getDefaultEnvironmentString(): 591 if venvName == self.getDefaultEnvironmentString():
592 venvName = self.__plugin.getPreferences("CurrentEnvironment") 592 venvName = Preferences.getPip("CurrentEnvironment")
593 elif venvName == self.getProjectEnvironmentString(): 593 elif venvName == self.getProjectEnvironmentString():
594 venvName = self.__project.getDebugProperty("VIRTUALENV") 594 venvName = e5App().getObject("Project").getDebugProperty("VIRTUALENV")
595 if not venvName: 595 if not venvName:
596 # fall back to standard if not defined 596 # fall back to standard if not defined
597 venvName = self.__plugin.getPreferences("CurrentEnvironment") 597 venvName = Preferences.getPip("CurrentEnvironment")
598 598
599 interpreter = self.__virtualenvManager.getVirtualenvInterpreter( 599 interpreter = self.__virtualenvManager.getVirtualenvInterpreter(
600 venvName) 600 venvName)
601 if not interpreter: 601 if not interpreter:
602 E5MessageBox.critical( 602 E5MessageBox.critical(
624 """ 624 """
625 Private method to select the virtual environment to be used. 625 Private method to select the virtual environment to be used.
626 """ 626 """
627 environments = self.getVirtualenvNames() 627 environments = self.getVirtualenvNames()
628 if environments: 628 if environments:
629 currentEnvironment = self.__plugin.getPreferences( 629 currentEnvironment = Preferences.getPip("CurrentEnvironment")
630 "CurrentEnvironment")
631 try: 630 try:
632 index = environments.index(currentEnvironment) 631 index = environments.index(currentEnvironment)
633 except ValueError: 632 except ValueError:
634 index = 0 633 index = 0
635 environment, ok = QInputDialog.getItem( 634 environment, ok = QInputDialog.getItem(
637 self.tr("Virtual Environment for pip"), 636 self.tr("Virtual Environment for pip"),
638 self.tr("Select the virtual environment to be used:"), 637 self.tr("Select the virtual environment to be used:"),
639 environments, index, False) 638 environments, index, False)
640 639
641 if ok and environment: 640 if ok and environment:
642 self.__plugin.setPreferences("CurrentEnvironment", 641 Preferences.getPip("CurrentEnvironment", environment)
643 environment)
644 else: 642 else:
645 E5MessageBox.warning( 643 E5MessageBox.warning(
646 None, 644 None,
647 self.tr("Virtual Environment for pip"), 645 self.tr("Virtual Environment for pip"),
648 self.tr("""No virtual environments have been configured yet.""" 646 self.tr("""No virtual environments have been configured yet."""
649 """ Please use the Virtualenv Manager to do that.""")) 647 """ Please use the Virtualenv Manager to do that."""))
650 648
649 # TODO: move these three to the widget
651 def __listPackages(self): 650 def __listPackages(self):
652 """ 651 """
653 Private slot to list all installed packages. 652 Private slot to list all installed packages.
654 """ 653 """
655 from .PipListDialog import PipListDialog 654 from .PipListDialog import PipListDialog
656 self.__listDialog = PipListDialog( 655 self.__listDialog = PipListDialog(
657 self, "list", self.__plugin.getPreferences("PipSearchIndex"), 656 self, "list", Preferences.getPip("PipSearchIndex"),
658 self.tr("Installed Packages")) 657 self.tr("Installed Packages"))
659 self.__listDialog.show() 658 self.__listDialog.show()
660 self.__listDialog.start() 659 self.__listDialog.start()
661 660
662 def __listUptodatePackages(self): 661 def __listUptodatePackages(self):
663 """ 662 """
664 Private slot to list all installed, up-to-date packages. 663 Private slot to list all installed, up-to-date packages.
665 """ 664 """
666 from .PipListDialog import PipListDialog 665 from .PipListDialog import PipListDialog
667 self.__listUptodateDialog = PipListDialog( 666 self.__listUptodateDialog = PipListDialog(
668 self, "uptodate", self.__plugin.getPreferences("PipSearchIndex"), 667 self, "uptodate", Preferences.getPip("PipSearchIndex"),
669 self.tr("Up-to-date Packages")) 668 self.tr("Up-to-date Packages"))
670 self.__listUptodateDialog.show() 669 self.__listUptodateDialog.show()
671 self.__listUptodateDialog.start() 670 self.__listUptodateDialog.start()
672 671
673 def __listOutdatedPackages(self): 672 def __listOutdatedPackages(self):
674 """ 673 """
675 Private slot to list all installed, up-to-date packages. 674 Private slot to list all installed, up-to-date packages.
676 """ 675 """
677 from .PipListDialog import PipListDialog 676 from .PipListDialog import PipListDialog
678 self.__listOutdatedDialog = PipListDialog( 677 self.__listOutdatedDialog = PipListDialog(
679 self, "outdated", self.__plugin.getPreferences("PipSearchIndex"), 678 self, "outdated", Preferences.getPip("PipSearchIndex"),
680 self.tr("Outdated Packages")) 679 self.tr("Outdated Packages"))
681 self.__listOutdatedDialog.show() 680 self.__listOutdatedDialog.show()
682 self.__listOutdatedDialog.start() 681 self.__listOutdatedDialog.start()
683 682
684 def __editUserConfiguration(self): 683 def __editUserConfiguration(self):
702 @type bool 701 @type bool
703 """ 702 """
704 from QScintilla.MiniEditor import MiniEditor 703 from QScintilla.MiniEditor import MiniEditor
705 if virtualenv: 704 if virtualenv:
706 cfgFile = self.__getVirtualenvConfig() 705 cfgFile = self.__getVirtualenvConfig()
706 if not cfgFile:
707 return
707 else: 708 else:
708 cfgFile = self.__getUserConfig() 709 cfgFile = self.__getUserConfig()
709 cfgDir = os.path.dirname(cfgFile) 710 cfgDir = os.path.dirname(cfgFile)
710 if not cfgDir: 711 if not cfgDir:
711 E5MessageBox.critical( 712 E5MessageBox.critical(
768 dia = PipDialog(self.tr('Install PIP')) 769 dia = PipDialog(self.tr('Install PIP'))
769 if userSite: 770 if userSite:
770 commands = [(interpreter, ["-m", "ensurepip", "--user"])] 771 commands = [(interpreter, ["-m", "ensurepip", "--user"])]
771 else: 772 else:
772 commands = [(interpreter, ["-m", "ensurepip"])] 773 commands = [(interpreter, ["-m", "ensurepip"])]
773 if self.__plugin.getPreferences("PipSearchIndex"): 774 if Preferences.getPip("PipSearchIndex"):
774 indexUrl = \ 775 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
775 self.__plugin.getPreferences("PipSearchIndex") + "/simple"
776 args = ["-m", "pip", "install", "--index-url", indexUrl, 776 args = ["-m", "pip", "install", "--index-url", indexUrl,
777 "--upgrade"] 777 "--upgrade"]
778 else: 778 else:
779 args = ["-m", "pip", "install", "--upgrade"] 779 args = ["-m", "pip", "install", "--upgrade"]
780 if userSite: 780 if userSite:
812 812
813 interpreter = self.getVirtualenvInterpreter(venvName) 813 interpreter = self.getVirtualenvInterpreter(venvName)
814 if not interpreter: 814 if not interpreter:
815 return 815 return
816 816
817 if self.__plugin.getPreferences("PipSearchIndex"): 817 if Preferences.getPip("PipSearchIndex"):
818 indexUrl = \ 818 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
819 self.__plugin.getPreferences("PipSearchIndex") + "/simple"
820 args = ["-m", "pip", "install", "--index-url", indexUrl, 819 args = ["-m", "pip", "install", "--index-url", indexUrl,
821 "--upgrade"] 820 "--upgrade"]
822 else: 821 else:
823 args = ["-m", "pip", "install", "--upgrade"] 822 args = ["-m", "pip", "install", "--upgrade"]
824 if userSite: 823 if userSite:
848 interpreter = self.getVirtualenvInterpreter(venvName) 847 interpreter = self.getVirtualenvInterpreter(venvName)
849 if not interpreter: 848 if not interpreter:
850 return 849 return
851 850
852 # python -m pip install --ignore-installed pip 851 # python -m pip install --ignore-installed pip
853 if self.__plugin.getPreferences("PipSearchIndex"): 852 if Preferences.getPip("PipSearchIndex"):
854 indexUrl = \ 853 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
855 self.__plugin.getPreferences("PipSearchIndex") + "/simple"
856 args = ["-m", "pip", "install", "--index-url", indexUrl, 854 args = ["-m", "pip", "install", "--index-url", indexUrl,
857 "--ignore-installed"] 855 "--ignore-installed"]
858 else: 856 else:
859 args = ["-m", "pip", "install", "--ignore-installed"] 857 args = ["-m", "pip", "install", "--ignore-installed"]
860 if userSite: 858 if userSite:
908 """ 906 """
909 if self.__checkUpgradePyQt(packages): 907 if self.__checkUpgradePyQt(packages):
910 return False 908 return False
911 909
912 if not venvName: 910 if not venvName:
913 venvName = self.__plugin.getPreferences("CurrentEnvironment") 911 venvName = Preferences.getPip("CurrentEnvironment")
914 interpreter = self.getVirtualenvInterpreter(venvName) 912 interpreter = self.getVirtualenvInterpreter(venvName)
915 if not interpreter: 913 if not interpreter:
916 return 914 return
917 915
918 if self.__plugin.getPreferences("PipSearchIndex"): 916 if Preferences.getPip("PipSearchIndex"):
919 indexUrl = \ 917 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
920 self.__plugin.getPreferences("PipSearchIndex") + "/simple"
921 args = ["-m", "pip", "install", "--index-url", indexUrl, 918 args = ["-m", "pip", "install", "--index-url", indexUrl,
922 "--upgrade"] 919 "--upgrade"]
923 else: 920 else:
924 args = ["-m", "pip", "install", "--upgrade"] 921 args = ["-m", "pip", "install", "--upgrade"]
925 if userSite: 922 if userSite:
954 @param userSite flag indicating an install to the user install 951 @param userSite flag indicating an install to the user install
955 directory 952 directory
956 @type bool 953 @type bool
957 """ 954 """
958 if not venvName: 955 if not venvName:
959 venvName = self.__plugin.getPreferences("CurrentEnvironment") 956 venvName = Preferences.getPip("CurrentEnvironment")
960 interpreter = self.getVirtualenvInterpreter(venvName) 957 interpreter = self.getVirtualenvInterpreter(venvName)
961 if not interpreter: 958 if not interpreter:
962 return 959 return
963 960
964 if self.__plugin.getPreferences("PipSearchIndex"): 961 if Preferences.getPip("PipSearchIndex"):
965 indexUrl = \ 962 indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
966 self.__plugin.getPreferences("PipSearchIndex") + "/simple"
967 args = ["-m", "pip", "install", "--index-url", indexUrl] 963 args = ["-m", "pip", "install", "--index-url", indexUrl]
968 else: 964 else:
969 args = ["-m", "pip", "install"] 965 args = ["-m", "pip", "install"]
970 if userSite: 966 if userSite:
971 args.append("--user") 967 args.append("--user")
1010 venvName, requirements, user = dlg.getData() 1006 venvName, requirements, user = dlg.getData()
1011 if requirements and os.path.exists(requirements): 1007 if requirements and os.path.exists(requirements):
1012 interpreter = self.getVirtualenvInterpreter(venvName) 1008 interpreter = self.getVirtualenvInterpreter(venvName)
1013 if not interpreter: 1009 if not interpreter:
1014 return 1010 return
1015 if self.__plugin.getPreferences("PipSearchIndex"): 1011 if Preferences.getPip("PipSearchIndex"):
1016 indexUrl = \ 1012 indexUrl = Preferences.getPip("PipSearchIndex") + \
1017 self.__plugin.getPreferences("PipSearchIndex") + \
1018 "/simple" 1013 "/simple"
1019 args = ["-m", "pip", "install", "--index-url", indexUrl] 1014 args = ["-m", "pip", "install", "--index-url", indexUrl]
1020 else: 1015 else:
1021 args = ["-m", "pip", "install"] 1016 args = ["-m", "pip", "install"]
1022 if user: 1017 if user:
1048 self.tr( 1043 self.tr(
1049 "Do you really want to uninstall these packages?"), 1044 "Do you really want to uninstall these packages?"),
1050 packages) 1045 packages)
1051 if dlg.exec_() == QDialog.Accepted: 1046 if dlg.exec_() == QDialog.Accepted:
1052 if not venvName: 1047 if not venvName:
1053 venvName = self.__plugin.getPreferences( 1048 venvName = Preferences.getPip("CurrentEnvironment")
1054 "CurrentEnvironment")
1055 interpreter = self.getVirtualenvInterpreter(venvName) 1049 interpreter = self.getVirtualenvInterpreter(venvName)
1056 if not interpreter: 1050 if not interpreter:
1057 return 1051 return
1058 args = ["-m", "pip", "uninstall", "--yes"] + packages 1052 args = ["-m", "pip", "uninstall", "--yes"] + packages
1059 dia = PipDialog(self.tr('Uninstall Packages')) 1053 dia = PipDialog(self.tr('Uninstall Packages'))
1099 self.tr( 1093 self.tr(
1100 "Do you really want to uninstall these packages?"), 1094 "Do you really want to uninstall these packages?"),
1101 reqs) 1095 reqs)
1102 if dlg.exec_() == QDialog.Accepted: 1096 if dlg.exec_() == QDialog.Accepted:
1103 if not venvName: 1097 if not venvName:
1104 venvName = self.__plugin.getPreferences( 1098 venvName = Preferences.getPip("CurrentEnvironment")
1105 "CurrentEnvironment")
1106 interpreter = self.getVirtualenvInterpreter(venvName) 1099 interpreter = self.getVirtualenvInterpreter(venvName)
1107 if not interpreter: 1100 if not interpreter:
1108 return 1101 return
1109 args = ["-m", "pip", "uninstall", "--requirement", 1102 args = ["-m", "pip", "uninstall", "--requirement",
1110 requirements] 1103 requirements]
1127 """ 1120 """
1128 Private slot to search the Python Package Index. 1121 Private slot to search the Python Package Index.
1129 """ 1122 """
1130 from .PipSearchDialog import PipSearchDialog 1123 from .PipSearchDialog import PipSearchDialog
1131 1124
1132 if self.__plugin.getPreferences("PipSearchIndex"): 1125 if Preferences.getPip("PipSearchIndex"):
1133 indexUrl = self.__plugin.getPreferences("PipSearchIndex") + "/pypi" 1126 indexUrl = Preferences.getPip("PipSearchIndex") + "/pypi"
1134 else: 1127 else:
1135 indexUrl = DefaultIndexUrlXml 1128 indexUrl = DefaultIndexUrlXml
1136 1129
1137 self.__searchDialog = PipSearchDialog(self, indexUrl) 1130 self.__searchDialog = PipSearchDialog(self, indexUrl)
1138 self.__searchDialog.show() 1131 self.__searchDialog.show()

eric ide

mercurial