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

Decouple WheelBuilder from RequirementSet (#4860)

This commit is contained in:
Pradyun Gedam 2017-11-16 15:16:21 +05:30 committed by GitHub
parent 9ec42b6085
commit 24fd884672
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 22 deletions

View file

@ -281,16 +281,15 @@ class InstallCommand(RequirementCommand):
if wheel and options.cache_dir:
# build wheels before install.
wb = WheelBuilder(
requirement_set,
finder,
preparer,
wheel_cache,
build_options=[],
global_options=[],
finder, preparer, wheel_cache,
build_options=[], global_options=[],
)
# Ignore the result: a failed wheel will be
# installed from the sdist/vcs whatever.
wb.build(session=session, autobuilding=True)
wb.build(
requirement_set.requirements.values(),
session=session, autobuilding=True
)
installed = requirement_set.install(
install_options,

View file

@ -177,15 +177,14 @@ class WheelCommand(RequirementCommand):
try:
# build wheels
wb = WheelBuilder(
requirement_set,
finder,
preparer,
wheel_cache,
finder, preparer, wheel_cache,
build_options=options.build_options or [],
global_options=options.global_options or [],
no_clean=options.no_clean,
)
wheels_built_successfully = wb.build(session=session)
wheels_built_successfully = wb.build(
requirement_set.requirements.values(), session=session,
)
if not wheels_built_successfully:
raise CommandError(
"Failed to build one or more wheels"

View file

@ -657,9 +657,8 @@ class BuildEnvironment(object):
class WheelBuilder(object):
"""Build wheels from a RequirementSet."""
def __init__(self, requirement_set, finder, preparer, wheel_cache,
def __init__(self, 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
@ -791,7 +790,7 @@ class WheelBuilder(object):
logger.error('Failed cleaning build dir for %s', req.name)
return False
def build(self, session, autobuilding=False):
def build(self, requirements, session, autobuilding=False):
"""Build wheels.
:param unpack: If True, replace the sdist we built from with the
@ -805,10 +804,8 @@ class WheelBuilder(object):
)
assert building_is_possible
reqset = self.requirement_set.requirements.values()
buildset = []
for req in reqset:
for req in requirements:
if req.constraint:
continue
if req.is_wheel:

View file

@ -364,10 +364,10 @@ class TestWheelBuilder(object):
with patch('pip._internal.wheel.WheelBuilder._build_one') \
as mock_build_one:
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(), wheel_cache=None)
wb.build(Mock())
wb = wheel.WheelBuilder(
finder=Mock(), preparer=Mock(), wheel_cache=None,
)
wb.build([wheel_req], session=Mock())
assert "due to already being wheel" in caplog.text
assert mock_build_one.mock_calls == []