mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Populate InstallRequirement.link before preparing it (#6803)
This commit is contained in:
commit
5796d9e949
|
@ -308,9 +308,11 @@ class Resolver(object):
|
|||
)
|
||||
|
||||
upgrade_allowed = self._is_upgrade_allowed(req)
|
||||
|
||||
# We eagerly populate the link, since that's our "legacy" behavior.
|
||||
req.populate_link(self.finder, upgrade_allowed, self.require_hashes)
|
||||
abstract_dist = self.preparer.prepare_linked_requirement(
|
||||
req, self.session, self.finder, upgrade_allowed,
|
||||
self.require_hashes
|
||||
req, self.session, self.finder, self.require_hashes
|
||||
)
|
||||
|
||||
# NOTE
|
||||
|
|
|
@ -104,18 +104,20 @@ class RequirementPreparer(object):
|
|||
req, # type: InstallRequirement
|
||||
session, # type: PipSession
|
||||
finder, # type: PackageFinder
|
||||
upgrade_allowed, # type: bool
|
||||
require_hashes # type: bool
|
||||
require_hashes, # type: bool
|
||||
):
|
||||
# type: (...) -> AbstractDistribution
|
||||
"""Prepare a requirement that would be obtained from req.link
|
||||
"""
|
||||
assert req.link
|
||||
link = req.link
|
||||
|
||||
# TODO: Breakup into smaller functions
|
||||
if req.link and req.link.scheme == 'file':
|
||||
path = url_to_path(req.link.url)
|
||||
if link.scheme == 'file':
|
||||
path = url_to_path(link.url)
|
||||
logger.info('Processing %s', display_path(path))
|
||||
else:
|
||||
logger.info('Collecting %s', req)
|
||||
logger.info('Collecting %s', req.req or req)
|
||||
|
||||
with indent_log():
|
||||
# @@ if filesystem packages are not marked
|
||||
|
@ -138,17 +140,6 @@ class RequirementPreparer(object):
|
|||
"can delete this. Please delete it and try again."
|
||||
% (req, req.source_dir)
|
||||
)
|
||||
req.populate_link(finder, upgrade_allowed, require_hashes)
|
||||
|
||||
# We can't hit this spot and have populate_link return None.
|
||||
# req.satisfied_by is None here (because we're
|
||||
# guarded) and upgrade has no impact except when satisfied_by
|
||||
# is not None.
|
||||
# Then inside find_requirement existing_applicable -> False
|
||||
# If no new versions are found, DistributionNotFound is raised,
|
||||
# otherwise a result is guaranteed.
|
||||
assert req.link
|
||||
link = req.link
|
||||
|
||||
# Now that we have the real link, we can tell what kind of
|
||||
# requirements we have and raise some more informative errors
|
||||
|
@ -186,11 +177,11 @@ class RequirementPreparer(object):
|
|||
download_dir = self.download_dir
|
||||
# We always delete unpacked sdists after pip ran.
|
||||
autodelete_unpacked = True
|
||||
if req.link.is_wheel and self.wheel_download_dir:
|
||||
if link.is_wheel and self.wheel_download_dir:
|
||||
# when doing 'pip wheel` we download wheels to a
|
||||
# dedicated dir.
|
||||
download_dir = self.wheel_download_dir
|
||||
if req.link.is_wheel:
|
||||
if link.is_wheel:
|
||||
if download_dir:
|
||||
# When downloading, we only unpack wheels to get
|
||||
# metadata.
|
||||
|
@ -200,7 +191,7 @@ class RequirementPreparer(object):
|
|||
# wheel.
|
||||
autodelete_unpacked = False
|
||||
unpack_url(
|
||||
req.link, req.source_dir,
|
||||
link, req.source_dir,
|
||||
download_dir, autodelete_unpacked,
|
||||
session=session, hashes=hashes,
|
||||
progress_bar=self.progress_bar
|
||||
|
@ -214,7 +205,7 @@ class RequirementPreparer(object):
|
|||
raise InstallationError(
|
||||
'Could not install requirement %s because of HTTP '
|
||||
'error %s for URL %s' %
|
||||
(req, exc, req.link)
|
||||
(req, exc, link)
|
||||
)
|
||||
abstract_dist = make_distribution_for_install_requirement(req)
|
||||
with self.req_tracker.track(req):
|
||||
|
@ -223,7 +214,7 @@ class RequirementPreparer(object):
|
|||
)
|
||||
if self._download_should_save:
|
||||
# Make a .zip of the source_dir we already created.
|
||||
if not req.link.is_artifact:
|
||||
if not link.is_artifact:
|
||||
req.archive(self.download_dir)
|
||||
return abstract_dist
|
||||
|
||||
|
|
|
@ -600,7 +600,7 @@ def test_install_global_option(script):
|
|||
result = script.pip(
|
||||
'install', '--global-option=--version', "INITools==0.1",
|
||||
expect_stderr=True)
|
||||
assert '0.1\n' in result.stdout
|
||||
assert 'INITools==0.1\n' in result.stdout
|
||||
|
||||
|
||||
def test_install_with_hacked_egg_info(script, data):
|
||||
|
|
|
@ -162,7 +162,7 @@ def test_respect_order_in_requirements_file(script, data):
|
|||
)
|
||||
|
||||
downloaded = [line for line in result.stdout.split('\n')
|
||||
if 'Collecting' in line]
|
||||
if 'Processing' in line]
|
||||
|
||||
assert 'parent' in downloaded[0], (
|
||||
'First download should be "parent" but was "%s"' % downloaded[0]
|
||||
|
|
Loading…
Reference in a new issue