1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Move wheel_cache out of RequirementSet (#4600)

It now goes into both Resolver and WheelBuilder, where it belongs.
This commit is contained in:
Pradyun S. Gedam 2017-07-06 05:27:35 +05:30 committed by Donald Stufft
parent bf4c613071
commit 6f29b5d552
8 changed files with 24 additions and 13 deletions

View file

@ -202,6 +202,7 @@ class DownloadCommand(RequirementCommand):
preparer=preparer,
finder=finder,
session=session,
wheel_cache=None,
use_user_site=False,
upgrade_strategy="to-satisfy-only",
force_reinstall=False,

View file

@ -243,7 +243,6 @@ class InstallCommand(RequirementCommand):
requirement_set = RequirementSet(
target_dir=target_temp_dir.path,
pycompile=options.compile,
wheel_cache=wheel_cache,
require_hashes=options.require_hashes,
use_user_site=options.use_user_site,
)
@ -264,6 +263,7 @@ class InstallCommand(RequirementCommand):
preparer=preparer,
finder=finder,
session=session,
wheel_cache=wheel_cache,
use_user_site=options.use_user_site,
upgrade_strategy=upgrade_strategy,
force_reinstall=options.force_reinstall,
@ -283,6 +283,7 @@ class InstallCommand(RequirementCommand):
requirement_set,
finder,
preparer,
wheel_cache,
build_options=[],
global_options=[],
)

View file

@ -143,7 +143,6 @@ class WheelCommand(RequirementCommand):
options.build_dir, delete=build_delete, kind="wheel"
) as directory:
requirement_set = RequirementSet(
wheel_cache=wheel_cache,
require_hashes=options.require_hashes,
)
@ -164,6 +163,7 @@ class WheelCommand(RequirementCommand):
preparer=preparer,
finder=finder,
session=session,
wheel_cache=wheel_cache,
use_user_site=False,
upgrade_strategy="to-satisfy-only",
force_reinstall=False,
@ -180,6 +180,7 @@ class WheelCommand(RequirementCommand):
requirement_set,
finder,
preparer,
wheel_cache,
build_options=options.build_options or [],
global_options=options.global_options or [],
no_clean=options.no_clean,

View file

@ -42,7 +42,7 @@ class RequirementSet(object):
def __init__(self,
require_hashes=False, target_dir=None, use_user_site=False,
pycompile=True, wheel_cache=None):
pycompile=True):
"""Create a RequirementSet.
:param wheel_cache: The pip wheel cache, for passing to
@ -62,7 +62,6 @@ class RequirementSet(object):
self.use_user_site = use_user_site
self.target_dir = target_dir # set from --target option
self.pycompile = pycompile
self._wheel_cache = wheel_cache
# Maps from install_req -> dependencies_of_install_req
self._dependencies = defaultdict(list)

View file

@ -32,7 +32,7 @@ class Resolver(object):
_allowed_strategies = {"eager", "only-if-needed", "to-satisfy-only"}
def __init__(self, preparer, session, finder, use_user_site,
def __init__(self, preparer, session, finder, wheel_cache, use_user_site,
ignore_dependencies, ignore_installed, ignore_requires_python,
force_reinstall, isolated, upgrade_strategy):
super(Resolver, self).__init__()
@ -42,6 +42,10 @@ class Resolver(object):
self.finder = finder
self.session = session
# NOTE: This would eventually be replaced with a cache that can give
# information about both sdist and wheels transparently.
self.wheel_cache = wheel_cache
self.require_hashes = None # This is set in resolve
self.upgrade_strategy = upgrade_strategy
@ -212,7 +216,7 @@ class Resolver(object):
str(subreq),
req_to_install,
isolated=self.isolated,
wheel_cache=requirement_set._wheel_cache,
wheel_cache=self.wheel_cache,
)
more_reqs.extend(
requirement_set.add_requirement(

View file

@ -586,13 +586,13 @@ class BuildEnvironment(object):
class WheelBuilder(object):
"""Build wheels from a RequirementSet."""
def __init__(self, requirement_set, finder, preparer, build_options=None,
global_options=None, no_clean=False):
def __init__(self, requirement_set, finder, preparer, wheel_cache,
build_options=None, global_options=None, no_clean=False):
self.requirement_set = requirement_set
self.finder = finder
self.preparer = preparer
self.wheel_cache = wheel_cache
self._cache_root = requirement_set._wheel_cache._cache_dir
self._wheel_dir = preparer.wheel_download_dir
self.build_options = build_options or []
@ -727,7 +727,11 @@ class WheelBuilder(object):
newly built wheel, in preparation for installation.
:return: True if all the wheels built correctly.
"""
assert self._wheel_dir or (autobuilding and self._cache_root)
building_is_possible = self._wheel_dir or (
autobuilding and self.wheel_cache._cache_dir
)
assert building_is_possible
reqset = self.requirement_set.requirements.values()
buildset = []
@ -775,8 +779,9 @@ class WheelBuilder(object):
python_tag = None
if autobuilding:
python_tag = pep425tags.implementation_tag
# NOTE: Should move out a method on the cache directly.
output_dir = get_cache_path_for_link(
self._cache_root, req.link
self.wheel_cache._cache_dir, req.link
)
try:
ensure_dir(output_dir)

View file

@ -42,7 +42,7 @@ class TestRequirementSet(object):
progress_bar="on"
)
return Resolver(
preparer=preparer,
preparer=preparer, wheel_cache=None,
session=PipSession(), finder=finder,
use_user_site=False, upgrade_strategy="to-satisfy-only",
ignore_dependencies=False, ignore_installed=False,

View file

@ -362,7 +362,7 @@ class TestWheelBuilder(object):
wheel_req = Mock(is_wheel=True, editable=False, constraint=False)
reqset = Mock(requirements=Mock(values=lambda: [wheel_req]),
wheel_download_dir='/wheel/dir')
wb = wheel.WheelBuilder(reqset, Mock(), Mock())
wb = wheel.WheelBuilder(reqset, Mock(), Mock(), wheel_cache=None)
wb.build(Mock())
assert "due to already being wheel" in caplog.text
assert mock_build_one.mock_calls == []