Commit faaaea0a authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #2108 from pypa/feature/faster-distribution-hashcmp-no-remove

Feature/faster distribution hashcmp no remove
parents 322734cf 6a73d1f0
Package index functionality no longer attempts to remove an md5 fragment from the index URL. This functionality, added for distribute #163 is no longer relevant.
...@@ -55,7 +55,7 @@ except NameError: ...@@ -55,7 +55,7 @@ except NameError:
FileExistsError = OSError FileExistsError = OSError
from pkg_resources.extern import six from pkg_resources.extern import six
from pkg_resources.extern.six.moves import urllib, map, filter from pkg_resources.extern.six.moves import map, filter
# capture these to bypass sandboxing # capture these to bypass sandboxing
from os import utime from os import utime
...@@ -2546,15 +2546,6 @@ class EntryPoint: ...@@ -2546,15 +2546,6 @@ class EntryPoint:
return maps return maps
def _remove_md5_fragment(location):
if not location:
return ''
parsed = urllib.parse.urlparse(location)
if parsed[-1].startswith('md5='):
return urllib.parse.urlunparse(parsed[:-1] + ('',))
return location
def _version_from_file(lines): def _version_from_file(lines):
""" """
Given an iterable of lines from a Metadata file, return Given an iterable of lines from a Metadata file, return
...@@ -2611,7 +2602,7 @@ class Distribution: ...@@ -2611,7 +2602,7 @@ class Distribution:
self.parsed_version, self.parsed_version,
self.precedence, self.precedence,
self.key, self.key,
_remove_md5_fragment(self.location), self.location,
self.py_version or '', self.py_version or '',
self.platform or '', self.platform or '',
) )
......
...@@ -9,9 +9,7 @@ from setuptools.extern.six.moves import urllib, http_client ...@@ -9,9 +9,7 @@ from setuptools.extern.six.moves import urllib, http_client
import mock import mock
import pytest import pytest
import pkg_resources
import setuptools.package_index import setuptools.package_index
from setuptools.tests.server import IndexServer
from .textwrap import DALS from .textwrap import DALS
...@@ -114,43 +112,6 @@ class TestPackageIndex: ...@@ -114,43 +112,6 @@ class TestPackageIndex:
url = 'file:///tmp/test_package_index' url = 'file:///tmp/test_package_index'
assert index.url_ok(url, True) assert index.url_ok(url, True)
def test_links_priority(self):
"""
Download links from the pypi simple index should be used before
external download links.
https://bitbucket.org/tarek/distribute/issue/163
Usecase :
- someone uploads a package on pypi, a md5 is generated
- someone manually copies this link (with the md5 in the url) onto an
external page accessible from the package page.
- someone reuploads the package (with a different md5)
- while easy_installing, an MD5 error occurs because the external link
is used
-> Setuptools should use the link from pypi, not the external one.
"""
if sys.platform.startswith('java'):
# Skip this test on jython because binding to :0 fails
return
# start an index server
server = IndexServer()
server.start()
index_url = server.base_url() + 'test_links_priority/simple/'
# scan a test index
pi = setuptools.package_index.PackageIndex(index_url)
requirement = pkg_resources.Requirement.parse('foobar')
pi.find_packages(requirement)
server.stop()
# the distribution has been found
assert 'foobar' in pi
# we have only one link, because links are compared without md5
assert len(pi['foobar']) == 1
# the link should be from the index
assert 'correct_md5' in pi['foobar'][0].location
def test_parse_bdist_wininst(self): def test_parse_bdist_wininst(self):
parse = setuptools.package_index.parse_bdist_wininst parse = setuptools.package_index.parse_bdist_wininst
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment