Make wheel_cache an argument of build()

This commit is contained in:
Stéphane Bidoul (ACSONE) 2019-12-29 12:47:28 +01:00
parent c8d4277535
commit 261c286de9
No known key found for this signature in database
GPG Key ID: BCAB2555446B5B92
5 changed files with 12 additions and 9 deletions

View File

@ -74,6 +74,7 @@ def build_wheels(
builder, # type: WheelBuilder
pep517_requirements, # type: List[InstallRequirement]
legacy_requirements, # type: List[InstallRequirement]
wheel_cache, # type: WheelCache
build_options, # type: List[str]
global_options, # type: List[str]
check_binary_allowed, # type: BinaryAllowedPredicate
@ -89,6 +90,7 @@ def build_wheels(
_, build_failures = builder.build(
pep517_requirements,
should_unpack=True,
wheel_cache=wheel_cache,
build_options=build_options,
global_options=global_options,
check_binary_allowed=check_binary_allowed,
@ -101,6 +103,7 @@ def build_wheels(
builder.build(
legacy_requirements,
should_unpack=True,
wheel_cache=wheel_cache,
build_options=build_options,
global_options=global_options,
check_binary_allowed=check_binary_allowed,
@ -405,11 +408,12 @@ class InstallCommand(RequirementCommand):
else:
legacy_requirements.append(req)
wheel_builder = WheelBuilder(preparer, wheel_cache)
wheel_builder = WheelBuilder(preparer)
build_failures = build_wheels(
builder=wheel_builder,
pep517_requirements=pep517_requirements,
legacy_requirements=legacy_requirements,
wheel_cache=wheel_cache,
build_options=[],
global_options=[],
check_binary_allowed=check_binary_allowed,

View File

@ -158,10 +158,11 @@ class WheelCommand(RequirementCommand):
resolver.resolve(requirement_set)
# build wheels
wb = WheelBuilder(preparer, wheel_cache)
wb = WheelBuilder(preparer)
build_successes, build_failures = wb.build(
requirement_set.requirements.values(),
should_unpack=False,
wheel_cache=wheel_cache,
build_options=options.build_options or [],
global_options=options.global_options or [],
)

View File

@ -257,16 +257,15 @@ class WheelBuilder(object):
def __init__(
self,
preparer, # type: RequirementPreparer
wheel_cache, # type: WheelCache
):
# type: (...) -> None
self.preparer = preparer
self.wheel_cache = wheel_cache
def build(
self,
requirements, # type: Iterable[InstallRequirement]
should_unpack, # type: bool
wheel_cache, # type: WheelCache
build_options, # type: List[str]
global_options, # type: List[str]
check_binary_allowed=None, # type: Optional[BinaryAllowedPredicate]
@ -286,7 +285,7 @@ class WheelBuilder(object):
buildset = _collect_buildset(
requirements,
wheel_cache=self.wheel_cache,
wheel_cache=wheel_cache,
check_binary_allowed=check_binary_allowed,
need_wheel=not should_unpack,
)

View File

@ -38,6 +38,7 @@ class TestWheelCache:
builder=builder,
pep517_requirements=pep517_requirements,
legacy_requirements=legacy_requirements,
wheel_cache=Mock(cache_dir=None),
build_options=[],
global_options=[],
check_binary_allowed=None,

View File

@ -186,10 +186,7 @@ def test_format_command_result__empty_output(caplog, log_level):
class TestWheelBuilder(object):
def test_skip_building_wheels(self, caplog):
wb = wheel_builder.WheelBuilder(
preparer=Mock(),
wheel_cache=Mock(cache_dir=None),
)
wb = wheel_builder.WheelBuilder(preparer=Mock())
wb._build_one = mock_build_one = Mock()
wheel_req = Mock(is_wheel=True, editable=False, constraint=False)
@ -197,6 +194,7 @@ class TestWheelBuilder(object):
wb.build(
[wheel_req],
should_unpack=False,
wheel_cache=Mock(cache_dir=None),
build_options=[],
global_options=[],
)