Remove --process-dependency-links and related support code

This commit is contained in:
Pradyun Gedam 2018-12-02 17:25:59 +05:30
parent 2a902dd464
commit 7222cb8fdb
No known key found for this signature in database
GPG Key ID: DA17C4B29CB32E4B
14 changed files with 11 additions and 132 deletions

View File

@ -189,8 +189,6 @@ class BuildEnvironment(object):
args.extend(['--trusted-host', host])
if finder.allow_all_prereleases:
args.append('--pre')
if finder.process_dependency_links:
args.append('--process-dependency-links')
args.append('--')
args.extend(requirements)
with open_spinner(message) as spinner:

View File

@ -296,7 +296,6 @@ class RequirementCommand(Command):
index_urls=index_urls,
trusted_hosts=options.trusted_hosts,
allow_all_prereleases=options.pre,
process_dependency_links=options.process_dependency_links,
session=session,
platform=platform,
versions=python_versions,

View File

@ -347,17 +347,6 @@ def trusted_host():
)
# Remove after 1.5
process_dependency_links = partial(
Option,
"--process-dependency-links",
dest="process_dependency_links",
action="store_true",
default=False,
help="Enable the processing of dependency links.",
) # type: Callable[..., Option]
def constraints():
# type: () -> Option
return Option(
@ -773,6 +762,5 @@ index_group = {
extra_index_url,
no_index,
find_links,
process_dependency_links,
]
} # type: Dict[str, Any]

View File

@ -118,7 +118,6 @@ class ListCommand(Command):
index_urls=index_urls,
allow_all_prereleases=options.pre,
trusted_hosts=options.trusted_hosts,
process_dependency_links=options.process_dependency_links,
session=session,
)
@ -168,16 +167,8 @@ class ListCommand(Command):
logger.debug('Ignoring indexes: %s', ','.join(index_urls))
index_urls = []
dependency_links = []
for dist in packages:
if dist.has_metadata('dependency_links.txt'):
dependency_links.extend(
dist.get_metadata_lines('dependency_links.txt'),
)
with self._build_session(options) as session:
finder = self._build_package_finder(options, index_urls, session)
finder.add_dependency_links(dependency_links)
for dist in packages:
typ = 'unknown'

View File

