From 7047330b0be9594ddf404618a3fd816f637d4021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sat, 18 Mar 2023 15:26:43 +0100 Subject: [PATCH] Simplify check_legacy_setup_py_options --- src/pip/_internal/commands/download.py | 9 ++------- src/pip/_internal/commands/install.py | 5 +---- src/pip/_internal/commands/wheel.py | 5 +---- src/pip/_internal/req/req_install.py | 25 +++++++------------------ 4 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/pip/_internal/commands/download.py b/src/pip/_internal/commands/download.py index 4132e0898..90388d118 100644 --- a/src/pip/_internal/commands/download.py +++ b/src/pip/_internal/commands/download.py @@ -8,10 +8,7 @@ from pip._internal.cli.cmdoptions import make_target_python 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 ( - LegacySetupPyOptionsCheckMode, - check_legacy_setup_py_options, -) +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 @@ -109,9 +106,7 @@ class DownloadCommand(RequirementCommand): ) reqs = self.get_requirements(args, options, finder, session) - check_legacy_setup_py_options( - options, reqs, LegacySetupPyOptionsCheckMode.DOWNLOAD - ) + 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 41d22c728..4783f807f 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -27,7 +27,6 @@ from pip._internal.operations.check import ConflictDetails, check_install_confli from pip._internal.req import install_given_reqs from pip._internal.req.req_install import ( InstallRequirement, - LegacySetupPyOptionsCheckMode, check_legacy_setup_py_options, ) from pip._internal.utils.compat import WINDOWS @@ -345,9 +344,7 @@ class InstallCommand(RequirementCommand): try: reqs = self.get_requirements(args, options, finder, session) - check_legacy_setup_py_options( - options, reqs, LegacySetupPyOptionsCheckMode.INSTALL - ) + check_legacy_setup_py_options(options, reqs) if "no-binary-enable-wheel-cache" in options.features_enabled: # TODO: remove format_control from WheelCache when the deprecation cycle diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py index 1afbd562c..a8483559c 100644 --- a/src/pip/_internal/commands/wheel.py +++ b/src/pip/_internal/commands/wheel.py @@ -12,7 +12,6 @@ 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, - LegacySetupPyOptionsCheckMode, check_legacy_setup_py_options, ) from pip._internal.utils.deprecation import deprecated @@ -122,9 +121,7 @@ class WheelCommand(RequirementCommand): ) reqs = self.get_requirements(args, options, finder, session) - check_legacy_setup_py_options( - options, reqs, LegacySetupPyOptionsCheckMode.WHEEL - ) + check_legacy_setup_py_options(options, reqs) if "no-binary-enable-wheel-cache" in options.features_enabled: # TODO: remove format_control from WheelCache when the deprecation cycle diff --git a/src/pip/_internal/req/req_install.py b/src/pip/_internal/req/req_install.py index fa5620e1d..9807f690f 100644 --- a/src/pip/_internal/req/req_install.py +++ b/src/pip/_internal/req/req_install.py @@ -8,7 +8,6 @@ import shutil import sys import uuid import zipfile -from enum import Enum from optparse import Values from typing import Any, Collection, Dict, Iterable, List, Optional, Sequence, Union @@ -888,26 +887,16 @@ def _has_option(options: Values, reqs: List[InstallRequirement], option: str) -> return False -class LegacySetupPyOptionsCheckMode(Enum): - INSTALL = 1 - WHEEL = 2 - DOWNLOAD = 3 - - def check_legacy_setup_py_options( options: Values, reqs: List[InstallRequirement], - mode: LegacySetupPyOptionsCheckMode, ) -> None: has_build_options = _has_option(options, reqs, "build_options") has_global_options = _has_option(options, reqs, "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. " - "Consider using --config-settings for more flexibility.", - ) + if has_build_options or has_global_options: + logger.warning( + "Implying --no-binary=:all: due to the presence of " + "--build-option / --global-option. " + "Consider using --config-settings for more flexibility.", + ) + options.format_control.disallow_binaries()