Skip to content

Commit 768be06

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 3ceab84 commit 768be06

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
@@ -161,8 +160,7 @@ class PipOption(Option):
161160
action="store_true",
162161
default=False,
163162
help=(
164-
"Allow pip to only run in a virtual environment; "
165-
"exit with an error otherwise."
163+
"Allow pip to only run in a virtual environment; exit with an error otherwise."
166164
),
167165
)
168166

@@ -813,62 +811,16 @@ def _handle_dependency_group(
813811
dest="check_build_deps",
814812
action="store_true",
815813
default=False,
816-
help="Check the build dependencies when PEP517 is used.",
814+
help="Check the build dependencies.",
817815
)
818816

819817

820-
def _handle_no_use_pep517(
821-
option: Option, opt: str, value: str, parser: OptionParser
822-
) -> None:
823-
"""
824-
Process a value provided for the --no-use-pep517 option.
825-
826-
This is an optparse.Option callback for the no_use_pep517 option.
827-
"""
828-
# Since --no-use-pep517 doesn't accept arguments, the value argument
829-
# will be None if --no-use-pep517 is passed via the command-line.
830-
# However, the value can be non-None if the option is triggered e.g.
831-
# by an environment variable, for example "PIP_NO_USE_PEP517=true".
832-
if value is not None:
833-
msg = """A value was passed for --no-use-pep517,
834-
probably using either the PIP_NO_USE_PEP517 environment variable
835-
or the "no-use-pep517" config file option. Use an appropriate value
836-
of the PIP_USE_PEP517 environment variable or the "use-pep517"
837-
config file option instead.
838-
"""
839-
raise_option_error(parser, option=option, msg=msg)
840-
841-
# If user doesn't wish to use pep517, we check if setuptools is installed
842-
# and raise error if it is not.
843-
packages = ("setuptools",)
844-
if not all(importlib.util.find_spec(package) for package in packages):
845-
msg = (
846-
f"It is not possible to use --no-use-pep517 "
847-
f"without {' and '.join(packages)} installed."
848-
)
849-
raise_option_error(parser, option=option, msg=msg)
850-
851-
# Otherwise, --no-use-pep517 was passed via the command-line.
852-
parser.values.use_pep517 = False
853-
854-
855818
use_pep517: Any = partial(
856819
Option,
857820
"--use-pep517",
858821
dest="use_pep517",
859822
action="store_true",
860-
default=None,
861-
help="Use PEP 517 for building source distributions "
862-
"(use --no-use-pep517 to force legacy behaviour).",
863-
)
864-
865-
no_use_pep517: Any = partial(
866-
Option,
867-
"--no-use-pep517",
868-
dest="use_pep517",
869-
action="callback",
870-
callback=_handle_no_use_pep517,
871-
default=None,
823+
default=True,
872824
help=SUPPRESS_HELP,
873825
)
874826

@@ -901,30 +853,11 @@ def _handle_config_settings(
901853
action="callback",
902854
callback=_handle_config_settings,
903855
metavar="settings",
904-
help="Configuration settings to be passed to the PEP 517 build backend. "
856+
help="Configuration settings to be passed to the build backend. "
905857
"Settings take the form KEY=VALUE. Use multiple --config-settings options "
906858
"to pass multiple keys to the backend.",
907859
)
908860

