Skip to content

Commit 7047330

Browse files
committed
Simplify check_legacy_setup_py_options
1 parent e798211 commit 7047330

File tree

4 files changed

+11
-33
lines changed

4 files changed

+11
-33
lines changed

src/pip/_internal/commands/download.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
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 (
12-
LegacySetupPyOptionsCheckMode,
13-
check_legacy_setup_py_options,
14-
)
11+
from pip._internal.req.req_install import check_legacy_setup_py_options
1512
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
1613
from pip._internal.utils.temp_dir import TempDirectory
1714

@@ -109,9 +106,7 @@ def run(self, options: Values, args: List[str]) -> int:
109106
)
110107

111108
reqs = self.get_requirements(args, options, finder, session)
112-
check_legacy_setup_py_options(
113-
options, reqs, LegacySetupPyOptionsCheckMode.DOWNLOAD
114-
)
109+
check_legacy_setup_py_options(options, reqs)
115110

116111
preparer = self.make_requirement_preparer(
117112
temp_build_dir=directory,

src/pip/_internal/commands/install.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from pip._internal.req import install_given_reqs
2828
from pip._internal.req.req_install import (
2929
InstallRequirement,
30-
LegacySetupPyOptionsCheckMode,
3130
check_legacy_setup_py_options,
3231
)
3332
from pip._internal.utils.compat import WINDOWS
@@ -345,9 +344,7 @@ def run(self, options: Values, args: List[str]) -> int:
345344

346345
try:
347346
reqs = self.get_requirements(args, options, finder, session)
348-
check_legacy_setup_py_options(
349-
options, reqs, LegacySetupPyOptionsCheckMode.INSTALL
350-
)
347+
check_legacy_setup_py_options(options, reqs)
351348

352349
if "no-binary-enable-wheel-cache" in options.features_enabled:
353350
# TODO: remove format_control from WheelCache when the deprecation cycle

src/pip/_internal/commands/wheel.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from pip._internal.operations.build.build_tracker import get_build_tracker
1313
from pip._internal.req.req_install import (
1414
InstallRequirement,
15-
LegacySetupPyOptionsCheckMode,
1615
check_legacy_setup_py_options,
1716
)
1817
from pip._internal.utils.deprecation import deprecated
@@ -122,9 +121,7 @@ def run(self, options: Values, args: List[str]) -> int:
122121
)
123122

124123
reqs = self.get_requirements(args, options, finder, session)
125-
check_legacy_setup_py_options(
126-
options, reqs, LegacySetupPyOptionsCheckMode.WHEEL
127-
)
124+
check_legacy_setup_py_options(options, reqs)
128125

129126
if "no-binary-enable-wheel-cache" in options.features_enabled:
130127
# TODO: remove format_control from WheelCache when the deprecation cycle

src/pip/_internal/req/req_install.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import sys
99
import uuid
1010
import zipfile
11-
from enum import Enum
1211
from optparse import Values
1312
from typing import Any, Collection, Dict, Iterable, List, Optional, Sequence, Union
1413

@@ -888,26 +887,16 @@ def _has_option(options: Values, reqs: List[InstallRequirement], option: str) ->
888887
return False
889888

890889

891-
class LegacySetupPyOptionsCheckMode(Enum):
892-
INSTALL = 1
893-
WHEEL = 2
894-
DOWNLOAD = 3
895-
896-
897890
def check_legacy_setup_py_options(
898891
options: Values,
899892
reqs: List[InstallRequirement],
900-
mode: LegacySetupPyOptionsCheckMode,
901893
) -> None:
902894
has_build_options = _has_option(options, reqs, "build_options")
903895
has_global_options = _has_option(options, reqs, "global_options")
904-
legacy_setup_py_options_present = has_build_options or has_global_options
905-
if not legacy_setup_py_options_present:
906-
return
907-
908-
options.format_control.disallow_binaries()
909-
logger.warning(
910-
"Implying --no-binary=:all: due to the presence of "
911-
"--build-option / --global-option. "
912-
"Consider using --config-settings for more flexibility.",
913-
)
896+
if has_build_options or has_global_options:
897+
logger.warning(
898+
"Implying --no-binary=:all: due to the presence of "
899+
"--build-option / --global-option. "
900+
"Consider using --config-settings for more flexibility.",
901+
)
902+
options.format_control.disallow_binaries()

0 commit comments

Comments
 (0)