Commits

Vinay Sajip committed ccf5bed

Removed PyPI mirroring functionality (as now deprecated).

  • Participants
  • Parent commits d6ac6fb

Comments (0)

Files changed (3)

File distlib/index.py

 
 logger = logging.getLogger(__name__)
 
-DEFAULT_MIRROR_HOST = 'last.pypi.python.org'
 DEFAULT_INDEX = 'http://pypi.python.org/pypi'
 DEFAULT_REALM = 'pypi'
 
 
     boundary = b'----------ThIs_Is_tHe_distlib_index_bouNdaRY_$'
 
-    def __init__(self, url=None, mirror_host=None):
+    def __init__(self, url=None):
         """
         Initialise an instance.
 
         :param url: The URL of the index. If not specified, the URL for PyPI is
                     used.
-        :param mirror_host: If not specified, ``last.pypi.python.org`` is used.
-                            This is expected to have a canonial name which
-                            allows all mirror hostnames to be divined (e.g. if
-                            the canonical hostname for ``last.pypi.python.org``
-                            is ``g.pypi.python.org``, then the mirrors that are
-                            available would be assumed to be
-                            ``a.pypi.python.org``, ``b.pypi.python.org``, ...
-                            up to and including ``g.pypi.python.org``.
         """
         self.url = url or DEFAULT_INDEX
-        self.mirror_host = mirror_host or DEFAULT_MIRROR_HOST
         self.read_configuration()
         scheme, netloc, path, params, query, frag = urlparse(self.url)
         if params or query or frag or scheme not in ('http', 'https'):
             'Content-length': str(len(body))
         }
         return Request(self.url, body, headers)
-
-    @cached_property
-    def mirrors(self):
-        """
-        Return the list of hostnames which are mirrors for this index.
-        :return: A (possibly empty) list of hostnames of mirrors.
-        """
-        result = []
-        try:
-            host = socket.gethostbyname_ex(self.mirror_host)[0]
-        except socket.gaierror: # pragma: no cover
-            host = None
-        if host:
-            last, rest = host.split('.', 1)
-            n = len(last)
-            host_list = (''.join(w) for w in itertools.chain.from_iterable(
-                        itertools.product(ascii_lowercase, repeat=i)
-                        for i in range(1, n + 1)))
-            for s in host_list:
-                result.append('.'.join((s, rest)))
-                if s == last:
-                    break
-        return result

File distlib/locators.py

 
 class PyPIRPCLocator(Locator):
     """
-    This locator uses XML-RPC to locate distributions. It therefore cannot be
-    used with simple mirrors (that only mirror file content).
+    This locator uses XML-RPC to locate distributions. It therefore
+    cannot be used with simple mirrors (that only mirror file content).
     """
     def __init__(self, url, **kwargs):
         """

File tests/test_index.py

 
 from distlib import DistlibException
 from distlib.compat import urlopen, HTTPError, URLError
-from distlib.index import PackageIndex, DEFAULT_MIRROR_HOST
+from distlib.index import PackageIndex
 from distlib.metadata import Metadata, MetadataMissingError, METADATA_FILENAME
 from distlib.util import zip_dir, HTTPSHandler
 
             self.index.username = 'test'
             self.index.password = 'secret'
 
-    def test_mirrors(self):
-        "Test list of mirrors"
-        actual = self.index.mirrors
-        if actual:
-            host = socket.gethostbyname_ex(DEFAULT_MIRROR_HOST)[0]
-            self.assertEqual(actual[-1], host)
-            prefix, suffix = host.split('.', 1)
-            self.assertEqual(actual[0], '.'.join(('a', suffix)))
-
     def load_package_metadata(self, path):
         result = None
         for bn in (METADATA_FILENAME, 'package.json'):