Skip to content

Commit 2008ba1

Browse files
committed
Remove --global-options and --build-option
1 parent 2ba5acc commit 2008ba1

21 files changed

+33
-340
lines changed

docs/html/reference/build-system/setup-py.md

-36
Original file line numberDiff line numberDiff line change
@@ -69,42 +69,6 @@ To support projects that directly use `distutils`, pip injects `setuptools` into
6969
`sys.modules` before invoking `setup.py`. This injection should be transparent
7070
to `distutils`-based projects.
7171

72-
## Customising the build
73-
74-
The `--global-option` and `--build-option` arguments to the `pip install`
75-
and `pip wheel` inject additional arguments into the `setup.py` command
76-
(`--build-option` is only available in `pip wheel`).
77-
78-
```{attention}
79-
The use of `--global-option` and `--build-option` is highly setuptools
80-
specific, and is considered more an accident of the current implementation than
81-
a supported interface. It is documented here for completeness. These flags will
82-
not be supported, once this build system interface is dropped.
83-
```
84-
85-
These arguments are included in the command as follows:
86-
87-
```
88-
python setup.py <global_options> BUILD COMMAND <build_options>
89-
```
90-
91-
The options are passed unmodified, and presently offer direct access to the
92-
distutils command line. For example:
93-
94-
```{pip-cli}
95-
$ pip wheel --global-option bdist_ext --global-option -DFOO wheel
96-
```
97-
98-
will result in pip invoking:
99-
100-
```
101-
setup.py bdist_ext -DFOO bdist_wheel -d TARGET
102-
```
103-
104-
This passes a preprocessor symbol to the extension build.
105-
106-
(build-output)=
107-
10872
## Build Output
10973

11074
Any output produced by the build system will be read by pip (for display to the

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

-28
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}`--global-option <install_--global-option>`
113112
- {ref}`--config-settings <install_--config-settings>`
114113
- `--hash` (for {ref}`Hash-checking mode`)
115114

