Skip to content

Commit 5189a6e

Browse files
committed
--no-binary does not imply setup.py install anymore
1 parent 4b14e7c commit 5189a6e

File tree

7 files changed

+23
-103
lines changed

7 files changed

+23
-103
lines changed

news/11451.removal.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``--no-binary`` does not imply ``setup.py install`` anymore. Instead a wheel will be
2+
built locally and installed.

src/pip/_internal/commands/install.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from optparse import SUPPRESS_HELP, Values
88
from typing import Iterable, List, Optional
99

10-
from pip._vendor.packaging.utils import canonicalize_name
1110
from pip._vendor.rich import print_json
1211

1312
from pip._internal.cache import WheelCache
@@ -22,7 +21,6 @@
2221
from pip._internal.exceptions import CommandError, InstallationError
2322
from pip._internal.locations import get_scheme
2423
from pip._internal.metadata import get_environment
25-
from pip._internal.models.format_control import FormatControl
2624
from pip._internal.models.installation_report import InstallationReport
2725
from pip._internal.operations.build.build_tracker import get_build_tracker
2826
from pip._internal.operations.check import ConflictDetails, check_install_conflicts
@@ -52,26 +50,11 @@
5250
running_under_virtualenv,
5351
virtualenv_no_global,
5452
)
55-
from pip._internal.wheel_builder import (
56-
BdistWheelAllowedPredicate,
57-
build,
58-
should_build_for_install_command,
59-
)
53+
from pip._internal.wheel_builder import build, should_build_for_install_command
6054

6155
logger = getLogger(__name__)
6256

6357

