Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated --install-option #11858

Merged
merged 1 commit into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions docs/html/reference/requirements-file-format.md
Original file line number Diff line number Diff line change
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}`--install-option <install_--install-option>`
- {ref}`--global-option <install_--global-option>`
- {ref}`--config-settings <install_--config-settings>`
- `--hash` (for {ref}`Hash-checking mode`)
Expand Down Expand Up @@ -161,7 +160,7 @@ This disables the use of wheels (cached or otherwise). This could mean that buil
This mechanism is only preserved for backwards compatibility and should be considered deprecated. A future release of pip may drop these options.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this PR, there's only one option left (--global-option). Although it might be worth it to document --build-option in this section.

Also, GitHub won't let me comment on the correct line, but there's a warning about disabling the use of wheels above, which should no longer be relevant.

```

The `--global-option` and `--install-option` options are used to pass options to `setup.py`.
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.
Expand All @@ -171,15 +170,10 @@ 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" \
--install-option="--prefix='/usr/local'" \
--install-option="--no-compile"
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 --prefix='/usr/local' --no-compile
python setup.py --no-user-cfg install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this install should be changed to bdist_wheel? I'm assuming that pip won't be using install anymore if --install-option is not used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SpecLad yes, that is correct. I'll take care of this. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, actually that will be for a subsequent PR that removes the setup.py install code path. This one just removes --install-option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that the setup.py install code path still exists, but I think in this example it's reasonable to assume that it won't be used in the absence of --install-option.


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.

# Invalid. Please use '--install-option' twice as shown above.
FooProject >= 1.2 --install-option="--prefix=/usr/local --no-compile"
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/11358.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove support for the deprecated ``--install-options``.
11 changes: 0 additions & 11 deletions src/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,17 +847,6 @@ def _handle_config_settings(
"to pass multiple keys to the backend.",
)

install_options: Callable[..., Option] = partial(
Option,
"--install-option",
dest="install_options",
action="append",
metavar="options",
help="This option is deprecated. Using this option with location-changing "
"options may cause unexpected behavior. "
"Use pip-level options like --user, --prefix, --root, and --target.",
)

build_options: Callable[..., Option] = partial(
Option,
"--build-option",
Expand Down
48 changes: 1 addition & 47 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import shutil
import site
from optparse import SUPPRESS_HELP, Values
from typing import Iterable, List, Optional
from typing import List, Optional

from pip._vendor.rich import print_json

Expand Down Expand Up @@ -35,7 +35,6 @@
LegacyInstallReasonFailedBdistWheel,
deprecated,
)
from pip._internal.utils.distutils_args import parse_distutils_args
from pip._internal.utils.filesystem import test_writable_dir
from pip._internal.utils.logging import getLogger
from pip._internal.utils.misc import (
Expand Down Expand Up @@ -206,7 +205,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.install_options())
self.cmd_opts.add_option(cmdoptions.global_options())

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

cmdoptions.check_dist_restriction(options, check_target=True)

install_options = options.install_options or []

logger.verbose("Using %s", get_pip_version())
options.use_user_site = decide_user_install(
options.use_user_site,
Expand Down Expand Up @@ -378,8 +374,6 @@ def run(self, options: Values, args: List[str]) -> int:
for req in reqs:
req.permit_editable_wheels = True

reject_location_related_install_options(reqs, options.install_options)

preparer = self.make_requirement_preparer(
temp_build_dir=directory,
options=options,
Expand Down Expand Up @@ -490,7 +484,6 @@ def run(self, options: Values, args: List[str]) -> int:

installed = install_given_reqs(
to_install,
install_options,
global_options,
root=options.root_path,
home=target_temp_dir_path,
Expand Down Expand Up @@ -761,45 +754,6 @@ def decide_user_install(
return True


def reject_location_related_install_options(
requirements: List[InstallRequirement], options: Optional[List[str]]
) -> None:
"""If any location-changing --install-option arguments were passed for
requirements or on the command-line, then show a deprecation warning.
"""

def format_options(option_names: Iterable[str]) -> List[str]:
return ["--{}".format(name.replace("_", "-")) for name in option_names]

offenders = []

for requirement in requirements:
install_options = requirement.install_options
location_options = parse_distutils_args(install_options)
if location_options:
offenders.append(
"{!r} from {}".format(
format_options(location_options.keys()), requirement
)
)

if options:
location_options = parse_distutils_args(options)
if location_options:
offenders.append(
"{!r} from command line".format(format_options(location_options.keys()))
)

if not offenders:
return

raise CommandError(
"Location-changing options found in --install-option: {}."
" This is unsupported, use pip-level options like --user,"
" --prefix, --root, and --target instead.".format("; ".join(offenders))
)


def create_os_error_message(
error: OSError, show_traceback: bool, using_user_site: bool
) -> str:
Expand Down
5 changes: 2 additions & 3 deletions src/pip/_internal/operations/install/editable_legacy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Legacy editable installation process, i.e. `setup.py develop`.
"""
import logging
from typing import List, Optional, Sequence
from typing import Optional, Sequence

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


def install_editable(
install_options: List[str],
*,
global_options: Sequence[str],
prefix: Optional[str],
home: Optional[str],
Expand All @@ -31,7 +31,6 @@ def install_editable(
args = make_setuptools_develop_args(
setup_py_path,
global_options=global_options,
install_options=install_options,
no_user_config=isolated,
prefix=prefix,
home=home,
Expand Down
2 changes: 0 additions & 2 deletions src/pip/_internal/operations/install/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def prepend_root(path: str) -> str:


def install(
install_options: List[str],
global_options: Sequence[str],
root: Optional[str],
home: Optional[str],
Expand All @@ -79,7 +78,6 @@ def install(
install_args = make_setuptools_install_args(
setup_py_path,
global_options=global_options,
install_options=install_options,
record_filename=record_filename,
root=root,
prefix=prefix,
Expand Down
2 changes: 0 additions & 2 deletions src/pip/_internal/req/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def _validate_requirements(

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

try:
requirement.install(
install_options,
global_options,
root=root,
home=home,
Expand Down
3 changes: 0 additions & 3 deletions src/pip/_internal/req/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def install_req_from_editable(
constraint=constraint,
use_pep517=use_pep517,
isolated=isolated,
install_options=options.get("install_options", []) if options else [],
global_options=options.get("global_options", []) if options else [],
hash_options=options.get("hashes", {}) if options else {},
config_settings=config_settings,
Expand Down Expand Up @@ -399,7 +398,6 @@ def install_req_from_line(
markers=parts.markers,
use_pep517=use_pep517,
isolated=isolated,
install_options=options.get("install_options", []) if options else [],
global_options=options.get("global_options", []) if options else [],
hash_options=options.get("hashes", {}) if options else {},
config_settings=config_settings,
Expand Down Expand Up @@ -493,7 +491,6 @@ def install_req_from_link_and_ireq(
markers=ireq.markers,
use_pep517=ireq.use_pep517,
isolated=ireq.isolated,
install_options=ireq.install_options,
global_options=ireq.global_options,
hash_options=ireq.hash_options,
config_settings=ireq.config_settings,
Expand Down
1 change: 0 additions & 1 deletion src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@

# options to be passed to requirements
SUPPORTED_OPTIONS_REQ: List[Callable[..., optparse.Option]] = [
cmdoptions.install_options,
cmdoptions.global_options,
cmdoptions.hash,
]
Expand Down
43 changes: 5 additions & 38 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(
markers: Optional[Marker] = None,
use_pep517: Optional[bool] = None,
isolated: bool = False,
install_options: Optional[List[str]] = None,
*,
global_options: Optional[List[str]] = None,
hash_options: Optional[Dict[str, List[str]]] = None,
config_settings: Optional[Dict[str, str]] = None,
Expand Down Expand Up @@ -146,7 +146,6 @@ def __init__(
# Set to True after successful installation
self.install_succeeded: Optional[bool] = None
# Supplied options
self.install_options = install_options if install_options else []
self.global_options = global_options if global_options else []
self.hash_options = hash_options if hash_options else {}
self.config_settings = config_settings
Expand Down Expand Up @@ -746,7 +745,6 @@ def archive(self, build_dir: Optional[str]) -> None:

def install(
self,
install_options: List[str],
global_options: Optional[Sequence[str]] = None,
root: Optional[str] = None,
home: Optional[str] = None,
Expand All @@ -767,8 +765,7 @@ def install(
global_options = global_options if global_options is not None else []
if self.editable and not self.is_wheel:
install_editable_legacy(
install_options,
global_options,
global_options=global_options,
prefix=prefix,
home=home,
use_user_site=use_user_site,
Expand Down Expand Up @@ -808,13 +805,12 @@ def install(

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

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

try:
if (
Expand All @@ -823,7 +819,6 @@ def install(
):
self.legacy_install_reason.emit_deprecation(self.name)
success = install_legacy(
install_options=install_options,
global_options=global_options,
root=root,
home=home,
Expand Down Expand Up @@ -893,15 +888,6 @@ def _has_option(options: Values, reqs: List[InstallRequirement], option: str) ->
return False


def _install_option_ignored(
install_options: List[str], reqs: List[InstallRequirement]
) -> bool:
for req in reqs:
if (install_options or req.install_options) and not req.use_pep517:
return False
return True


class LegacySetupPyOptionsCheckMode(Enum):
INSTALL = 1
WHEEL = 2
Expand All @@ -913,34 +899,15 @@ def check_legacy_setup_py_options(
reqs: List[InstallRequirement],
mode: LegacySetupPyOptionsCheckMode,
) -> None:
has_install_options = _has_option(options, reqs, "install_options")
has_build_options = _has_option(options, reqs, "build_options")
has_global_options = _has_option(options, reqs, "global_options")
legacy_setup_py_options_present = (
has_install_options or has_build_options or has_global_options
)
legacy_setup_py_options_present = has_build_options or has_global_options
if not legacy_setup_py_options_present:
return

options.format_control.disallow_binaries()
logger.warning(
"Implying --no-binary=:all: due to the presence of "
"--build-option / --global-option / --install-option. "
"--build-option / --global-option. "
"Consider using --config-settings for more flexibility.",
)
if mode == LegacySetupPyOptionsCheckMode.INSTALL and has_install_options:
if _install_option_ignored(options.install_options, reqs):
logger.warning(
"Ignoring --install-option when building using PEP 517",
)
else:
deprecated(
reason=(
"--install-option is deprecated because "
"it forces pip to use the 'setup.py install' "
"command which is itself deprecated."
),
issue=11358,
replacement="to use --config-settings",
gone_in="23.1",
)
3 changes: 0 additions & 3 deletions src/pip/_internal/resolution/resolvelib/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def make_install_req_from_link(
isolated=template.isolated,
constraint=template.constraint,
options=dict(
install_options=template.install_options,
global_options=template.global_options,
hashes=template.hash_options,
),
Expand All @@ -90,7 +89,6 @@ def make_install_req_from_editable(
constraint=template.constraint,
permit_editable_wheels=template.permit_editable_wheels,
options=dict(
install_options=template.install_options,
global_options=template.global_options,
hashes=template.hash_options,
),
Expand All @@ -115,7 +113,6 @@ def _make_install_req_from_dist(
isolated=template.isolated,
constraint=template.constraint,
options=dict(
install_options=template.install_options,
global_options=template.global_options,
hashes=template.hash_options,
),
Expand Down
Loading