Skip to content

Commit f860790

Browse files
committed
Remove non PEP 517 code paths
We remove - legacy metadata preparation - legacy wheel build (bdist_wheel) - --global-option and --build-option - --no-use-pep517 - and therefore all setuptools shims --use-pep517 stays as a no-op This commits removes some tests that become irrelevant, but just the minimum so mypy is happy.
1 parent 65297aa commit f860790

27 files changed

+45
-1026
lines changed

src/pip/_internal/cli/cmdoptions.py

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# mypy: strict-optional=False
1212
from __future__ import annotations
1313

14-
import importlib.util
1514
import logging
1615
import os
1716
import pathlib
@@ -184,8 +183,7 @@ class PipOption(Option):
184183
action="store_true",
185184
default=False,
186185
help=(
187-
"Allow pip to only run in a virtual environment; "
188-
"exit with an error otherwise."
186+
"Allow pip to only run in a virtual environment; exit with an error otherwise."
189187
),
190188
)
191189

@@ -851,62 +849,16 @@ def _handle_dependency_group(
851849
dest="check_build_deps",
852850
action="store_true",
853851
default=False,
854-
help="Check the build dependencies when PEP517 is used.",
852+
help="Check the build dependencies.",
855853
)
856854

857855

858-
def _handle_no_use_pep517(
859-
option: Option, opt: str, value: str, parser: OptionParser
860-
) -> None:
861-
"""
862-
Process a value provided for the --no-use-pep517 option.
863-
864-
This is an optparse.Option callback for the no_use_pep517 option.
865-
"""
866-
# Since --no-use-pep517 doesn't accept arguments, the value argument
867-
# will be None if --no-use-pep517 is passed via the command-line.
868-
# However, the value can be non-None if the option is triggered e.g.
869-
# by an environment variable, for example "PIP_NO_USE_PEP517=true".
870-
if value is not None:
871-
msg = """A value was passed for --no-use-pep517,
872-
probably using either the PIP_NO_USE_PEP517 environment variable
873-
or the "no-use-pep517" config file option. Use an appropriate value
874-
of the PIP_USE_PEP517 environment variable or the "use-pep517"
875-
config file option instead.
876-
"""
877-
raise_option_error(parser, option=option, msg=msg)
878-
879-
# If user doesn't wish to use pep517, we check if setuptools is installed
880-
# and raise error if it is not.
881-
packages = ("setuptools",)
882-
if not all(importlib.util.find_spec(package) for package in packages):
883-
msg = (
884-
f"It is not possible to use --no-use-pep517 "
885-
f"without {' and '.join(packages)} installed."
886-
)
887-
raise_option_error(parser, option=option, msg=msg)
888-
889-
# Otherwise, --no-use-pep517 was passed via the command-line.
890-
parser.values.use_pep517 = False
891-
892-
893856
use_pep517: Any = partial(
894857
Option,
895858
"--use-pep517",
896859
dest="use_pep517",
897860
action="store_true",
898-
default=None,
899-
help="Use PEP 517 for building source distributions "
900-
"(use --no-use-pep517 to force legacy behaviour).",
901-
)
902-
903-
no_use_pep517: Any = partial(
904-
Option,
905-
"--no-use-pep517",
906-
dest="use_pep517",
907-
action="callback",
908-
callback=_handle_no_use_pep517,
909-
default=None,
861+
default=True,
910862
help=SUPPRESS_HELP,
911863
)
912864

@@ -939,30 +891,11 @@ def _handle_config_settings(
939891
action="callback",
940892
callback=_handle_config_settings,
941893
metavar="settings",
942-
help="Configuration settings to be passed to the PEP 517 build backend. "
894+
help="Configuration settings to be passed to the build backend. "
943895
"Settings take the form KEY=VALUE. Use multiple --config-settings options "
944896
"to pass multiple keys to the backend.",
945897
)
946898

