Skip to content

Commit cf21401

Browse files
committed
Make wheelbuilder.build return successes too
Also, pluralize variable names for readability and consistency with similar variables in callers.
1 parent a4d06ae commit cf21401

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/pip/_internal/commands/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def build_wheels(
8383
should_build_legacy = is_wheel_installed()
8484

8585
# Always build PEP 517 requirements
86-
build_failures = builder.build(
86+
_, build_failures = builder.build(
8787
pep517_requirements,
8888
should_unpack=True,
8989
)

src/pip/_internal/commands/wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def run(self, options, args):
161161
build_options=options.build_options or [],
162162
global_options=options.global_options or [],
163163
)
164-
build_failures = wb.build(
164+
_, build_failures = wb.build(
165165
requirement_set.requirements.values(),
166166
should_unpack=False,
167167
)

src/pip/_internal/wheel_builder.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from pip._vendor.pep517.wrappers import Pep517HookCaller
4444

4545
BinaryAllowedPredicate = Callable[[InstallRequirement], bool]
46+
BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]
4647

4748
logger = logging.getLogger(__name__)
4849

@@ -413,7 +414,7 @@ def build(
413414
requirements, # type: Iterable[InstallRequirement]
414415
should_unpack, # type: bool
415416
):
416-
# type: (...) -> List[InstallRequirement]
417+
# type: (...) -> BuildResult
417418
"""Build wheels.
418419
419420
:param should_unpack: If True, after building the wheel, unpack it
@@ -437,7 +438,7 @@ def build(
437438
need_wheel=not should_unpack,
438439
)
439440
if not buildset:
440-
return []
441+
return [], []
441442

442443
# TODO by @pradyunsg
443444
# Should break up this method into 2 separate methods.
@@ -449,7 +450,7 @@ def build(
449450
)
450451

451452
with indent_log():
452-
build_success, build_failure = [], []
453+
build_successes, build_failures = [], []
453454
for req, cache_dir in buildset:
454455
wheel_file = self._build_one(req, cache_dir)
455456
if wheel_file:
@@ -488,22 +489,22 @@ def build(
488489
"Building wheel for %s failed: %s",
489490
req.name, e,
490491
)
491-
build_failure.append(req)
492+
build_failures.append(req)
492493
continue
493-
build_success.append(req)
494+
build_successes.append(req)
494495
else:
495-
build_failure.append(req)
496+
build_failures.append(req)
496497

497498
# notify success/failure
498-
if build_success:
499+
if build_successes:
499500
logger.info(
500501
'Successfully built %s',
501-
' '.join([req.name for req in build_success]),
502+
' '.join([req.name for req in build_successes]),
502503
)
503-
if build_failure:
504+
if build_failures:
504505
logger.info(
505506
'Failed to build %s',
506-
' '.join([req.name for req in build_failure]),
507+
' '.join([req.name for req in build_failures]),
507508
)
508509
# Return a list of requirements that failed to build
509-
return build_failure
510+
return build_successes, build_failures

tests/unit/test_command_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def check_build_wheels(
2626
"""
2727
def build(reqs, **kwargs):
2828
# Fail the first requirement.
29-
return [reqs[0]]
29+
return ([], [reqs[0]])
3030

3131
builder = Mock()
3232
builder.build.side_effect = build

0 commit comments

Comments
 (0)