Skip to content

Commit e798211

Browse files
authored
Merge pull request #11858 from sbidoul/rm-install-options-sbi
Remove deprecated `--install-option`
2 parents 9d09b85 + a04748d commit e798211

18 files changed

+20
-394
lines changed

docs/html/reference/requirements-file-format.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ and two {ref}`--find-links <install_--find-links>` locations:
109109

110110
The options which can be applied to individual requirements are:
111111

112-
- {ref}`--install-option <install_--install-option>`
113112
- {ref}`--global-option <install_--global-option>`
114113
- {ref}`--config-settings <install_--config-settings>`
115114
- `--hash` (for {ref}`Hash-checking mode`)
@@ -161,7 +160,7 @@ This disables the use of wheels (cached or otherwise). This could mean that buil
161160
This mechanism is only preserved for backwards compatibility and should be considered deprecated. A future release of pip may drop these options.
162161
```
163162

164-
The `--global-option` and `--install-option` options are used to pass options to `setup.py`.
163+
The `--global-option` option is used to pass options to `setup.py`.
165164

166165
```{attention}
167166
These options are highly coupled with how pip invokes setuptools using the {doc}`../reference/build-system/setup-py` build system interface. It is not compatible with newer {doc}`../reference/build-system/pyproject-toml` build system interface.
@@ -171,15 +170,10 @@ This is will not work with other build-backends or newer setup.cfg-only projects
171170

172171
If you have a declaration like:
173172

174-
FooProject >= 1.2 --global-option="--no-user-cfg" \
175-
--install-option="--prefix='/usr/local'" \
176-
--install-option="--no-compile"
173+
FooProject >= 1.2 --global-option="--no-user-cfg"
177174

178175
The above translates roughly into running FooProject's `setup.py` script as:
179176

180-
python setup.py --no-user-cfg install --prefix='/usr/local' --no-compile
177+
python setup.py --no-user-cfg install
181178

182-
Note that the only way of giving more than one option to `setup.py` is through multiple `--global-option` and `--install-option` options, as shown in the example above. The value of each option is passed as a single argument to the `setup.py` script. Therefore, a line such as the following is invalid and would result in an installation error.
183-
184-
# Invalid. Please use '--install-option' twice as shown above.
185-
FooProject >= 1.2 --install-option="--prefix=/usr/local --no-compile"
179+
Note that the only way of giving more than one option to `setup.py` is through multiple `--global-option` options.

news/11358.removal.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove support for the deprecated ``--install-options``.

src/pip/_internal/cli/cmdoptions.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -847,17 +847,6 @@ def _handle_config_settings(
847847
"to pass multiple keys to the backend.",
848848
)
849849