64-
def get_check_bdist_wheel_allowed(
65-
format_control: FormatControl,
66-
) -> BdistWheelAllowedPredicate:
67-
def check_binary_allowed(req: InstallRequirement) -> bool:
68-
canonical_name = canonicalize_name(req.name or "")
69-
allowed_formats = format_control.get_allowed_formats(canonical_name)
70-
return "binary" in allowed_formats
71-
72-
return check_binary_allowed
73-
74-
7558
class InstallCommand(RequirementCommand):
7659
"""
7760
Install packages from:
@@ -455,14 +438,10 @@ def run(self, options: Values, args: List[str]) -> int:
455438
modifying_pip = pip_req.satisfied_by is None
456439
protect_pip_from_modification_on_windows(modifying_pip=modifying_pip)
457440

458-
check_bdist_wheel_allowed = get_check_bdist_wheel_allowed(
459-
finder.format_control
460-
)
461-
462441
reqs_to_build = [
463442
r
464443
for r in requirement_set.requirements.values()
465-
if should_build_for_install_command(r, check_bdist_wheel_allowed)
444+
if should_build_for_install_command(r)
466445
]
467446

468447
_, build_failures = build(

src/pip/_internal/utils/deprecation.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,3 @@ def emit_deprecation(self, name: str) -> None:
173173
issue=8559,
174174
emit_before_install=True,
175175
)
176-
177-
LegacyInstallReasonNoBinaryForcesSetuptoolsInstall = LegacyInstallReason(
178-
reason=(
179-
"{name} is being installed using the legacy "
180-
"'setup.py install' method, because the '--no-binary' option was enabled "
181-
"for it and this currently disables local wheel building for projects that "
182-
"don't have a 'pyproject.toml' file."
183-
),
184-
replacement="to enable the '--use-pep517' option",
185-
gone_in="23.1",
186-
issue=11451,
187-
emit_before_install=True,
188-
)

src/pip/_internal/wheel_builder.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os.path
66
import re
77
import shutil
8-
from typing import Callable, Iterable, List, Optional, Tuple
8+
from typing import Iterable, List, Optional, Tuple
99

1010
from pip._vendor.packaging.utils import canonicalize_name, canonicalize_version
1111
from pip._vendor.packaging.version import InvalidVersion, Version
@@ -19,10 +19,7 @@
1919
from pip._internal.operations.build.wheel_editable import build_wheel_editable
2020
from pip._internal.operations.build.wheel_legacy import build_wheel_legacy
2121
from pip._internal.req.req_install import InstallRequirement
22-
from pip._internal.utils.deprecation import (
23-
LegacyInstallReasonMissingWheelPackage,
24-
LegacyInstallReasonNoBinaryForcesSetuptoolsInstall,
25-
)
22+
from pip._internal.utils.deprecation import LegacyInstallReasonMissingWheelPackage
2623
from pip._internal.utils.logging import indent_log
2724
from pip._internal.utils.misc import ensure_dir, hash_file, is_wheel_installed
2825
from pip._internal.utils.setuptools_build import make_setuptools_clean_args
@@ -35,7 +32,6 @@
3532

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

38-
BdistWheelAllowedPredicate = Callable[[InstallRequirement], bool]
3935
BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]
4036

4137

@@ -50,7 +46,6 @@ def _contains_egg_info(s: str) -> bool:
5046
def _should_build(
5147
req: InstallRequirement,
5248
need_wheel: bool,
53-
check_bdist_wheel: Optional[BdistWheelAllowedPredicate] = None,
5449
) -> bool:
5550
"""Return whether an InstallRequirement should be built into a wheel."""
5651
if req.constraint:
@@ -81,16 +76,6 @@ def _should_build(
8176
if req.use_pep517:
8277
return True
8378

84-
assert check_bdist_wheel is not None
85-
if not check_bdist_wheel(req):
86-
# /!\ When we change this to unconditionally return True, we must also remove
87-
# support for `--install-option`. Indeed, `--install-option` implies
88-
# `--no-binary` so we can return False here and run `setup.py install`.
89-
# `--global-option` and `--build-option` can remain until we drop support for
90-
# building with `setup.py bdist_wheel`.
91-
req.legacy_install_reason = LegacyInstallReasonNoBinaryForcesSetuptoolsInstall
92-
return False
93-
9479
if not is_wheel_installed():
9580
# we don't build legacy requirements if wheel is not installed
9681
req.legacy_install_reason = LegacyInstallReasonMissingWheelPackage
@@ -107,11 +92,8 @@ def should_build_for_wheel_command(
10792

10893
def should_build_for_install_command(
10994
req: InstallRequirement,
110-
check_bdist_wheel_allowed: BdistWheelAllowedPredicate,
11195
) -> bool:
112-
return _should_build(
113-
req, need_wheel=False, check_bdist_wheel=check_bdist_wheel_allowed
114-
)
96+
return _should_build(req, need_wheel=False)
11597

11698

11799
def _should_cache(

tests/functional/test_install.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,12 +1665,9 @@ def test_install_no_binary_disables_building_wheels(
16651665
# Wheels are built for local directories, but not cached across runs
16661666
assert "Building wheel for requir" in str(res), str(res)
16671667
# Don't build wheel for upper which was blacklisted
1668-
assert "Building wheel for upper" not in str(res), str(res)
1669-
# Wheels are built for local directories, but not cached across runs
1670-
assert "Running setup.py install for requir" not in str(res), str(res)
1668+
assert "Building wheel for upper" in str(res), str(res)
16711669
# And these two fell back to sdist based installed.
16721670
assert "Running setup.py install for wheelb" in str(res), str(res)
1673-
assert "Running setup.py install for upper" in str(res), str(res)
16741671

16751672

16761673
@pytest.mark.network
@@ -1720,10 +1717,8 @@ def test_install_no_binary_disables_cached_wheels(
17201717
expect_stderr=True,
17211718
)
17221719
assert "Successfully installed upper-2.0" in str(res), str(res)
1723-
# No wheel building for upper, which was blacklisted
1724-
assert "Building wheel for upper" not in str(res), str(res)
1725-
# Must have used source, not a cached wheel to install upper.
1726-
assert "Running setup.py install for upper" in str(res), str(res)
1720+
# upper is built and not obtained from cache
1721+
assert "Building wheel for upper" in str(res), str(res)
17271722

17281723

17291724
def test_install_editable_with_wrong_egg_name(

tests/functional/test_install_config.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,8 @@ def test_install_no_binary_via_config_disables_cached_wheels(
265265
finally:
266266
os.unlink(config_file.name)
267267
assert "Successfully installed upper-2.0" in str(res), str(res)
268-
# No wheel building for upper, which was blacklisted
269-
assert "Building wheel for upper" not in str(res), str(res)
270-
# Must have used source, not a cached wheel to install upper.
271-
assert "Running setup.py install for upper" in str(res), str(res)
268+
# upper is built and not obtained from cache
269+
assert "Building wheel for upper" in str(res), str(res)
272270

273271

274272
@pytest.mark.skipif(

tests/unit/test_wheel_builder.py

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

5959

6060
@pytest.mark.parametrize(
61-
"req, disallow_bdist_wheel, expected",
61+
"req, expected",
6262
[
63-
# When binaries are allowed, we build.
64-
(ReqMock(use_pep517=True), False, True),
65-
(ReqMock(use_pep517=False), False, True),
66-
# When binaries are disallowed, we don't build, unless pep517 is
67-
# enabled.
68-
(ReqMock(use_pep517=True), True, True),
69-
(ReqMock(use_pep517=False), True, False),
63+
# We build, whether pep 517 is enabled or not.
64+
(ReqMock(use_pep517=True), True),
65+
(ReqMock(use_pep517=False), True),
7066
# We don't build constraints.
71-
(ReqMock(constraint=True), False, False),
67+
(ReqMock(constraint=True), False),
7268
# We don't build reqs that are already wheels.
73-
(ReqMock(is_wheel=True), False, False),
74-
(ReqMock(editable=True, use_pep517=False), False, False),
69+
(ReqMock(is_wheel=True), False),
70+
# We build editables if the backend supports PEP 660.
71+
(ReqMock(editable=True, use_pep517=False), False),
7572
(
7673
ReqMock(editable=True, use_pep517=True, supports_pyproject_editable=True),
77-
False,
7874
True,
7975
),
8076
(
8177
ReqMock(editable=True, use_pep517=True, supports_pyproject_editable=False),
8278
False,
83-
False,
8479
),
85-
(ReqMock(source_dir=None), False, False),
80+
# We don't build if there is no source dir (whatever that means!).
81+
(ReqMock(source_dir=None), False),
8682
# By default (i.e. when binaries are allowed), VCS requirements
8783
# should be built in install mode.
8884
(
8985
ReqMock(link=Link("git+https://g.c/org/repo"), use_pep517=True),
90-
False,
91-
True,
92-
),
93-
(
94-
ReqMock(link=Link("git+https://g.c/org/repo"), use_pep517=False),
95-
False,
96-
True,
97-
),
98-
# Disallowing binaries, however, should cause them not to be built.
99-
# unless pep517 is enabled.
100-
(
101-
ReqMock(link=Link("git+https://g.c/org/repo"), use_pep517=True),
102-
True,
10386
True,
10487
),
10588
(
10689
ReqMock(link=Link("git+https://g.c/org/repo"), use_pep517=False),
10790
True,
108-
False,
10991
),
11092
],
11193
)
112-
def test_should_build_for_install_command(
113-
req: ReqMock, disallow_bdist_wheel: bool, expected: bool
114-
) -> None:
94+
def test_should_build_for_install_command(req: ReqMock, expected: bool) -> None:
11595
should_build = wheel_builder.should_build_for_install_command(
11696
cast(InstallRequirement, req),
117-
check_bdist_wheel_allowed=lambda req: not disallow_bdist_wheel,
11897
)
11998
assert should_build is expected
12099

@@ -144,7 +123,6 @@ def test_should_build_legacy_wheel_not_installed(is_wheel_installed: mock.Mock)
144123
legacy_req = ReqMock(use_pep517=False)
145124
should_build = wheel_builder.should_build_for_install_command(
146125
cast(InstallRequirement, legacy_req),
147-
check_bdist_wheel_allowed=lambda req: True,
148126
)
149127
assert not should_build
150128

@@ -155,7 +133,6 @@ def test_should_build_legacy_wheel_installed(is_wheel_installed: mock.Mock) -> N
155133
legacy_req = ReqMock(use_pep517=False)
156134
should_build = wheel_builder.should_build_for_install_command(
157135
cast(InstallRequirement, legacy_req),
158-
check_bdist_wheel_allowed=lambda req: True,
159136
)
160137
assert should_build
161138

0 commit comments

Comments
 (0)