diff --git a/docs/html/reference/build-system/setup-py.md b/docs/html/reference/build-system/setup-py.md index 0103a3a6a92..818b94be4a2 100644 --- a/docs/html/reference/build-system/setup-py.md +++ b/docs/html/reference/build-system/setup-py.md @@ -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 BUILD COMMAND -``` - -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 diff --git a/docs/html/reference/requirements-file-format.md b/docs/html/reference/requirements-file-format.md index 01047587161..e9ba85add9e 100644 --- a/docs/html/reference/requirements-file-format.md +++ b/docs/html/reference/requirements-file-format.md @@ -109,7 +109,6 @@ and two {ref}`--find-links ` locations: The options which can be applied to individual requirements are: -- {ref}`--global-option ` - {ref}`--config-settings ` - `--hash` (for {ref}`Hash-checking mode`) @@ -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. diff --git a/news/12301.removal.rst b/news/12301.removal.rst new file mode 100644 index 00000000000..04635cb71a4 --- /dev/null +++ b/news/12301.removal.rst @@ -0,0 +1 @@ +Remove the deprecated ``--global-options`` and ``--build-options`` flags. diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py index 84b40a8fc52..86ac109696a 100644 --- a/src/pip/_internal/cli/cmdoptions.py +++ b/src/pip/_internal/cli/cmdoptions.py @@ -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", diff --git a/src/pip/_internal/commands/download.py b/src/pip/_internal/commands/download.py index 54247a78a65..d6452c67e7c 100644 --- a/src/pip/_internal/commands/download.py +++ b/src/pip/_internal/commands/download.py @@ -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 @@ -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()) @@ -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, diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index f6a300804f4..30f0cbc701d 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -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 @@ -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", @@ -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) @@ -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) @@ -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: @@ -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, diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py index ed578aa2500..831541f95cd 100644 --- a/src/pip/_internal/commands/wheel.py +++ b/src/pip/_internal/commands/wheel.py @@ -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 @@ -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", @@ -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) @@ -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 diff --git a/src/pip/_internal/operations/build/wheel_legacy.py b/src/pip/_internal/operations/build/wheel_legacy.py index c5f0492ccbe..8472dfcda25 100644 --- a/src/pip/_internal/operations/build/wheel_legacy.py +++ b/src/pip/_internal/operations/build/wheel_legacy.py @@ -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. @@ -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, ) diff --git a/src/pip/_internal/operations/install/editable_legacy.py b/src/pip/_internal/operations/install/editable_legacy.py index bebe24e6d3a..250ad0080df 100644 --- a/src/pip/_internal/operations/install/editable_legacy.py +++ b/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 @@ -13,7 +13,6 @@ def install_editable( *, - global_options: Sequence[str], prefix: Optional[str], home: Optional[str], use_user_site: bool, @@ -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, diff --git a/src/pip/_internal/req/__init__.py b/src/pip/_internal/req/__init__.py index 16de903a44c..8acd19f9f34 100644 --- a/src/pip/_internal/req/__init__.py +++ b/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 @@ -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], @@ -70,7 +69,6 @@ def install_given_reqs( try: requirement.install( - global_options, root=root, home=home, prefix=prefix, diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py index c5ca2d85d51..d992917afbc 100644 --- a/src/pip/_internal/req/constructors.py +++ b/src/pip/_internal/req/constructors.py @@ -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, @@ -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, @@ -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, @@ -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, @@ -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 {} ), @@ -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, diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py index f717c1ccc79..7eab20b56e9 100644 --- a/src/pip/_internal/req/req_file.py +++ b/src/pip/_internal/req/req_file.py @@ -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, ] diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index f8957e5d994..3d564a887a2 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -7,7 +7,7 @@ import zipfile from optparse import Values from pathlib import Path -from typing import Any, Collection, Dict, Iterable, List, Optional, Sequence, Union +from typing import Any, Collection, Dict, Iterable, List, Optional, Union from pip._vendor.packaging.markers import Marker from pip._vendor.packaging.requirements import Requirement @@ -78,7 +78,6 @@ def __init__( use_pep517: Optional[bool] = None, isolated: bool = False, *, - global_options: Optional[List[str]] = None, hash_options: Optional[Dict[str, List[str]]] = None, config_settings: Optional[Dict[str, Union[str, List[str]]]] = None, constraint: bool = False, @@ -145,7 +144,6 @@ def __init__( # Set to True after successful installation self.install_succeeded: Optional[bool] = None # Supplied options - self.global_options = global_options if global_options else [] self.hash_options = hash_options if hash_options else {} self.config_settings = config_settings # Set to True after successful preparation of this requirement @@ -807,7 +805,6 @@ def archive(self, build_dir: Optional[str]) -> None: def install( self, - global_options: Optional[Sequence[str]] = None, root: Optional[str] = None, home: Optional[str] = None, prefix: Optional[str] = None, @@ -827,7 +824,6 @@ def install( if self.editable and not self.is_wheel: install_editable_legacy( - global_options=global_options if global_options is not None else [], prefix=prefix, home=home, use_user_site=use_user_site, @@ -891,23 +887,3 @@ def _has_option(options: Values, reqs: List[InstallRequirement], option: str) -> if getattr(req, option, None): return True return False - - -def check_legacy_setup_py_options( - options: Values, - reqs: List[InstallRequirement], -) -> None: - has_build_options = _has_option(options, reqs, "build_options") - has_global_options = _has_option(options, reqs, "global_options") - if has_build_options or has_global_options: - deprecated( - reason="--build-option and --global-option are deprecated.", - issue=11859, - replacement="to use --config-settings", - gone_in="23.3", - ) - logger.warning( - "Implying --no-binary=:all: due to the presence of " - "--build-option / --global-option. " - ) - options.format_control.disallow_binaries() diff --git a/src/pip/_internal/resolution/resolvelib/candidates.py b/src/pip/_internal/resolution/resolvelib/candidates.py index 67737a5092f..aaf735ccf55 100644 --- a/src/pip/_internal/resolution/resolvelib/candidates.py +++ b/src/pip/_internal/resolution/resolvelib/candidates.py @@ -65,7 +65,6 @@ def make_install_req_from_link( use_pep517=template.use_pep517, isolated=template.isolated, constraint=template.constraint, - global_options=template.global_options, hash_options=template.hash_options, config_settings=template.config_settings, ) @@ -87,7 +86,6 @@ def make_install_req_from_editable( isolated=template.isolated, constraint=template.constraint, permit_editable_wheels=template.permit_editable_wheels, - global_options=template.global_options, hash_options=template.hash_options, config_settings=template.config_settings, ) @@ -111,7 +109,6 @@ def _make_install_req_from_dist( use_pep517=template.use_pep517, isolated=template.isolated, constraint=template.constraint, - global_options=template.global_options, hash_options=template.hash_options, config_settings=template.config_settings, ) diff --git a/src/pip/_internal/utils/setuptools_build.py b/src/pip/_internal/utils/setuptools_build.py index 96d1b246067..880b6d504f6 100644 --- a/src/pip/_internal/utils/setuptools_build.py +++ b/src/pip/_internal/utils/setuptools_build.py @@ -1,6 +1,6 @@ import sys import textwrap -from typing import List, Optional, Sequence +from typing import List, Optional # Shim to wrap setup.py invocation with setuptools # Note that __file__ is handled via two {!r} *and* %r, to ensure that paths on @@ -48,7 +48,6 @@ def make_setuptools_shim_args( setup_py_path: str, - global_options: Optional[Sequence[str]] = None, no_user_config: bool = False, unbuffered_output: bool = False, ) -> List[str]: @@ -56,7 +55,6 @@ def make_setuptools_shim_args( Get setuptools command arguments with shim wrapped setup file invocation. :param setup_py_path: The path to setup.py to be wrapped. - :param global_options: Additional global options. :param no_user_config: If True, disables personal user configuration. :param unbuffered_output: If True, adds the unbuffered switch to the argument list. @@ -65,8 +63,6 @@ def make_setuptools_shim_args( if unbuffered_output: args += ["-u"] args += ["-c", _SETUPTOOLS_SHIM.format(setup_py_path)] - if global_options: - args += global_options if no_user_config: args += ["--no-user-cfg"] return args @@ -74,29 +70,19 @@ def make_setuptools_shim_args( def make_setuptools_bdist_wheel_args( setup_py_path: str, - global_options: Sequence[str], - build_options: Sequence[str], destination_dir: str, ) -> List[str]: # NOTE: Eventually, we'd want to also -S to the flags here, when we're # isolating. Currently, it breaks Python in virtualenvs, because it # relies on site.py to find parts of the standard library outside the # virtualenv. - args = make_setuptools_shim_args( - setup_py_path, global_options=global_options, unbuffered_output=True - ) + args = make_setuptools_shim_args(setup_py_path, unbuffered_output=True) args += ["bdist_wheel", "-d", destination_dir] - args += build_options return args -def make_setuptools_clean_args( - setup_py_path: str, - global_options: Sequence[str], -) -> List[str]: - args = make_setuptools_shim_args( - setup_py_path, global_options=global_options, unbuffered_output=True - ) +def make_setuptools_clean_args(setup_py_path: str) -> List[str]: + args = make_setuptools_shim_args(setup_py_path, unbuffered_output=True) args += ["clean", "--all"] return args @@ -104,7 +90,6 @@ def make_setuptools_clean_args( def make_setuptools_develop_args( setup_py_path: str, *, - global_options: Sequence[str], no_user_config: bool, prefix: Optional[str], home: Optional[str], @@ -114,7 +99,6 @@ def make_setuptools_develop_args( args = make_setuptools_shim_args( setup_py_path, - global_options=global_options, no_user_config=no_user_config, ) diff --git a/src/pip/_internal/wheel_builder.py b/src/pip/_internal/wheel_builder.py index 60d75dd18ef..0255d4fa61f 100644 --- a/src/pip/_internal/wheel_builder.py +++ b/src/pip/_internal/wheel_builder.py @@ -169,8 +169,6 @@ def _build_one( req: InstallRequirement, output_dir: str, verify: bool, - build_options: List[str], - global_options: List[str], editable: bool, ) -> Optional[str]: """Build one wheel. @@ -191,9 +189,7 @@ def _build_one( # Install build deps into temporary directory (PEP 518) with req.build_env: - wheel_path = _build_one_inside_env( - req, output_dir, build_options, global_options, editable - ) + wheel_path = _build_one_inside_env(req, output_dir, editable) if wheel_path and verify: try: _verify_one(req, wheel_path) @@ -206,8 +202,6 @@ def _build_one( def _build_one_inside_env( req: InstallRequirement, output_dir: str, - build_options: List[str], - global_options: List[str], editable: bool, ) -> Optional[str]: with TempDirectory(kind="wheel") as temp_dir: @@ -215,14 +209,6 @@ def _build_one_inside_env( if req.use_pep517: assert req.metadata_directory assert req.pep517_backend - if global_options: - logger.warning( - "Ignoring --global-option when building %s using PEP 517", req.name - ) - if build_options: - logger.warning( - "Ignoring --build-option when building %s using PEP 517", req.name - ) if editable: wheel_path = build_wheel_editable( name=req.name, @@ -242,8 +228,6 @@ def _build_one_inside_env( name=req.name, setup_py_path=req.setup_py_path, source_dir=req.unpacked_source_directory, - global_options=global_options, - build_options=build_options, tempd=temp_dir.path, ) @@ -270,15 +254,12 @@ def _build_one_inside_env( ) # Ignore return, we can't do anything else useful. if not req.use_pep517: - _clean_one_legacy(req, global_options) + _clean_one_legacy(req) return None -def _clean_one_legacy(req: InstallRequirement, global_options: List[str]) -> bool: - clean_args = make_setuptools_clean_args( - req.setup_py_path, - global_options=global_options, - ) +def _clean_one_legacy(req: InstallRequirement) -> bool: + clean_args = make_setuptools_clean_args(req.setup_py_path) logger.info("Running setup.py clean for %s", req.name) try: @@ -295,8 +276,6 @@ def build( requirements: Iterable[InstallRequirement], wheel_cache: WheelCache, verify: bool, - build_options: List[str], - global_options: List[str], ) -> BuildResult: """Build wheels. @@ -321,8 +300,6 @@ def build( req, cache_dir, verify, - build_options, - global_options, req.editable and req.permit_editable_wheels, ) if wheel_file: diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index bf051294338..67acfe0ce95 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -982,24 +982,6 @@ def test_install_pardir(script: PipTestEnvironment, data: TestData) -> None: result.did_create(dist_info_folder) -@pytest.mark.network -def test_install_global_option(script: PipTestEnvironment) -> None: - """ - Test using global distutils options. - (In particular those that disable the actual install action) - """ - result = script.pip( - "install", - "--global-option=--version", - "INITools==0.1", - expect_error=True, # build is going to fail because of --version - ) - assert "INITools==0.1\n" in result.stdout - assert not result.files_created - assert "Implying --no-binary=:all:" in result.stderr - assert "A possible replacement is to use --config-settings" in result.stderr - - def test_install_with_hacked_egg_info( script: PipTestEnvironment, data: TestData ) -> None: @@ -1011,26 +993,6 @@ def test_install_with_hacked_egg_info( assert "Successfully installed hackedegginfo-0.0.0\n" in result.stdout -@pytest.mark.xfail -@pytest.mark.network -@need_mercurial -def test_install_global_option_using_editable( - script: PipTestEnvironment, tmpdir: Path -) -> None: - """ - Test using global distutils options, but in an editable installation - """ - url = "hg+http://bitbucket.org/runeh/anyjson" - result = script.pip( - "install", - "--global-option=--version", - "-e", - f"{local_checkout(url, tmpdir)}@0.2.5#egg=anyjson", - expect_stderr=True, - ) - assert "Successfully installed anyjson" in result.stdout - - @pytest.mark.network def test_install_package_with_same_name_in_curdir(script: PipTestEnvironment) -> None: """ @@ -1662,16 +1624,21 @@ def test_install_subprocess_output_handling( # If the install fails, then we *should* show the output... but only once, # even if --verbose is given. - result = script.pip(*(args + ["--global-option=--fail"]), expect_error=True) - # This error is emitted 3 times: - # - by setup.py bdist_wheel - # - by setup.py clean - assert 2 == result.stderr.count("I DIE, I DIE") + result = script.pip( + *(args + ["--use-pep517", "-C", "--global-option=--fail"]), + expect_error=True, + ) + # This error is emitted by setup.py bdist_wheel + assert 1 == result.stderr.count("I DIE, I DIE") result = script.pip( - *(args + ["--global-option=--fail", "--verbose"]), expect_error=True + *( + args + + ["--use-pep517", "-C", "--global-option=--fail", "--verbose"] + ), + expect_error=True, ) - assert 2 == result.stderr.count("I DIE, I DIE") + assert 1 == result.stderr.count("I DIE, I DIE") def test_install_log(script: PipTestEnvironment, data: TestData, tmpdir: Path) -> None: diff --git a/tests/functional/test_install_vcs_git.py b/tests/functional/test_install_vcs_git.py index 2abc7aa0fd2..f12e04cbdb1 100644 --- a/tests/functional/test_install_vcs_git.py +++ b/tests/functional/test_install_vcs_git.py @@ -353,7 +353,6 @@ def test_git_with_tag_name_and_update(script: PipTestEnvironment, tmpdir: Path) new_local_url = f"{base_local_url}@0.1.2#egg=pip-test-package" result = script.pip( "install", - "--global-option=--version", "-e", new_local_url, allow_stderr_warning=True, @@ -392,7 +391,6 @@ def test_git_with_non_editable_unpacking( ) result = script.pip( "install", - "--global-option=--quiet", local_url, allow_stderr_warning=True, ) diff --git a/tests/functional/test_pep517.py b/tests/functional/test_pep517.py index a642a3f8bfb..c949e3bfacc 100644 --- a/tests/functional/test_pep517.py +++ b/tests/functional/test_pep517.py @@ -2,7 +2,6 @@ from pathlib import Path from typing import Any, Dict, List, Optional, Tuple -import pytest import tomli_w from pip._internal.build_env import BuildEnvironment @@ -380,45 +379,3 @@ def test_explicit_setuptools_backend( project_dir, ) result.assert_installed(name, editable=False) - - -@pytest.mark.network -def test_pep517_and_build_options( - script: PipTestEnvironment, tmpdir: Path, data: TestData, common_wheels: Path -) -> None: - """Backend generated requirements are installed in the build env""" - project_dir, name = make_pyproject_with_setup(tmpdir) - result = script.pip( - "wheel", - "--wheel-dir", - tmpdir, - "--build-option", - "foo", - "-f", - common_wheels, - project_dir, - allow_stderr_warning=True, - ) - assert "Ignoring --build-option when building" in result.stderr - assert "using PEP 517" in result.stderr - - -@pytest.mark.network -def test_pep517_and_global_options( - script: PipTestEnvironment, tmpdir: Path, data: TestData, common_wheels: Path -) -> None: - """Backend generated requirements are installed in the build env""" - project_dir, name = make_pyproject_with_setup(tmpdir) - result = script.pip( - "wheel", - "--wheel-dir", - tmpdir, - "--global-option", - "foo", - "-f", - common_wheels, - project_dir, - allow_stderr_warning=True, - ) - assert "Ignoring --global-option when building" in result.stderr - assert "using PEP 517" in result.stderr diff --git a/tests/unit/test_req_file.py b/tests/unit/test_req_file.py index 439c41563b7..039a4171ab9 100644 --- a/tests/unit/test_req_file.py +++ b/tests/unit/test_req_file.py @@ -27,7 +27,7 @@ preprocess, ) from pip._internal.req.req_install import InstallRequirement -from tests.lib import TestData, make_test_finder, requirements_file +from tests.lib import TestData, make_test_finder if TYPE_CHECKING: from typing import Protocol @@ -350,13 +350,14 @@ def test_nested_constraints_file( def test_options_on_a_requirement_line(self, line_processor: LineProcessor) -> None: line = ( - 'SomeProject --global-option="yo3" --global-option "yo4" ' - '--config-settings="yo3=yo4" --config-settings "yo1=yo2"' + "SomeProject" + ' --config-settings="yo3=yo4"' + ' --config-settings "yo1=yo2"' + ' --config-settings "yo1=yo2.1"' ) filename = "filename" req = line_processor(line, filename, 1)[0] - assert req.global_options == ["yo3", "yo4"] - assert req.config_settings == {"yo3": "yo4", "yo1": "yo2"} + assert req.config_settings == {"yo3": "yo4", "yo1": ["yo2", "yo2.1"]} def test_hash_options(self, line_processor: LineProcessor) -> None: """Test the --hash option: mostly its value storage. @@ -865,28 +866,3 @@ def test_req_file_no_finder(self, tmpdir: Path) -> None: ) parse_reqfile(tmpdir.joinpath("req.txt"), session=PipSession()) - - def test_install_requirements_with_options( - self, - tmpdir: Path, - finder: PackageFinder, - session: PipSession, - options: mock.Mock, - ) -> None: - global_option = "--dry-run" - - content = """ - --only-binary :all: - INITools==2.0 --global-option="{global_option}" - """.format( - global_option=global_option - ) - - with requirements_file(content, tmpdir) as reqs_file: - req = next( - parse_reqfile( - reqs_file.resolve(), finder=finder, options=options, session=session - ) - ) - - assert req.global_options == [global_option] diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index d3b0d32d12f..2e388c09854 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -948,13 +948,12 @@ def test_make_setuptools_shim_args() -> None: # Test all arguments at once, including the overall ordering. args = make_setuptools_shim_args( "/dir/path/setup.py", - global_options=["--some", "--option"], no_user_config=True, unbuffered_output=True, ) assert args[1:3] == ["-u", "-c"] - assert args[4:] == ["--some", "--option", "--no-user-cfg"] + assert args[4:] == ["--no-user-cfg"] shim = args[3] # Spot-check key aspects of the command string. @@ -963,23 +962,6 @@ def test_make_setuptools_shim_args() -> None: assert "sys.argv[0] = __file__" in args[3] -@pytest.mark.parametrize("global_options", [None, [], ["--some", "--option"]]) -def test_make_setuptools_shim_args__global_options( - global_options: Optional[List[str]], -) -> None: - args = make_setuptools_shim_args( - "/dir/path/setup.py", - global_options=global_options, - ) - - if global_options: - assert len(args) == 5 - for option in global_options: - assert option in args - else: - assert len(args) == 3 - - @pytest.mark.parametrize("no_user_config", [False, True]) def test_make_setuptools_shim_args__no_user_config(no_user_config: bool) -> None: args = make_setuptools_shim_args(