@@ -150,30 +149,3 @@ You can now store sensitive data (tokens, keys, etc.) in environment variables
150149
and only specify the variable name for your requirements, letting pip lookup
151150
the value at runtime. This approach aligns with the commonly used
152151
[12-factor configuration pattern](https://12factor.net/config).
153-
154-
155-
## Influencing the build system
156-
157-
```{danger}
158-
This disables the use of wheels (cached or otherwise). This could mean that builds will be slower, less deterministic, less reliable and may not behave correctly upon installation.
159-
160-
This mechanism is only preserved for backwards compatibility and should be considered deprecated. A future release of pip may drop these options.
161-
```
162-
163-
The `--global-option` option is used to pass options to `setup.py`.
164-
165-
```{attention}
166-
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.
167-
168-
This is will not work with other build-backends or newer setup.cfg-only projects.
169-
```
170-
171-
If you have a declaration like:
172-
173-
FooProject >= 1.2 --global-option="--no-user-cfg"
174-
175-
The above translates roughly into running FooProject's `setup.py` script as:
176-
177-
python setup.py --no-user-cfg install
178-
179-
Note that the only way of giving more than one option to `setup.py` is through multiple `--global-option` options.

news/12301.removal.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the deprecated ``--global-options`` and ``--build-options`` flags.

src/pip/_internal/cli/cmdoptions.py

-19
Original file line numberDiff line numberDiff line change
@@ -854,25 +854,6 @@ def _handle_config_settings(
854854
"to pass multiple keys to the backend.",
855855
)
856856

857-
build_options: Callable[..., Option] = partial(
858-
Option,
859-
"--build-option",
860-
dest="build_options",
861-
metavar="options",
862-
action="append",
863-
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
864-
)
865-
866-
global_options: Callable[..., Option] = partial(
867-
Option,
868-
"--global-option",
869-
dest="global_options",
870-
action="append",
871-
metavar="options",
872-
help="Extra global options to be supplied to the setup.py "
873-
"call before the install or bdist_wheel command.",
874-
)
875-
876857
no_clean: Callable[..., Option] = partial(
877858
Option,
878859
"--no-clean",

src/pip/_internal/commands/download.py

-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
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 check_legacy_setup_py_options
1211
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
1312
from pip._internal.utils.temp_dir import TempDirectory
1413

@@ -39,7 +38,6 @@ def add_options(self) -> None:
3938
self.cmd_opts.add_option(cmdoptions.constraints())
4039
self.cmd_opts.add_option(cmdoptions.requirements())
4140
self.cmd_opts.add_option(cmdoptions.no_deps())
42-
self.cmd_opts.add_option(cmdoptions.global_options())
4341
self.cmd_opts.add_option(cmdoptions.no_binary())
4442
self.cmd_opts.add_option(cmdoptions.only_binary())
4543
self.cmd_opts.add_option(cmdoptions.prefer_binary())
@@ -105,7 +103,6 @@ def run(self, options: Values, args: List[str]) -> int:
105103
)
106104

107105
reqs = self.get_requirements(args, options, finder, session)
108-
check_legacy_setup_py_options(options, reqs)
109106

110107
preparer = self.make_requirement_preparer(
111108
temp_build_dir=directory,

src/pip/_internal/commands/install.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
from pip._internal.operations.build.build_tracker import get_build_tracker
2626
from pip._internal.operations.check import ConflictDetails, check_install_conflicts
2727
from pip._internal.req import install_given_reqs
28-
from pip._internal.req.req_install import (
29-
InstallRequirement,
30-
check_legacy_setup_py_options,
31-
)
28+
from pip._internal.req.req_install import InstallRequirement
3229
from pip._internal.utils.compat import WINDOWS
3330
from pip._internal.utils.filesystem import test_writable_dir
3431
from pip._internal.utils.logging import getLogger
@@ -200,7 +197,6 @@ def add_options(self) -> None:
200197
self.cmd_opts.add_option(cmdoptions.override_externally_managed())
201198

202199
self.cmd_opts.add_option(cmdoptions.config_settings())
203-
self.cmd_opts.add_option(cmdoptions.global_options())
204200

205201
self.cmd_opts.add_option(
206202
"--compile",
@@ -319,8 +315,6 @@ def run(self, options: Values, args: List[str]) -> int:
319315
target_temp_dir_path = target_temp_dir.path
320316
self.enter_context(target_temp_dir)
321317

322-
global_options = options.global_options or []
323-
324318
session = self.get_default_session(options)
325319

326320
target_python = make_target_python(options)
@@ -340,7 +334,6 @@ def run(self, options: Values, args: List[str]) -> int:
340334

341335
try:
342336
reqs = self.get_requirements(args, options, finder, session)
343-
check_legacy_setup_py_options(options, reqs)
344337

345338
wheel_cache = WheelCache(options.cache_dir)
346339

@@ -421,8 +414,6 @@ def run(self, options: Values, args: List[str]) -> int:
421414
reqs_to_build,
422415
wheel_cache=wheel_cache,
423416
verify=True,
424-
build_options=[],
425-
global_options=global_options,
426417
)
427418

428419
if build_failures:
@@ -451,7 +442,6 @@ def run(self, options: Values, args: List[str]) -> int:
451442

452443
installed = install_given_reqs(
453444
to_install,
454-
global_options,
455445
root=options.root_path,
456446
home=target_temp_dir_path,
457447
prefix=options.prefix_path,

src/pip/_internal/commands/wheel.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
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 (
14-
InstallRequirement,
15-
check_legacy_setup_py_options,
16-
)
13+
from pip._internal.req.req_install import InstallRequirement
1714
from pip._internal.utils.misc import ensure_dir, normalize_path
1815
from pip._internal.utils.temp_dir import TempDirectory
1916
from pip._internal.wheel_builder import build, should_build_for_wheel_command
@@ -77,8 +74,6 @@ def add_options(self) -> None:
7774
)
7875

7976
self.cmd_opts.add_option(cmdoptions.config_settings())
80-
self.cmd_opts.add_option(cmdoptions.build_options())
81-
self.cmd_opts.add_option(cmdoptions.global_options())
8277

8378
self.cmd_opts.add_option(
8479
"--pre",
@@ -118,7 +113,6 @@ def run(self, options: Values, args: List[str]) -> int:
118113
)
119114

120115
reqs = self.get_requirements(args, options, finder, session)
121-
check_legacy_setup_py_options(options, reqs)
122116

123117
wheel_cache = WheelCache(options.cache_dir)
124118

@@ -161,8 +155,6 @@ def run(self, options: Values, args: List[str]) -> int:
161155
reqs_to_build,
162156
wheel_cache=wheel_cache,
163157
verify=(not options.no_verify),
164-
build_options=options.build_options or [],
165-
global_options=options.global_options or [],
166158
)
167159
for req in build_successes:
168160
assert req.link and req.link.is_wheel

src/pip/_internal/operations/build/wheel_legacy.py

-4
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def build_wheel_legacy(
6060
name: str,
6161
setup_py_path: str,
6262
source_dir: str,
63-
global_options: List[str],
64-
build_options: List[str],
6563
tempd: str,
6664
) -> Optional[str]:
6765
"""Build one unpacked package using the "legacy" build process.
@@ -70,8 +68,6 @@ def build_wheel_legacy(
7068
"""
7169
wheel_args = make_setuptools_bdist_wheel_args(
7270
setup_py_path,
73-
global_options=global_options,
74-
build_options=build_options,
7571
destination_dir=tempd,
7672
)
7773

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

+1-3
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 Optional, Sequence
4+
from typing import Optional
55

66
from pip._internal.build_env import BuildEnvironment
77
from pip._internal.utils.logging import indent_log
@@ -13,7 +13,6 @@
1313

1414
def install_editable(
1515
*,
16-
global_options: Sequence[str],
1716
prefix: Optional[str],
1817
home: Optional[str],
1918
use_user_site: bool,
@@ -30,7 +29,6 @@ def install_editable(
3029

3130
args = make_setuptools_develop_args(
3231
setup_py_path,
33-
global_options=global_options,
3432
no_user_config=isolated,
3533
prefix=prefix,
3634
home=home,

src/pip/_internal/req/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import collections
22
import logging
3-
from typing import Generator, List, Optional, Sequence, Tuple
3+
from typing import Generator, List, Optional, Tuple
44

55
from pip._internal.utils.logging import indent_log
66

@@ -36,7 +36,6 @@ def _validate_requirements(
3636

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

7170
try:
7271
requirement.install(
73-
global_options,
7472
root=root,
7573
home=home,
7674
prefix=prefix,

src/pip/_internal/req/constructors.py

-10
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ def install_req_from_editable(
204204
*,
205205
use_pep517: Optional[bool] = None,
206206
isolated: bool = False,
207-
global_options: Optional[List[str]] = None,
208207
hash_options: Optional[Dict[str, List[str]]] = None,
209208
constraint: bool = False,
210209
user_supplied: bool = False,
@@ -223,7 +222,6 @@ def install_req_from_editable(
223222
constraint=constraint,
224223
use_pep517=use_pep517,
225224
isolated=isolated,
226-
global_options=global_options,
227225
hash_options=hash_options,
228226
config_settings=config_settings,
229227
extras=parts.extras,
@@ -379,7 +377,6 @@ def install_req_from_line(
379377
*,
380378
use_pep517: Optional[bool] = None,
381379
isolated: bool = False,
382-
global_options: Optional[List[str]] = None,
383380
hash_options: Optional[Dict[str, List[str]]] = None,
384381
constraint: bool = False,
385382
line_source: Optional[str] = None,
@@ -401,7 +398,6 @@ def install_req_from_line(
401398
markers=parts.markers,
402399
use_pep517=use_pep517,
403400
isolated=isolated,
404-
global_options=global_options,
405401
hash_options=hash_options,
406402
config_settings=config_settings,
407403
constraint=constraint,
@@ -472,11 +468,6 @@ def install_req_from_parsed_requirement(
472468
comes_from=parsed_req.comes_from,
473469
use_pep517=use_pep517,
474470
isolated=isolated,
475-
global_options=(
476-
parsed_req.options.get("global_options", [])
477-
if parsed_req.options
478-
else []
479-
),
480471
hash_options=(
481472
parsed_req.options.get("hashes", {}) if parsed_req.options else {}
482473
),
@@ -499,7 +490,6 @@ def install_req_from_link_and_ireq(
499490
markers=ireq.markers,
500491
use_pep517=ireq.use_pep517,
501492
isolated=ireq.isolated,
502-
global_options=ireq.global_options,
503493
hash_options=ireq.hash_options,
504494
config_settings=ireq.config_settings,
505495
user_supplied=ireq.user_supplied,

src/pip/_internal/req/req_file.py

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070

7171
# options to be passed to requirements
7272
SUPPORTED_OPTIONS_REQ: List[Callable[..., optparse.Option]] = [
73-
cmdoptions.global_options,
7473
cmdoptions.hash,
7574
cmdoptions.config_settings,
7675
]

0 commit comments

Comments
 (0)