Skip to content

Commit 84f7870

Browse files
committed
Deprecate --install-option
1 parent 1880f4a commit 84f7870

File tree

7 files changed

+75
-34
lines changed

7 files changed

+75
-34
lines changed

news/11358.removal.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate ``--install-options`` which forces pip to use the deprecated ``install``
2+
command of ``setuptools``.

src/pip/_internal/cli/cmdoptions.py

-25
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,6 @@ def make_option_group(group: Dict[str, Any], parser: ConfigOptionParser) -> Opti
5959
return option_group
6060

6161

62-
def check_install_build_global(
63-
options: Values, check_options: Optional[Values] = None
64-
) -> None:
65-
"""Disable wheels if per-setup.py call options are set.
66-
67-
:param options: The OptionParser options to update.
68-
:param check_options: The options to check, if not supplied defaults to
69-
options.
70-
"""
71-
if check_options is None:
72-
check_options = options
73-
74-
def getname(n: str) -> Optional[Any]:
75-
return getattr(check_options, n, None)
76-
77-
names = ["build_options", "global_options", "install_options"]
78-
if any(map(getname, names)):
79-
control = options.format_control
80-
control.disallow_binaries()
81-
logger.warning(
82-
"Disabling all use of wheels due to the use of --build-option "
83-
"/ --global-option / --install-option.",
84-
)
85-
86-
8762
def check_dist_restriction(options: Values, check_target: bool = False) -> None:
8863
"""Function for determining if custom platform options are allowed.
8964

src/pip/_internal/commands/download.py

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
99
from pip._internal.cli.status_codes import SUCCESS
1010
from pip._internal.operations.build.build_tracker import get_build_tracker
11+
from pip._internal.req.req_install import (
12+
LegacySetupPyOptionsCheckMode,
13+
check_legacy_setup_py_options,
14+
)
1115
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
1216
from pip._internal.utils.temp_dir import TempDirectory
1317

@@ -105,6 +109,9 @@ def run(self, options: Values, args: List[str]) -> int:
105109
)
106110

107111
reqs = self.get_requirements(args, options, finder, session)
112+
check_legacy_setup_py_options(
113+
options, reqs, LegacySetupPyOptionsCheckMode.DOWNLOAD
114+
)
108115

109116
preparer = self.make_requirement_preparer(
110117
temp_build_dir=directory,

src/pip/_internal/commands/install.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
from pip._internal.operations.build.build_tracker import get_build_tracker
2828
from pip._internal.operations.check import ConflictDetails, check_install_conflicts
2929
from pip._internal.req import install_given_reqs
30-
from pip._internal.req.req_install import InstallRequirement
30+
from pip._internal.req.req_install import (
31+
InstallRequirement,
32+
LegacySetupPyOptionsCheckMode,
33+
check_legacy_setup_py_options,
34+
)
3135
from pip._internal.utils.compat import WINDOWS
3236
from pip._internal.utils.distutils_args import parse_distutils_args
3337
from pip._internal.utils.filesystem import test_writable_dir
@@ -272,7 +276,6 @@ def run(self, options: Values, args: List[str]) -> int:
272276
if options.use_user_site and options.target_dir is not None:
273277
raise CommandError("Can not combine '--user' and '--target'")
274278

275-
cmdoptions.check_install_build_global(options)
276279
upgrade_strategy = "to-satisfy-only"
277280
if options.upgrade:
278281
upgrade_strategy = options.upgrade_strategy
@@ -333,6 +336,9 @@ def run(self, options: Values, args: List[str]) -> int:
333336

334337
try:
335338
reqs = self.get_requirements(args, options, finder, session)
339+
check_legacy_setup_py_options(
340+
options, reqs, LegacySetupPyOptionsCheckMode.INSTALL
341+
)
336342

337343
# Only when installing is it permitted to use PEP 660.
338344
# In other circumstances (pip wheel, pip download) we generate

src/pip/_internal/commands/wheel.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
from pip._internal.cli.status_codes import SUCCESS
1111
from pip._internal.exceptions import CommandError
1212
from pip._internal.operations.build.build_tracker import get_build_tracker
13-
from pip._internal.req.req_install import InstallRequirement
13+
from pip._internal.req.req_install import (
14+
InstallRequirement,
15+
LegacySetupPyOptionsCheckMode,
16+
check_legacy_setup_py_options,
17+
)
1418
from pip._internal.utils.misc import ensure_dir, normalize_path
1519
from pip._internal.utils.temp_dir import TempDirectory
1620
from pip._internal.wheel_builder import build, should_build_for_wheel_command
@@ -100,8 +104,6 @@ def add_options(self) -> None:
100104

101105
@with_cleanup
102106
def run(self, options: Values, args: List[str]) -> int:
103-
cmdoptions.check_install_build_global(options)
104-
105107
session = self.get_default_session(options)
106108

107109
finder = self._build_package_finder(options, session)
@@ -119,6 +121,9 @@ def run(self, options: Values, args: List[str]) -> int:
119121
)
120122

121123
reqs = self.get_requirements(args, options, finder, session)
124+
check_legacy_setup_py_options(
125+
options, reqs, LegacySetupPyOptionsCheckMode.WHEEL
126+
)
122127

123128
preparer = self.make_requirement_preparer(
124129
temp_build_dir=directory,

src/pip/_internal/req/req_file.py

-4
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ def handle_requirement_line(
186186
constraint=line.constraint,
187187
)
188188
else:
189-
if options:
190-
# Disable wheels if the user has specified build options
191-
cmdoptions.check_install_build_global(options, line.opts)
192-
193189
# get the options that apply to requirements
194190
req_options = {}
195191
for dest in SUPPORTED_OPTIONS_REQ_DEST:

src/pip/_internal/req/req_install.py

+50
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import sys
99
import uuid
1010
import zipfile
11+
from enum import Enum
12+
from optparse import Values
1113
from typing import Any, Collection, Dict, Iterable, List, Optional, Sequence, Union
1214

1315
from pip._vendor.packaging.markers import Marker
@@ -877,3 +879,51 @@ def check_invalid_constraint_type(req: InstallRequirement) -> str:
877879
)
878880

879881
return problem
882+
883+
884+
def _has_option(options: Values, reqs: List[InstallRequirement], option: str) -> bool:
885+
if getattr(options, option, None):
886+
return True
887+
for req in reqs:
888+
if getattr(req, option, None):
889+
return True
890+
return False
891+
892+
893+
class LegacySetupPyOptionsCheckMode(Enum):
894+
INSTALL = 1
895+
WHEEL = 2
896+
DOWNLOAD = 3
897+
898+
899+
def check_legacy_setup_py_options(
900+
options: Values,
901+
reqs: List[InstallRequirement],
902+
mode: LegacySetupPyOptionsCheckMode,
903+
) -> None:
904+
has_install_options = _has_option(options, reqs, "install_options")
905+
has_build_options = _has_option(options, reqs, "build_options")
906+
has_global_options = _has_option(options, reqs, "global_options")
907+
legacy_setup_py_options_present = (
908+
has_install_options or has_build_options or has_global_options
909+
)
910+
if not legacy_setup_py_options_present:
911+
return
912+
913+
options.format_control.disallow_binaries()
914+
logger.warning(
915+
"Implying --no-binary=:all: due to the presence of "
916+
"--build-option / --global-option / --install-option. "
917+
"Consider using --config-settings for more flexibility.",
918+
)
919+
if mode == LegacySetupPyOptionsCheckMode.INSTALL and has_install_options:
920+
deprecated(
921+
reason=(
922+
"--install-option is deprecated because "
923+
"it forces pip to use the 'setup.py install' "
924+
"command which is itself deprecated."
925+
),
926+
issue=11358,
927+
replacement="to use --config-settings",
928+
gone_in=None,
929+
)

0 commit comments

Comments
 (0)