850-
install_options: Callable[..., Option] = partial(
851-
Option,
852-
"--install-option",
853-
dest="install_options",
854-
action="append",
855-
metavar="options",
856-
help="This option is deprecated. Using this option with location-changing "
857-
"options may cause unexpected behavior. "
858-
"Use pip-level options like --user, --prefix, --root, and --target.",
859-
)
860-
861850
build_options: Callable[..., Option] = partial(
862851
Option,
863852
"--build-option",

src/pip/_internal/commands/install.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import shutil
66
import site
77
from optparse import SUPPRESS_HELP, Values
8-
from typing import Iterable, List, Optional
8+
from typing import List, Optional
99

1010
from pip._vendor.rich import print_json
1111

@@ -35,7 +35,6 @@
3535
LegacyInstallReasonFailedBdistWheel,
3636
deprecated,
3737
)
38-
from pip._internal.utils.distutils_args import parse_distutils_args
3938
from pip._internal.utils.filesystem import test_writable_dir
4039
from pip._internal.utils.logging import getLogger
4140
from pip._internal.utils.misc import (
@@ -206,7 +205,6 @@ def add_options(self) -> None:
206205
self.cmd_opts.add_option(cmdoptions.override_externally_managed())
207206

208207
self.cmd_opts.add_option(cmdoptions.config_settings())
209-
self.cmd_opts.add_option(cmdoptions.install_options())
210208
self.cmd_opts.add_option(cmdoptions.global_options())
211209

212210
self.cmd_opts.add_option(
@@ -297,8 +295,6 @@ def run(self, options: Values, args: List[str]) -> int:
297295

298296
cmdoptions.check_dist_restriction(options, check_target=True)
299297

300-
install_options = options.install_options or []
301-
302298
logger.verbose("Using %s", get_pip_version())
303299
options.use_user_site = decide_user_install(
304300
options.use_user_site,
@@ -378,8 +374,6 @@ def run(self, options: Values, args: List[str]) -> int:
378374
for req in reqs:
379375
req.permit_editable_wheels = True
380376

381-
reject_location_related_install_options(reqs, options.install_options)
382-
383377
preparer = self.make_requirement_preparer(
384378
temp_build_dir=directory,
385379
options=options,
@@ -490,7 +484,6 @@ def run(self, options: Values, args: List[str]) -> int:
490484

491485
installed = install_given_reqs(
492486
to_install,
493-
install_options,
494487
global_options,
495488
root=options.root_path,
496489
home=target_temp_dir_path,
@@ -761,45 +754,6 @@ def decide_user_install(
761754
return True
762755

763756

764-
def reject_location_related_install_options(
765-
requirements: List[InstallRequirement], options: Optional[List[str]]
766-
) -> None:
767-
"""If any location-changing --install-option arguments were passed for
768-
requirements or on the command-line, then show a deprecation warning.
769-
"""
770-
771-
def format_options(option_names: Iterable[str]) -> List[str]:
772-
return ["--{}".format(name.replace("_", "-")) for name in option_names]
773-
774-
offenders = []
775-
776-
for requirement in requirements:
777-
install_options = requirement.install_options
778-
location_options = parse_distutils_args(install_options)
779-
if location_options:
780-
offenders.append(
781-
"{!r} from {}".format(
782-
format_options(location_options.keys()), requirement
783-
)
784-
)
785-
786-
if options:
787-
location_options = parse_distutils_args(options)
788-
if location_options:
789-
offenders.append(
790-
"{!r} from command line".format(format_options(location_options.keys()))
791-
)
792-
793-
if not offenders:
794-
return
795-
796-
raise CommandError(
797-
"Location-changing options found in --install-option: {}."
798-
" This is unsupported, use pip-level options like --user,"
799-
" --prefix, --root, and --target instead.".format("; ".join(offenders))
800-
)
801-
802-
803757
def create_os_error_message(
804758
error: OSError, show_traceback: bool, using_user_site: bool
805759
) -> str:

src/pip/_internal/operations/install/editable_legacy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Legacy editable installation process, i.e. `setup.py develop`.
22
"""
33
import logging
4-
from typing import List, Optional, Sequence
4+
from typing import Optional, Sequence
55

66
from pip._internal.build_env import BuildEnvironment
77
from pip._internal.utils.logging import indent_log
@@ -12,7 +12,7 @@
1212

1313

1414
def install_editable(
15-
install_options: List[str],
15+
*,
1616
global_options: Sequence[str],
1717
prefix: Optional[str],
1818
home: Optional[str],
@@ -31,7 +31,6 @@ def install_editable(
3131
args = make_setuptools_develop_args(
3232
setup_py_path,
3333
global_options=global_options,
34-
install_options=install_options,
3534
no_user_config=isolated,
3635
prefix=prefix,
3736
home=home,

src/pip/_internal/operations/install/legacy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def prepend_root(path: str) -> str:
5555

5656

5757
def install(
58-
install_options: List[str],
5958
global_options: Sequence[str],
6059
root: Optional[str],
6160
home: Optional[str],
@@ -79,7 +78,6 @@ def install(
7978
install_args = make_setuptools_install_args(
8079
setup_py_path,
8180
global_options=global_options,
82-
install_options=install_options,
8381
record_filename=record_filename,
8482
root=root,
8583
prefix=prefix,

src/pip/_internal/req/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def _validate_requirements(
3636

3737
def install_given_reqs(
3838
requirements: List[InstallRequirement],
39-
install_options: List[str],
4039
global_options: Sequence[str],
4140
root: Optional[str],
4241
home: Optional[str],
@@ -71,7 +70,6 @@ def install_given_reqs(
7170

7271
try:
7372
requirement.install(
74-
install_options,
7573
global_options,
7674
root=root,
7775
home=home,

src/pip/_internal/req/constructors.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ def install_req_from_editable(
222222
constraint=constraint,
223223
use_pep517=use_pep517,
224224
isolated=isolated,
225-
install_options=options.get("install_options", []) if options else [],
226225
global_options=options.get("global_options", []) if options else [],
227226
hash_options=options.get("hashes", {}) if options else {},
228227
config_settings=config_settings,
@@ -399,7 +398,6 @@ def install_req_from_line(
399398
markers=parts.markers,
400399
use_pep517=use_pep517,
401400
isolated=isolated,
402-
install_options=options.get("install_options", []) if options else [],
403401
global_options=options.get("global_options", []) if options else [],
404402
hash_options=options.get("hashes", {}) if options else {},
405403
config_settings=config_settings,
@@ -493,7 +491,6 @@ def install_req_from_link_and_ireq(
493491
markers=ireq.markers,
494492
use_pep517=ireq.use_pep517,
495493
isolated=ireq.isolated,
496-
install_options=ireq.install_options,
497494
global_options=ireq.global_options,
498495
hash_options=ireq.hash_options,
499496
config_settings=ireq.config_settings,

src/pip/_internal/req/req_file.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969

7070
# options to be passed to requirements
7171
SUPPORTED_OPTIONS_REQ: List[Callable[..., optparse.Option]] = [
72-
cmdoptions.install_options,
7372
cmdoptions.global_options,
7473
cmdoptions.hash,
7574
]

src/pip/_internal/req/req_install.py

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
markers: Optional[Marker] = None,
8484
use_pep517: Optional[bool] = None,
8585
isolated: bool = False,
86-
install_options: Optional[List[str]] = None,
86+
*,
8787
global_options: Optional[List[str]] = None,
8888
hash_options: Optional[Dict[str, List[str]]] = None,
8989
config_settings: Optional[Dict[str, str]] = None,
@@ -146,7 +146,6 @@ def __init__(
146146
# Set to True after successful installation
147147
self.install_succeeded: Optional[bool] = None
148148
# Supplied options
149-
self.install_options = install_options if install_options else []
150149
self.global_options = global_options if global_options else []
151150
self.hash_options = hash_options if hash_options else {}
152151
self.config_settings = config_settings
@@ -746,7 +745,6 @@ def archive(self, build_dir: Optional[str]) -> None:
746745

747746
def install(
748747
self,
749-
install_options: List[str],
750748
global_options: Optional[Sequence[str]] = None,
751749
root: Optional[str] = None,
752750
home: Optional[str] = None,
@@ -767,8 +765,7 @@ def install(
767765
global_options = global_options if global_options is not None else []
768766
if self.editable and not self.is_wheel:
769767
install_editable_legacy(
770-
install_options,
771-
global_options,
768+
global_options=global_options,
772769
prefix=prefix,
773770
home=home,
774771
use_user_site=use_user_site,
@@ -808,13 +805,12 @@ def install(
808805

809806
# TODO: Why don't we do this for editable installs?
810807

811-
# Extend the list of global and install options passed on to
808+
# Extend the list of global options passed on to
812809
# the setup.py call with the ones from the requirements file.
813810
# Options specified in requirements file override those
814811
# specified on the command line, since the last option given
815812
# to setup.py is the one that is used.
816813
global_options = list(global_options) + self.global_options
817-
install_options = list(install_options) + self.install_options
818814

819815
try:
820816
if (
@@ -823,7 +819,6 @@ def install(
823819
):
824820
self.legacy_install_reason.emit_deprecation(self.name)
825821
success = install_legacy(
826-
install_options=install_options,
827822
global_options=global_options,
828823
root=root,
829824
home=home,
@@ -893,15 +888,6 @@ def _has_option(options: Values, reqs: List[InstallRequirement], option: str) ->
893888
return False
894889

895890

896-
def _install_option_ignored(
897-
install_options: List[str], reqs: List[InstallRequirement]
898-
) -> bool:
899-
for req in reqs:
900-
if (install_options or req.install_options) and not req.use_pep517:
901-
return False
902-
return True
903-
904-
905891
class LegacySetupPyOptionsCheckMode(Enum):
906892
INSTALL = 1
907893
WHEEL = 2
@@ -913,34 +899,15 @@ def check_legacy_setup_py_options(
913899
reqs: List[InstallRequirement],
914900
mode: LegacySetupPyOptionsCheckMode,
915901
) -> None:
916-
has_install_options = _has_option(options, reqs, "install_options")
917902
has_build_options = _has_option(options, reqs, "build_options")
918903
has_global_options = _has_option(options, reqs, "global_options")
919-
legacy_setup_py_options_present = (
920-
has_install_options or has_build_options or has_global_options
921-
)
904+
legacy_setup_py_options_present = has_build_options or has_global_options
922905
if not legacy_setup_py_options_present:
923906
return
924907

925908
options.format_control.disallow_binaries()
926909
logger.warning(
927910
"Implying --no-binary=:all: due to the presence of "
928-
"--build-option / --global-option / --install-option. "
911+
"--build-option / --global-option. "
929912
"Consider using --config-settings for more flexibility.",
930913
)
931-
if mode == LegacySetupPyOptionsCheckMode.INSTALL and has_install_options:
932-
if _install_option_ignored(options.install_options, reqs):
933-
logger.warning(
934-
"Ignoring --install-option when building using PEP 517",
935-
)
936-
else:
937-
deprecated(
938-
reason=(
939-
"--install-option is deprecated because "
940-
"it forces pip to use the 'setup.py install' "
941-
"command which is itself deprecated."
942-
),
943-
issue=11358,
944-
replacement="to use --config-settings",
945-
gone_in="23.1",
946-
)

src/pip/_internal/resolution/resolvelib/candidates.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def make_install_req_from_link(
6666
isolated=template.isolated,
6767
constraint=template.constraint,
6868
options=dict(
69-
install_options=template.install_options,
7069
global_options=template.global_options,
7170
hashes=template.hash_options,
7271
),
@@ -90,7 +89,6 @@ def make_install_req_from_editable(
9089
constraint=template.constraint,
9190
permit_editable_wheels=template.permit_editable_wheels,
9291
options=dict(
93-
install_options=template.install_options,
9492
global_options=template.global_options,
9593
hashes=template.hash_options,
9694
),
@@ -115,7 +113,6 @@ def _make_install_req_from_dist(
115113
isolated=template.isolated,
116114
constraint=template.constraint,
117115
options=dict(
118-
install_options=template.install_options,
119116
global_options=template.global_options,
120117
hashes=template.hash_options,
121118
),

0 commit comments

Comments
 (0)