Skip to content

Commit

Permalink
Remove --global-options and --build-option
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Sep 30, 2023
1 parent 2ba5acc commit 2be580c
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 339 deletions.
34 changes: 0 additions & 34 deletions docs/html/reference/build-system/setup-py.md
Expand Up @@ -69,40 +69,6 @@ To support projects that directly use `distutils`, pip injects `setuptools` into
`sys.modules` before invoking `setup.py`. This injection should be transparent
to `distutils`-based projects.

## Customising the build

The `--global-option` and `--build-option` arguments to the `pip install`
and `pip wheel` inject additional arguments into the `setup.py` command
(`--build-option` is only available in `pip wheel`).

```{attention}
The use of `--global-option` and `--build-option` is highly setuptools
specific, and is considered more an accident of the current implementation than
a supported interface. It is documented here for completeness. These flags will
not be supported, once this build system interface is dropped.
```

These arguments are included in the command as follows:

```
python setup.py <global_options> BUILD COMMAND <build_options>
```

The options are passed unmodified, and presently offer direct access to the
distutils command line. For example:

```{pip-cli}
$ pip wheel --global-option bdist_ext --global-option -DFOO wheel
```

will result in pip invoking:

```
setup.py bdist_ext -DFOO bdist_wheel -d TARGET
```

This passes a preprocessor symbol to the extension build.

(build-output)=

## Build Output
Expand Down
28 changes: 0 additions & 28 deletions docs/html/reference/requirements-file-format.md
Expand Up @@ -109,7 +109,6 @@ and two {ref}`--find-links <install_--find-links>` locations:

The options which can be applied to individual requirements are:

- {ref}`--global-option <install_--global-option>`
- {ref}`--config-settings <install_--config-settings>`
- `--hash` (for {ref}`Hash-checking mode`)