@ -31,7 +31,6 @@ from pip._internal.models.index import PyPI
from pip._internal.models.link import Link
from pip._internal.pep425tags import get_supported
from pip._internal.utils.compat import ipaddress
from pip._internal.utils.deprecation import deprecated
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import (
ARCHIVE_EXTENSIONS, SUPPORTED_EXTENSIONS, WHEEL_EXTENSION, normalize_path,
@ -268,7 +267,6 @@ class PackageFinder(object):
index_urls, # type: List[str]
allow_all_prereleases=False, # type: bool
trusted_hosts=None, # type: Optional[Iterable[str]]
process_dependency_links=False, # type: bool
session=None, # type: Optional[PipSession]
format_control=None, # type: Optional[FormatControl]
platform=None, # type: Optional[str]
@ -315,7 +313,6 @@ class PackageFinder(object):
self.find_links.append(link)
self.index_urls = index_urls
self.dependency_links = [] # type: List[str]
# These are boring links that have already been logged somehow:
self.logged_links = set() # type: Set[Link]
@ -331,9 +328,6 @@ class PackageFinder(object):
# Do we want to allow _all_ pre-releases?
self.allow_all_prereleases = allow_all_prereleases
# Do we process dependency links?
self.process_dependency_links = process_dependency_links
# The Session we'll use to make requests
self.session = session
@ -375,22 +369,6 @@ class PackageFinder(object):
)
return "\n".join(lines)
def add_dependency_links(self, links):
# type: (Iterable[str]) -> None
# FIXME: this shouldn't be global list this, it should only
# apply to requirements of the package that specifies the
# dependency_links value
# FIXME: also, we should track comes_from (i.e., use Link)
if self.process_dependency_links:
deprecated(
"Dependency Links processing has been deprecated and will be "
"removed in a future release.",
replacement="PEP 508 URL dependencies",
gone_in="19.0",
issue=4187,
)
self.dependency_links.extend(links)
@staticmethod
def _sort_locations(locations, expand_dir=False):
# type: (Sequence[str], bool) -> Tuple[List[str], List[str]]
@ -587,7 +565,7 @@ class PackageFinder(object):
# type: (str) -> List[Optional[InstallationCandidate]]
"""Find all available InstallationCandidate for project_name
This checks index_urls, find_links and dependency_links.
This checks index_urls and find_links.
All versions found are returned as an InstallationCandidate list.
See _link_package_versions for details on which files are accepted
@ -597,21 +575,18 @@ class PackageFinder(object):
fl_file_loc, fl_url_loc = self._sort_locations(
self.find_links, expand_dir=True,
)
dep_file_loc, dep_url_loc = self._sort_locations(self.dependency_links)
file_locations = (Link(url) for url in itertools.chain(
index_file_loc, fl_file_loc, dep_file_loc,
index_file_loc, fl_file_loc,
))
# We trust every url that the user has given us whether it was given
# via --index-url or --find-links
# We explicitly do not trust links that came from dependency_links
# via --index-url or --find-links.
# We want to filter out any thing which does not have a secure origin.
url_locations = [
link for link in itertools.chain(
(Link(url) for url in index_url_loc),
(Link(url) for url in fl_url_loc),
(Link(url) for url in dep_url_loc),
)
if self._validate_secure_origin(logger, link)
]
@ -639,17 +614,6 @@ class PackageFinder(object):
self._package_versions(page.iter_links(), search)
)
dependency_versions = self._package_versions(
(Link(url) for url in self.dependency_links), search
)
if dependency_versions:
logger.debug(
'dependency_links found: %s',
', '.join([
version.location.url for version in dependency_versions
])
)
file_versions = self._package_versions(file_locations, search)
if file_versions:
file_versions.sort(reverse=True)
@ -662,10 +626,7 @@ class PackageFinder(object):
)
# This is an intentional priority ordering
return (
file_versions + find_links_versions + page_versions +
dependency_versions
)
return file_versions + find_links_versions + page_versions
def find_requirement(self, req, upgrade):
# type: (InstallRequirement, bool) -> Optional[Link]

View File

@ -97,15 +97,9 @@ class IsWheel(DistAbstraction):
class IsSDist(DistAbstraction):
# TODO: Remove 'finder' and the note in operations/check.py
def dist(self, finder):
# type: (PackageFinder) -> pkg_resources.Distribution
dist = self.req.get_dist()
# FIXME: shouldn't be globally added.
if finder and dist.has_metadata('dependency_links.txt'):
finder.add_dependency_links(
dist.get_metadata_lines('dependency_links.txt')
)
return dist
return self.req.get_dist()
def prep_for_dist(self, finder, build_isolation):
# type: (PackageFinder, bool) -> None

View File

@ -55,7 +55,6 @@ SUPPORTED_OPTIONS = [
cmdoptions.no_binary,
cmdoptions.only_binary,
cmdoptions.pre,
cmdoptions.process_dependency_links,
cmdoptions.trusted_host,
cmdoptions.require_hashes,
] # type: List[Callable[..., optparse.Option]]
@ -251,8 +250,6 @@ def process_line(
finder.find_links.append(value)
if opts.pre:
finder.allow_all_prereleases = True
if opts.process_dependency_links:
finder.process_dependency_links = True
if opts.trusted_hosts:
finder.secure_origins.extend(
("*", host, "*") for host in opts.trusted_hosts)

View File

@ -127,7 +127,6 @@ def pip_version_check(session, options):
index_urls=[options.index_url] + options.extra_index_urls,
allow_all_prereleases=False, # Explicitly set to False
trusted_hosts=options.trusted_hosts,
process_dependency_links=options.process_dependency_links,
session=session,
)
all_candidates = finder.find_all_candidates("pip")

View File

@ -61,6 +61,7 @@ class Subversion(VersionControl):
cmd_args = ['update'] + rev_options.to_args() + [dest]
self.run_command(cmd_args)
# TODO: Remove
def get_location(self, dist, dependency_links):
for url in dependency_links:
egg_fragment = Link(url).egg_fragment

View File

@ -175,8 +175,8 @@ def test_respect_order_in_requirements_file(script, data):
def test_install_local_editable_with_extras(script, data):
to_install = data.packages.join("LocalExtras")
res = script.pip(
'install', '-e', to_install + '[bar]', '--process-dependency-links',
res = script.pip_install_local(
'-e', to_install + '[bar]',
expect_error=False,
expect_stderr=True,
)

View File

@ -300,50 +300,6 @@ def test_finder_priority_file_over_page(data):
assert link.url.startswith("file://")
def test_finder_deplink():
"""
Test PackageFinder with dependency links only
"""
req = install_req_from_line('gmpy==1.15', None)
finder = PackageFinder(
[],
[],
process_dependency_links=True,
session=PipSession(),
)
finder.add_dependency_links(
['https://files.pythonhosted.org/packages/source/g/gmpy/gmpy-1.15.zip']
)
link = finder.find_requirement(req, False)
assert link.url.startswith("https://files.pythonhosted.org/"), link
@pytest.mark.network
def test_finder_priority_page_over_deplink():
"""
Test PackageFinder prefers page links over equivalent dependency links
"""
req = install_req_from_line('pip==1.5.6', None)
finder = PackageFinder(
[],
["https://pypi.org/simple/"],
process_dependency_links=True,
session=PipSession(),
)
finder.add_dependency_links([
'https://files.pythonhosted.org/packages/source/p/pip/pip-1.5.6.tar.gz'
])
all_versions = finder.find_all_candidates(req.name)
# Check that the dependency_link is last
assert all_versions[-1].location.url.startswith(
'https://files.pythonhosted.org/'
)
link = finder.find_requirement(req, False)
assert link.url.startswith(
"https://files.pythonhosted.org/packages/3f/08/7347ca4"
), link
def test_finder_priority_nonegg_over_eggfragments():
"""Test PackageFinder prefers non-egg links over "#egg=" links"""
req = install_req_from_line('bar==1.0', None)

View File

@ -82,6 +82,7 @@ class TestRequirementSet(object):
reqset,
)
# TODO: Update test when Python 2.7 or Python 3.4 is dropped.
def test_environment_marker_extras(self, data):
"""
Test that the environment marker extras are used with

View File

@ -413,11 +413,6 @@ class TestProcessLine(object):
call = mock_parse.mock_calls[0]
assert call[1][0] == 'http://me.com/me/reqs.txt'
def test_set_finder_process_dependency_links(self, finder):
list(process_line(
"--process-dependency-links", "file", 1, finder=finder))
assert finder.process_dependency_links
class TestBreakOptionsArgs(object):

View File

@ -50,8 +50,7 @@ def _options():
''' Some default options that we pass to outdated.pip_version_check '''
return pretend.stub(
find_links=False, extra_index_urls=[], index_url='default_url',
pre=False, trusted_hosts=False, process_dependency_links=False,
cache_dir='',
pre=False, trusted_hosts=False, cache_dir='',
)