eric6/PipInterface/Pip.py

changeset 8090
c53117374255
parent 8085
f6db8b3ecea9
child 8143
2c730d5fd177
--- a/eric6/PipInterface/Pip.py	Tue Feb 09 11:39:58 2021 +0100
+++ b/eric6/PipInterface/Pip.py	Tue Feb 09 17:51:16 2021 +0100
@@ -38,8 +38,9 @@
     Class implementing the pip GUI logic.
     """
     DefaultPyPiUrl = "https://pypi.org"
-    DefaultIndexUrlXml = DefaultPyPiUrl + "/pypi"
-    DefaultIndexUrlPip = DefaultPyPiUrl + "/simple"
+    DefaultIndexUrlPypi = DefaultPyPiUrl + "/pypi"
+    DefaultIndexUrlSimple = DefaultPyPiUrl + "/simple"
+    DefaultIndexUrlSearch = DefaultPyPiUrl + "/search/"
     
     def __init__(self, parent=None):
         """
@@ -504,13 +505,13 @@
         if Preferences.getPip("PipSearchIndex"):
             indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
         else:
-            indexUrl = Pip.DefaultIndexUrlPip
+            indexUrl = Pip.DefaultIndexUrlSimple
         
         return indexUrl
     
-    def getIndexUrlXml(self):
+    def getIndexUrlPypi(self):
         """
-        Public method to get the index URL for XML RPC calls.
+        Public method to get the index URL for PyPI API calls.
         
         @return index URL for XML RPC calls
         @rtype str
@@ -518,7 +519,21 @@
         if Preferences.getPip("PipSearchIndex"):
             indexUrl = Preferences.getPip("PipSearchIndex") + "/pypi"
         else:
-            indexUrl = Pip.DefaultIndexUrlXml
+            indexUrl = Pip.DefaultIndexUrlPypi
+        
+        return indexUrl
+    
+    def getIndexUrlSearch(self):
+        """
+        Public method to get the index URL for PyPI API calls.
+        
+        @return index URL for XML RPC calls
+        @rtype str
+        """
+        if Preferences.getPip("PipSearchIndex"):
+            indexUrl = Preferences.getPip("PipSearchIndex") + "/search/"
+        else:
+            indexUrl = Pip.DefaultIndexUrlSearch
         
         return indexUrl
     
@@ -557,6 +572,10 @@
                 if usersite:
                     args.append("--user")
                 
+                if Preferences.getPip("PipSearchIndex"):
+                    indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
+                    args += ["--index-url", indexUrl]
+                
                 proc = QProcess()
                 proc.start(interpreter, args)
                 if proc.waitForStarted(15000):
@@ -615,6 +634,10 @@
                 if usersite:
                     args.append("--user")
                 
+                if Preferences.getPip("PipSearchIndex"):
+                    indexUrl = Preferences.getPip("PipSearchIndex") + "/simple"
+                    args += ["--index-url", indexUrl]
+                
                 proc = QProcess()
                 proc.start(interpreter, args)
                 if proc.waitForStarted(15000):
@@ -651,7 +674,8 @@
         result = {}
         
         if name and version:
-            url = "https://pypi.org/pypi/{0}/{1}/json".format(name, version)
+            url = "{0}/{1}/{2}/json".format(
+                self.getIndexUrlPypi(), name, version)
             request = QNetworkRequest(QUrl(url))
             reply = self.__networkManager.get(request)
             while not reply.isFinished():

eric ide

mercurial