909-
build_options: Callable[..., Option] = partial(
910-
Option,
911-
"--build-option",
912-
dest="build_options",
913-
metavar="options",
914-
action="append",
915-
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
916-
)
917-
918-
global_options: Callable[..., Option] = partial(
919-
Option,
920-
"--global-option",
921-
dest="global_options",
922-
action="append",
923-
metavar="options",
924-
help="Extra global options to be supplied to the setup.py "
925-
"call before the install or bdist_wheel command.",
926-
)
927-
928861
no_clean: Callable[..., Option] = partial(
929862
Option,
930863
"--no-clean",

src/pip/_internal/cli/req_command.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def make_resolver(
163163
ignore_requires_python: bool = False,
164164
force_reinstall: bool = False,
165165
upgrade_strategy: str = "to-satisfy-only",
166-
use_pep517: bool | None = None,
167166
py_version_info: tuple[int, ...] | None = None,
168167
) -> BaseResolver:
169168
"""
@@ -172,7 +171,6 @@ def make_resolver(
172171
make_install_req = partial(
173172
install_req_from_req_string,
174173
isolated=options.isolated_mode,
175-
use_pep517=use_pep517,
176174
)
177175
resolver_variant = cls.determine_resolver_variant(options)
178176
# The long import name and duplicated invocation is needed to convince
@@ -241,7 +239,6 @@ def get_requirements(
241239
req,
242240
comes_from=None,
243241
isolated=options.isolated_mode,
244-
use_pep517=options.use_pep517,
245242
user_supplied=True,
246243
config_settings=getattr(options, "config_settings", None),
247244
)
@@ -252,7 +249,6 @@ def get_requirements(
252249
req_to_add = install_req_from_req_string(
253250
req,
254251
isolated=options.isolated_mode,
255-
use_pep517=options.use_pep517,
256252
user_supplied=True,
257253
)
258254
requirements.append(req_to_add)
@@ -262,7 +258,6 @@ def get_requirements(
262258
req,
263259
user_supplied=True,
264260
isolated=options.isolated_mode,
265-
use_pep517=options.use_pep517,
266261
config_settings=getattr(options, "config_settings", None),
267262
)
268263
requirements.append(req_to_add)
@@ -275,7 +270,6 @@ def get_requirements(
275270
req_to_add = install_req_from_parsed_requirement(
276271
parsed_req,
277272
isolated=options.isolated_mode,
278-
use_pep517=options.use_pep517,
279273
user_supplied=True,
280274
config_settings=(
281275
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

@@ -38,7 +37,6 @@ def add_options(self) -> None:
3837
self.cmd_opts.add_option(cmdoptions.constraints())
3938
self.cmd_opts.add_option(cmdoptions.requirements())
4039
self.cmd_opts.add_option(cmdoptions.no_deps())
41-
self.cmd_opts.add_option(cmdoptions.global_options())
4240
self.cmd_opts.add_option(cmdoptions.no_binary())
4341
self.cmd_opts.add_option(cmdoptions.only_binary())
4442
self.cmd_opts.add_option(cmdoptions.prefer_binary())
@@ -48,7 +46,6 @@ def add_options(self) -> None:
4846
self.cmd_opts.add_option(cmdoptions.progress_bar())
4947
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
5048
self.cmd_opts.add_option(cmdoptions.use_pep517())
51-
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
5249
self.cmd_opts.add_option(cmdoptions.check_build_deps())
5350
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
5451

@@ -104,7 +101,6 @@ def run(self, options: Values, args: list[str]) -> int:
104101
)
105102

106103
reqs = self.get_requirements(args, options, finder, session)
107-
check_legacy_setup_py_options(options, reqs)
108104

109105
preparer = self.make_requirement_preparer(
110106
temp_build_dir=directory,
@@ -122,7 +118,6 @@ def run(self, options: Values, args: list[str]) -> int:
122118
finder=finder,
123119
options=options,
124120
ignore_requires_python=options.ignore_requires_python,
125-
use_pep517=options.use_pep517,
126121
py_version_info=options.python_version,
127122
)
128123

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
@@ -210,12 +209,10 @@ def add_options(self) -> None:
210209
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
211210
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
212211
self.cmd_opts.add_option(cmdoptions.use_pep517())
213-
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
214212
self.cmd_opts.add_option(cmdoptions.check_build_deps())
215213
self.cmd_opts.add_option(cmdoptions.override_externally_managed())
216214

217215
self.cmd_opts.add_option(cmdoptions.config_settings())
218-
self.cmd_opts.add_option(cmdoptions.global_options())
219216

220217
self.cmd_opts.add_option(
221218
"--compile",
@@ -334,8 +331,6 @@ def run(self, options: Values, args: list[str]) -> int:
334331
target_temp_dir_path = target_temp_dir.path
335332
self.enter_context(target_temp_dir)
336333

337-
global_options = options.global_options or []
338-
339334
session = self.get_default_session(options)
340335

341336
target_python = make_target_python(options)
@@ -355,7 +350,6 @@ def run(self, options: Values, args: list[str]) -> int:
355350

356351
try:
357352
reqs = self.get_requirements(args, options, finder, session)
358-
check_legacy_setup_py_options(options, reqs)
359353

360354
wheel_cache = WheelCache(options.cache_dir)
361355

@@ -384,7 +378,6 @@ def run(self, options: Values, args: list[str]) -> int:
384378
ignore_requires_python=options.ignore_requires_python,
385379
force_reinstall=options.force_reinstall,
386380
upgrade_strategy=upgrade_strategy,
387-
use_pep517=options.use_pep517,
388381
py_version_info=options.python_version,
389382
)
390383

@@ -432,8 +425,6 @@ def run(self, options: Values, args: list[str]) -> int:
432425
reqs_to_build,
433426
wheel_cache=wheel_cache,
434427
verify=True,
435-
build_options=[],
436-
global_options=global_options,
437428
)
438429

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

458449
installed = install_given_reqs(
459450
to_install,
460-
global_options,
461451
root=options.root_path,
462452
home=target_temp_dir_path,
463453
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,
@@ -69,7 +66,6 @@ def add_options(self) -> None:
6966
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
7067
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
7168
self.cmd_opts.add_option(cmdoptions.use_pep517())
72-
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
7369
self.cmd_opts.add_option(cmdoptions.check_build_deps())
7470

7571
self.cmd_opts.add_option(cmdoptions.config_settings())
@@ -114,7 +110,6 @@ def run(self, options: Values, args: list[str]) -> int:
114110
)
115111

116112
reqs = self.get_requirements(args, options, finder, session)
117-
check_legacy_setup_py_options(options, reqs)
118113

119114
wheel_cache = WheelCache(options.cache_dir)
120115

@@ -142,7 +137,6 @@ def run(self, options: Values, args: list[str]) -> int:
142137
ignore_installed=True,
143138
ignore_requires_python=options.ignore_requires_python,
144139
upgrade_strategy="to-satisfy-only",
145-
use_pep517=options.use_pep517,
146140
)
147141

148142
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.editable())
@@ -76,8 +74,6 @@ def add_options(self) -> None:
7674
)
7775

7876
self.cmd_opts.add_option(cmdoptions.config_settings())
79-
self.cmd_opts.add_option(cmdoptions.build_options())
80-
self.cmd_opts.add_option(cmdoptions.global_options())
8177

8278
self.cmd_opts.add_option(
8379
"--pre",
@@ -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

@@ -138,7 +133,6 @@ def run(self, options: Values, args: list[str]) -> int:
138133
options=options,
139134
wheel_cache=wheel_cache,
140135
ignore_requires_python=options.ignore_requires_python,
141-
use_pep517=options.use_pep517,
142136
)
143137

144138
self.trace_basic_info(finder)
@@ -159,8 +153,6 @@ def run(self, options: Values, args: list[str]) -> int:
159153
reqs_to_build,
160154
wheel_cache=wheel_cache,
161155
verify=(not options.no_verify),
162-
build_options=options.build_options or [],
163-
global_options=options.global_options or [],
164156
)
165157
for req in build_successes:
166158
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)