Expand Down Expand Up @@ -150,30 +149,3 @@ You can now store sensitive data (tokens, keys, etc.) in environment variables
and only specify the variable name for your requirements, letting pip lookup
the value at runtime. This approach aligns with the commonly used
[12-factor configuration pattern](https://12factor.net/config).


## Influencing the build system

```{danger}
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.
This mechanism is only preserved for backwards compatibility and should be considered deprecated. A future release of pip may drop these options.
```

The `--global-option` option is used to pass options to `setup.py`.

```{attention}
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.
This is will not work with other build-backends or newer setup.cfg-only projects.
```

If you have a declaration like:

FooProject >= 1.2 --global-option="--no-user-cfg"

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

python setup.py --no-user-cfg install

Note that the only way of giving more than one option to `setup.py` is through multiple `--global-option` options.
1 change: 1 addition & 0 deletions news/12301.removal.rst
@@ -0,0 +1 @@
Remove the deprecated ``--global-options`` and ``--build-options`` flags.
19 changes: 0 additions & 19 deletions src/pip/_internal/cli/cmdoptions.py
Expand Up @@ -854,25 +854,6 @@ def _handle_config_settings(
"to pass multiple keys to the backend.",
)

build_options: Callable[..., Option] = partial(
Option,
"--build-option",
dest="build_options",
metavar="options",
action="append",
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
)

global_options: Callable[..., Option] = partial(
Option,
"--global-option",
dest="global_options",
action="append",
metavar="options",
help="Extra global options to be supplied to the setup.py "
"call before the install or bdist_wheel command.",
)

no_clean: Callable[..., Option] = partial(
Option,
"--no-clean",
Expand Down
3 changes: 0 additions & 3 deletions src/pip/_internal/commands/download.py
Expand Up @@ -8,7 +8,6 @@
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
from pip._internal.cli.status_codes import SUCCESS
from pip._internal.operations.build.build_tracker import get_build_tracker
from pip._internal.req.req_install import check_legacy_setup_py_options
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
from pip._internal.utils.temp_dir import TempDirectory

Expand Down Expand Up @@ -39,7 +38,6 @@ def add_options(self) -> None:
self.cmd_opts.add_option(cmdoptions.constraints())
self.cmd_opts.add_option(cmdoptions.requirements())
self.cmd_opts.add_option(cmdoptions.no_deps())
self.cmd_opts.add_option(cmdoptions.global_options())
self.cmd_opts.add_option(cmdoptions.no_binary())
self.cmd_opts.add_option(cmdoptions.only_binary())
self.cmd_opts.add_option(cmdoptions.prefer_binary())
Expand Down Expand Up @@ -105,7 +103,6 @@ def run(self, options: Values, args: List[str]) -> int:
)

reqs = self.get_requirements(args, options, finder, session)
check_legacy_setup_py_options(options, reqs)

preparer = self.make_requirement_preparer(
temp_build_dir=directory,
Expand Down
12 changes: 1 addition & 11 deletions src/pip/_internal/commands/install.py
Expand Up @@ -25,10 +25,7 @@
from pip._internal.operations.build.build_tracker import get_build_tracker
from pip._internal.operations.check import ConflictDetails, check_install_conflicts
from pip._internal.req import install_given_reqs
from pip._internal.req.req_install import (
InstallRequirement,
check_legacy_setup_py_options,
)
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.compat import WINDOWS
from pip._internal.utils.filesystem import test_writable_dir
from pip._internal.utils.logging import getLogger
Expand Down Expand Up @@ -200,7 +197,6 @@ def add_options(self) -> None:
self.cmd_opts.add_option(cmdoptions.override_externally_managed())

self.cmd_opts.add_option(cmdoptions.config_settings())
self.cmd_opts.add_option(cmdoptions.global_options())

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

global_options = options.global_options or []

session = self.get_default_session(options)

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

try:
reqs = self.get_requirements(args, options, finder, session)
check_legacy_setup_py_options(options, reqs)

wheel_cache = WheelCache(options.cache_dir)

Expand Down Expand Up @@ -421,8 +414,6 @@ def run(self, options: Values, args: List[str]) -> int:
reqs_to_build,
wheel_cache=wheel_cache,
verify=True,
build_options=[],
global_options=global_options,
)

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

installed = install_given_reqs(
to_install,
global_options,
root=options.root_path,
home=target_temp_dir_path,
prefix=options.prefix_path,
Expand Down
10 changes: 1 addition & 9 deletions src/pip/_internal/commands/wheel.py
Expand Up @@ -10,10 +10,7 @@
from pip._internal.cli.status_codes import SUCCESS
from pip._internal.exceptions import CommandError
from pip._internal.operations.build.build_tracker import get_build_tracker
from pip._internal.req.req_install import (
InstallRequirement,
check_legacy_setup_py_options,
)
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.misc import ensure_dir, normalize_path
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.wheel_builder import build, should_build_for_wheel_command
Expand Down Expand Up @@ -77,8 +74,6 @@ def add_options(self) -> None:
)

self.cmd_opts.add_option(cmdoptions.config_settings())
self.cmd_opts.add_option(cmdoptions.build_options())
self.cmd_opts.add_option(cmdoptions.global_options())

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

reqs = self.get_requirements(args, options, finder, session)
check_legacy_setup_py_options(options, reqs)

wheel_cache = WheelCache(options.cache_dir)

Expand Down Expand Up @@ -161,8 +155,6 @@ def run(self, options: Values, args: List[str]) -> int:
reqs_to_build,
wheel_cache=wheel_cache,
verify=(not options.no_verify),
build_options=options.build_options or [],
global_options=options.global_options or [],
)
for req in build_successes:
assert req.link and req.link.is_wheel
Expand Down
4 changes: 0 additions & 4 deletions src/pip/_internal/operations/build/wheel_legacy.py
Expand Up @@ -60,8 +60,6 @@ def build_wheel_legacy(
name: str,
setup_py_path: str,
source_dir: str,
global_options: List[str],
build_options: List[str],
tempd: str,
) -> Optional[str]:
"""Build one unpacked package using the "legacy" build process.
Expand All @@ -70,8 +68,6 @@ def build_wheel_legacy(
"""
wheel_args = make_setuptools_bdist_wheel_args(
setup_py_path,
global_options=global_options,
build_options=build_options,
destination_dir=tempd,
)