947-
build_options: Callable[..., Option] = partial(
948-
Option,
949-
"--build-option",
950-
dest="build_options",
951-
metavar="options",
952-
action="append",
953-
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
954-
)
955-
956-
global_options: Callable[..., Option] = partial(
957-
Option,
958-
"--global-option",
959-
dest="global_options",
960-
action="append",
961-
metavar="options",
962-
help="Extra global options to be supplied to the setup.py "
963-
"call before the install or bdist_wheel command.",
964-
)
965-
966899
no_clean: Callable[..., Option] = partial(
967900
Option,
968901
"--no-clean",

src/pip/_internal/cli/req_command.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ def make_resolver(
184184
ignore_requires_python: bool = False,
185185
force_reinstall: bool = False,
186186
upgrade_strategy: str = "to-satisfy-only",
187-
use_pep517: bool | None = None,
188187
py_version_info: tuple[int, ...] | None = None,
189188
) -> BaseResolver:
190189
"""
@@ -193,7 +192,6 @@ def make_resolver(
193192
make_install_req = partial(
194193
install_req_from_req_string,
195194
isolated=options.isolated_mode,
196-
use_pep517=use_pep517,
197195
)
198196
resolver_variant = cls.determine_resolver_variant(options)
199197
# The long import name and duplicated invocation is needed to convince
@@ -264,7 +262,6 @@ def get_requirements(
264262
req,
265263
comes_from=None,
266264
isolated=options.isolated_mode,
267-
use_pep517=options.use_pep517,
268265
user_supplied=True,
269266
config_settings=getattr(options, "config_settings", None),
270267
)
@@ -275,7 +272,6 @@ def get_requirements(
275272
req_to_add = install_req_from_req_string(
276273
req,
277274
isolated=options.isolated_mode,
278-
use_pep517=options.use_pep517,
279275
user_supplied=True,
280276
)
281277
requirements.append(req_to_add)
@@ -285,7 +281,6 @@ def get_requirements(
285281
req,
286282
user_supplied=True,
287283
isolated=options.isolated_mode,
288-
use_pep517=options.use_pep517,
289284
config_settings=getattr(options, "config_settings", None),
290285
)
291286
requirements.append(req_to_add)
@@ -298,7 +293,6 @@ def get_requirements(
298293
req_to_add = install_req_from_parsed_requirement(
299294
parsed_req,
300295
isolated=options.isolated_mode,
301-
use_pep517=options.use_pep517,
302296
user_supplied=True,
303297
config_settings=(
304298
parsed_req.options.get("config_settings")

src/pip/_internal/commands/download.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
88
from pip._internal.cli.status_codes import SUCCESS
99
from pip._internal.operations.build.build_tracker import get_build_tracker
10-
from pip._internal.req.req_install import check_legacy_setup_py_options
1110
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
1211
from pip._internal.utils.temp_dir import TempDirectory
1312

@@ -39,7 +38,6 @@ def add_options(self) -> None:
3938
self.cmd_opts.add_option(cmdoptions.build_constraints())
4039
self.cmd_opts.add_option(cmdoptions.requirements())
4140
self.cmd_opts.add_option(cmdoptions.no_deps())
42-
self.cmd_opts.add_option(cmdoptions.global_options())
4341
self.cmd_opts.add_option(cmdoptions.no_binary())
4442
self.cmd_opts.add_option(cmdoptions.only_binary())
4543
self.cmd_opts.add_option(cmdoptions.prefer_binary())
@@ -49,7 +47,6 @@ def add_options(self) -> None:
4947
self.cmd_opts.add_option(cmdoptions.progress_bar())
5048
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
5149
self.cmd_opts.add_option(cmdoptions.use_pep517())
52-
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
5350
self.cmd_opts.add_option(cmdoptions.check_build_deps())
5451
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
5552

@@ -106,7 +103,6 @@ def run(self, options: Values, args: list[str]) -> int:
106103
)
107104

108105
reqs = self.get_requirements(args, options, finder, session)
109-
check_legacy_setup_py_options(options, reqs)
110106

111107
preparer = self.make_requirement_preparer(
112108
temp_build_dir=directory,
@@ -124,7 +120,6 @@ def run(self, options: Values, args: list[str]) -> int:
124120
finder=finder,
125121
options=options,
126122
ignore_requires_python=options.ignore_requires_python,
127-
use_pep517=options.use_pep517,
128123
py_version_info=options.python_version,
129124
)
130125

src/pip/_internal/commands/install.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from pip._internal.req import install_given_reqs
4242
from pip._internal.req.req_install import (
4343
InstallRequirement,
44-
check_legacy_setup_py_options,
4544
)
4645
from pip._internal.utils.compat import WINDOWS
4746
from pip._internal.utils.filesystem import test_writable_dir
@@ -211,12 +210,10 @@ def add_options(self) -> None:
211210
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
212211
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
213212
self.cmd_opts.add_option(cmdoptions.use_pep517())
214-
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
215213
self.cmd_opts.add_option(cmdoptions.check_build_deps())
216214
self.cmd_opts.add_option(cmdoptions.override_externally_managed())
217215

218216
self.cmd_opts.add_option(cmdoptions.config_settings())
219-
self.cmd_opts.add_option(cmdoptions.global_options())
220217

221218
self.cmd_opts.add_option(
222219
"--compile",
@@ -336,8 +333,6 @@ def run(self, options: Values, args: list[str]) -> int:
336333
target_temp_dir_path = target_temp_dir.path
337334
self.enter_context(target_temp_dir)
338335

339-
global_options = options.global_options or []
340-
341336
session = self.get_default_session(options)
342337

343338
target_python = make_target_python(options)
@@ -357,7 +352,6 @@ def run(self, options: Values, args: list[str]) -> int:
357352

358353
try:
359354
reqs = self.get_requirements(args, options, finder, session)
360-
check_legacy_setup_py_options(options, reqs)
361355

362356
wheel_cache = WheelCache(options.cache_dir)
363357

@@ -386,7 +380,6 @@ def run(self, options: Values, args: list[str]) -> int:
386380
ignore_requires_python=options.ignore_requires_python,
387381
force_reinstall=options.force_reinstall,
388382
upgrade_strategy=upgrade_strategy,
389-
use_pep517=options.use_pep517,
390383
py_version_info=options.python_version,
391384
)
392385

@@ -441,8 +434,6 @@ def run(self, options: Values, args: list[str]) -> int:
441434
reqs_to_build,
442435
wheel_cache=wheel_cache,
443436
verify=True,
444-
build_options=[],
445-
global_options=global_options,
446437
)
447438

448439
if build_failures:
@@ -466,7 +457,6 @@ def run(self, options: Values, args: list[str]) -> int:
466457

467458
installed = install_given_reqs(
468459
to_install,
469-
global_options,
470460
root=options.root_path,
471461
home=target_temp_dir_path,
472462
prefix=options.prefix_path,

src/pip/_internal/commands/lock.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
from pip._internal.cli.status_codes import SUCCESS
1212
from pip._internal.models.pylock import Pylock, is_valid_pylock_file_name
1313
from pip._internal.operations.build.build_tracker import get_build_tracker
14-
from pip._internal.req.req_install import (
15-
check_legacy_setup_py_options,
16-
)
1714
from pip._internal.utils.logging import getLogger
1815
from pip._internal.utils.misc import (
1916
get_pip_version,
@@ -70,7 +67,6 @@ def add_options(self) -> None:
7067
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
7168
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
7269
self.cmd_opts.add_option(cmdoptions.use_pep517())
73-
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
7470
self.cmd_opts.add_option(cmdoptions.check_build_deps())
7571

7672
self.cmd_opts.add_option(cmdoptions.config_settings())
@@ -117,7 +113,6 @@ def run(self, options: Values, args: list[str]) -> int:
117113
)
118114

119115
reqs = self.get_requirements(args, options, finder, session)
120-
check_legacy_setup_py_options(options, reqs)
121116

122117
wheel_cache = WheelCache(options.cache_dir)
123118

@@ -145,7 +140,6 @@ def run(self, options: Values, args: list[str]) -> int:
145140
ignore_installed=True,
146141
ignore_requires_python=options.ignore_requires_python,
147142
upgrade_strategy="to-satisfy-only",
148-
use_pep517=options.use_pep517,
149143
)
150144

151145
self.trace_basic_info(finder)

src/pip/_internal/commands/wheel.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from pip._internal.operations.build.build_tracker import get_build_tracker
1212
from pip._internal.req.req_install import (
1313
InstallRequirement,
14-
check_legacy_setup_py_options,
1514
)
1615
from pip._internal.utils.misc import ensure_dir, normalize_path
1716
from pip._internal.utils.temp_dir import TempDirectory
@@ -57,7 +56,6 @@ def add_options(self) -> None:
5756
self.cmd_opts.add_option(cmdoptions.prefer_binary())
5857
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
5958
self.cmd_opts.add_option(cmdoptions.use_pep517())
60-
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
6159
self.cmd_opts.add_option(cmdoptions.check_build_deps())
6260
self.cmd_opts.add_option(cmdoptions.constraints())
6361
self.cmd_opts.add_option(cmdoptions.build_constraints())
@@ -77,8 +75,6 @@ def add_options(self) -> None:
7775
)
7876

7977
self.cmd_opts.add_option(cmdoptions.config_settings())
80-
self.cmd_opts.add_option(cmdoptions.build_options())
81-
self.cmd_opts.add_option(cmdoptions.global_options())
8278

8379
self.cmd_opts.add_option(
8480
"--pre",
@@ -120,7 +116,6 @@ def run(self, options: Values, args: list[str]) -> int:
120116
)
121117

122118
reqs = self.get_requirements(args, options, finder, session)
123-
check_legacy_setup_py_options(options, reqs)
124119

125120
wheel_cache = WheelCache(options.cache_dir)
126121

@@ -141,7 +136,6 @@ def run(self, options: Values, args: list[str]) -> int:
141136
options=options,
142137
wheel_cache=wheel_cache,
143138
ignore_requires_python=options.ignore_requires_python,
144-
use_pep517=options.use_pep517,
145139
)
146140

147141
self.trace_basic_info(finder)
@@ -162,8 +156,6 @@ def run(self, options: Values, args: list[str]) -> int:
162156
reqs_to_build,
163157
wheel_cache=wheel_cache,
164158
verify=(not options.no_verify),
165-
build_options=options.build_options or [],
166-
global_options=options.global_options or [],
167159
)
168160
for req in build_successes:
169161
assert req.link and req.link.is_wheel

src/pip/_internal/distributions/sdist.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SourceDistribution(AbstractDistribution):
2020
"""Represents a source distribution.
2121
2222
The preparation step for these needs metadata for the packages to be
23-
generated, either using PEP 517 or using the legacy `setup.py egg_info`.
23+
generated.
2424
"""
2525

2626
@property
@@ -38,12 +38,11 @@ def prepare_distribution_metadata(
3838
build_isolation: bool,
3939
check_build_deps: bool,
4040
) -> None:
41-
# Load pyproject.toml, to determine whether PEP 517 is to be used
41+
# Load pyproject.toml
4242
self.req.load_pyproject_toml()
4343

4444
# Set up the build isolation, if this requirement should be isolated
45-
should_isolate = self.req.use_pep517 and build_isolation
46-
if should_isolate:
45+
if build_isolation:
4746
# Setup an isolated environment and install the build backend static
4847
# requirements in it.
4948
self._prepare_build_backend(build_env_installer)
@@ -58,8 +57,7 @@ def prepare_distribution_metadata(
5857
# Install the dynamic build requirements.
5958
self._install_build_reqs(build_env_installer)
6059
# Check if the current environment provides build dependencies
61-
should_check_deps = self.req.use_pep517 and check_build_deps
62-
if should_check_deps:
60+
if check_build_deps:
6361
pyproject_requires = self.req.pyproject_requires
6462
assert pyproject_requires is not None
6563
conflicting, missing = self.req.build_env.check_requirements(

0 commit comments

Comments
 (0)