Skip to content

Commit d8e2d66

Browse files
committed
Rename BinaryAllowedPredicate
It really is a BdistWheelAllowedPredicate and this will make it easier to reason when --no-binary does not imply setup.py install anymore.
1 parent df8a501 commit d8e2d66

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

src/pip/_internal/commands/install.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@
4545
virtualenv_no_global,
4646
)
4747
from pip._internal.wheel_builder import (
48-
BinaryAllowedPredicate,
48+
BdistWheelAllowedPredicate,
4949
build,
5050
should_build_for_install_command,
5151
)
5252

5353
logger = getLogger(__name__)
5454

5555

56-
def get_check_binary_allowed(format_control: FormatControl) -> BinaryAllowedPredicate:
56+
def get_check_bdist_wheel_allowed(
57+
format_control: FormatControl,
58+
) -> BdistWheelAllowedPredicate:
5759
def check_binary_allowed(req: InstallRequirement) -> bool:
5860
canonical_name = canonicalize_name(req.name or "")
5961
allowed_formats = format_control.get_allowed_formats(canonical_name)
@@ -409,12 +411,14 @@ def run(self, options: Values, args: List[str]) -> int:
409411
modifying_pip = pip_req.satisfied_by is None
410412
protect_pip_from_modification_on_windows(modifying_pip=modifying_pip)
411413

412-
check_binary_allowed = get_check_binary_allowed(finder.format_control)
414+
check_bdist_wheel_allowed = get_check_bdist_wheel_allowed(
415+
finder.format_control
416+
)
413417

414418
reqs_to_build = [
415419
r
416420
for r in requirement_set.requirements.values()
417-
if should_build_for_install_command(r, check_binary_allowed)
421+
if should_build_for_install_command(r, check_bdist_wheel_allowed)
418422
]
419423

420424
_, build_failures = build(

src/pip/_internal/wheel_builder.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
_egg_info_re = re.compile(r"([a-z0-9_.]+)-([a-z0-9_.!+-]+)", re.IGNORECASE)
3434

35-
BinaryAllowedPredicate = Callable[[InstallRequirement], bool]
35+
BdistWheelAllowedPredicate = Callable[[InstallRequirement], bool]
3636
BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]
3737

3838

@@ -47,7 +47,7 @@ def _contains_egg_info(s: str) -> bool:
4747
def _should_build(
4848
req: InstallRequirement,
4949
need_wheel: bool,
50-
check_binary_allowed: Optional[BinaryAllowedPredicate] = None,
50+
check_bdist_wheel: Optional[BdistWheelAllowedPredicate] = None,
5151
) -> bool:
5252
"""Return whether an InstallRequirement should be built into a wheel."""
5353
if req.constraint:
@@ -78,8 +78,8 @@ def _should_build(
7878
if req.use_pep517:
7979
return True
8080

81-
assert check_binary_allowed is not None
82-
if not check_binary_allowed(req):
81+
assert check_bdist_wheel is not None
82+
if not check_bdist_wheel(req):
8383
logger.info(
8484
"Skipping wheel build for %s, due to binaries being disabled for it.",
8585
req.name,
@@ -102,10 +102,10 @@ def should_build_for_wheel_command(
102102

103103
def should_build_for_install_command(
104104
req: InstallRequirement,
105-
check_binary_allowed: BinaryAllowedPredicate,
105+
check_bdist_wheel_allowed: BdistWheelAllowedPredicate,
106106
) -> bool:
107107
return _should_build(
108-
req, need_wheel=False, check_binary_allowed=check_binary_allowed
108+
req, need_wheel=False, check_bdist_wheel=check_bdist_wheel_allowed
109109
)
110110

111111

tests/unit/test_wheel_builder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def supports_pyproject_editable(self) -> bool:
5858

5959

6060
@pytest.mark.parametrize(
61-
"req, disallow_binaries, expected",
61+
"req, disallow_bdist_wheel, expected",
6262
[
6363
# When binaries are allowed, we build.
6464
(ReqMock(use_pep517=True), False, True),
@@ -110,11 +110,11 @@ def supports_pyproject_editable(self) -> bool:
110110
],
111111
)
112112
def test_should_build_for_install_command(
113-
req: ReqMock, disallow_binaries: bool, expected: bool
113+
req: ReqMock, disallow_bdist_wheel: bool, expected: bool
114114
) -> None:
115115
should_build = wheel_builder.should_build_for_install_command(
116116
cast(InstallRequirement, req),
117-
check_binary_allowed=lambda req: not disallow_binaries,
117+
check_bdist_wheel_allowed=lambda req: not disallow_bdist_wheel,
118118
)
119119
assert should_build is expected
120120

@@ -144,7 +144,7 @@ def test_should_build_legacy_wheel_not_installed(is_wheel_installed: mock.Mock)
144144
legacy_req = ReqMock(use_pep517=False)
145145
should_build = wheel_builder.should_build_for_install_command(
146146
cast(InstallRequirement, legacy_req),
147-
check_binary_allowed=lambda req: True,
147+
check_bdist_wheel_allowed=lambda req: True,
148148
)
149149
assert not should_build
150150

@@ -155,7 +155,7 @@ def test_should_build_legacy_wheel_installed(is_wheel_installed: mock.Mock) -> N
155155
legacy_req = ReqMock(use_pep517=False)
156156
should_build = wheel_builder.should_build_for_install_command(
157157
cast(InstallRequirement, legacy_req),
158-
check_binary_allowed=lambda req: True,
158+
check_bdist_wheel_allowed=lambda req: True,
159159
)
160160
assert should_build
161161

0 commit comments

Comments
 (0)