Expand Down
4 changes: 1 addition & 3 deletions src/pip/_internal/operations/install/editable_legacy.py
@@ -1,7 +1,7 @@
"""Legacy editable installation process, i.e. `setup.py develop`.
"""
import logging
from typing import Optional, Sequence
from typing import Optional

from pip._internal.build_env import BuildEnvironment
from pip._internal.utils.logging import indent_log
Expand All @@ -13,7 +13,6 @@

def install_editable(
*,
global_options: Sequence[str],
prefix: Optional[str],
home: Optional[str],
use_user_site: bool,
Expand All @@ -30,7 +29,6 @@ def install_editable(

args = make_setuptools_develop_args(
setup_py_path,
global_options=global_options,
no_user_config=isolated,
prefix=prefix,
home=home,
Expand Down
4 changes: 1 addition & 3 deletions src/pip/_internal/req/__init__.py
@@ -1,6 +1,6 @@
import collections
import logging
from typing import Generator, List, Optional, Sequence, Tuple
from typing import Generator, List, Optional, Tuple

from pip._internal.utils.logging import indent_log

Expand Down Expand Up @@ -36,7 +36,6 @@ def _validate_requirements(

def install_given_reqs(
requirements: List[InstallRequirement],
global_options: Sequence[str],
root: Optional[str],
home: Optional[str],
prefix: Optional[str],
Expand Down Expand Up @@ -70,7 +69,6 @@ def install_given_reqs(

try:
requirement.install(
global_options,
root=root,
home=home,
prefix=prefix,
Expand Down
10 changes: 0 additions & 10 deletions src/pip/_internal/req/constructors.py
Expand Up @@ -204,7 +204,6 @@ def install_req_from_editable(
*,
use_pep517: Optional[bool] = None,
isolated: bool = False,
global_options: Optional[List[str]] = None,
hash_options: Optional[Dict[str, List[str]]] = None,
constraint: bool = False,
user_supplied: bool = False,
Expand All @@ -223,7 +222,6 @@ def install_req_from_editable(
constraint=constraint,
use_pep517=use_pep517,
isolated=isolated,
global_options=global_options,
hash_options=hash_options,
config_settings=config_settings,
extras=parts.extras,
Expand Down Expand Up @@ -379,7 +377,6 @@ def install_req_from_line(
*,
use_pep517: Optional[bool] = None,
isolated: bool = False,
global_options: Optional[List[str]] = None,
hash_options: Optional[Dict[str, List[str]]] = None,
constraint: bool = False,
line_source: Optional[str] = None,
Expand All @@ -401,7 +398,6 @@ def install_req_from_line(
markers=parts.markers,
use_pep517=use_pep517,
isolated=isolated,
global_options=global_options,
hash_options=hash_options,
config_settings=config_settings,
constraint=constraint,
Expand Down Expand Up @@ -472,11 +468,6 @@ def install_req_from_parsed_requirement(
comes_from=parsed_req.comes_from,
use_pep517=use_pep517,
isolated=isolated,
global_options=(
parsed_req.options.get("global_options", [])
if parsed_req.options
else []
),
hash_options=(
parsed_req.options.get("hashes", {}) if parsed_req.options else {}
),
Expand All @@ -499,7 +490,6 @@ def install_req_from_link_and_ireq(
markers=ireq.markers,
use_pep517=ireq.use_pep517,
isolated=ireq.isolated,
global_options=ireq.global_options,
hash_options=ireq.hash_options,
config_settings=ireq.config_settings,
user_supplied=ireq.user_supplied,
Expand Down
1 change: 0 additions & 1 deletion src/pip/_internal/req/req_file.py
Expand Up @@ -70,7 +70,6 @@

# options to be passed to requirements
SUPPORTED_OPTIONS_REQ: List[Callable[..., optparse.Option]] = [
cmdoptions.global_options,
cmdoptions.hash,
cmdoptions.config_settings,
]
Expand Down

0 comments on commit 2be580c

Please sign in to comment.