Skip to content

Commit 295a35b

Browse files
authored
Merge pull request #11874 from sbidoul/drop-setup-py-install-sbi
Drop `setup.py install` support
2 parents fded808 + 849dcbd commit 295a35b

File tree

13 files changed

+59
-380
lines changed

13 files changed

+59
-380
lines changed

docs/html/reference/build-system/setup-py.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ The overall process for building a package is:
2424

2525
- Generate the package's metadata.
2626
- Generate a wheel for the package.
27-
- If this fails and we're trying to install the package, attempt a direct
28-
installation.
2927

3028
The wheel can then be used to perform an installation, if necessary.
3129

@@ -58,13 +56,6 @@ If this wheel generation fails, pip runs `setup.py clean` to clean up any build
5856
artifacts that may have been generated. After that, pip will attempt a direct
5957
installation.
6058

61-
### Direct Installation
62-
63-
When all else fails, pip will invoke `setup.py install` to install a package
64-
using setuptools' mechanisms to perform the installation. This is currently the
65-
last-resort fallback for projects that cannot be built into wheels, and may not
66-
be supported in the future.
67-
6859
### Editable Installation
6960

7061
For installing packages in "editable" mode

news/8368.removal.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove ``setup.py install`` fallback when building a wheel failed for projects without
2+
``pyproject.toml``.

src/pip/_internal/commands/install.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
check_legacy_setup_py_options,
3131
)
3232
from pip._internal.utils.compat import WINDOWS
33-
from pip._internal.utils.deprecation import LegacyInstallReasonFailedBdistWheel
3433
from pip._internal.utils.filesystem import test_writable_dir
3534
from pip._internal.utils.logging import getLogger
3635
from pip._internal.utils.misc import (
@@ -423,26 +422,14 @@ def run(self, options: Values, args: List[str]) -> int:
423422
global_options=global_options,
424423
)
425424

426-
# If we're using PEP 517, we cannot do a legacy setup.py install
427-
# so we fail here.
428-
pep517_build_failure_names: List[str] = [
429-
r.name for r in build_failures if r.use_pep517 # type: ignore
430-
]
431-
if pep517_build_failure_names:
425+
if build_failures:
432426
raise InstallationError(
433427
"Could not build wheels for {}, which is required to "
434428
"install pyproject.toml-based projects".format(
435-
", ".join(pep517_build_failure_names)
429+
", ".join(r.name for r in build_failures) # type: ignore
436430
)
437431
)
438432

439-
# For now, we just warn about failures building legacy
440-
# requirements, as we'll fall through to a setup.py install for
441-
# those.
442-
for r in build_failures:
443-
if not r.use_pep517:
444-
r.legacy_install_reason = LegacyInstallReasonFailedBdistWheel
445-
446433
to_install = resolver.get_installation_order(requirement_set)
447434

448435
# Check for conflicts in the package set we're installing.

src/pip/_internal/exceptions.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,6 @@ def __str__(self) -> str:
361361
)
362362

363363

364-
class LegacyInstallFailure(DiagnosticPipError):
365-
"""Error occurred while executing `setup.py install`"""
366-
367-
reference = "legacy-install-failure"
368-
369-
def __init__(self, package_details: str) -> None:
370-
super().__init__(
371-
message="Encountered error while trying to install package.",
372-
context=package_details,
373-
hint_stmt="See above for output from the failure.",
374-
note_stmt="This is an issue with the package mentioned above, not pip.",
375-
)
376-
377-
378364
class InstallationSubprocessError(DiagnosticPipError, InstallationError):
379365
"""A subprocess call failed."""
380366

src/pip/_internal/operations/install/legacy.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

src/pip/_internal/req/req_install.py

Lines changed: 16 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from pip._vendor.pyproject_hooks import BuildBackendHookCaller
2121

2222
from pip._internal.build_env import BuildEnvironment, NoOpBuildEnvironment
23-
from pip._internal.exceptions import InstallationError, LegacyInstallFailure
23+
from pip._internal.exceptions import InstallationError
2424
from pip._internal.locations import get_scheme
2525
from pip._internal.metadata import (
2626
BaseDistribution,
@@ -39,11 +39,10 @@
3939
from pip._internal.operations.install.editable_legacy import (
4040
install_editable as install_editable_legacy,
4141
)
42-
from pip._internal.operations.install.legacy import install as install_legacy
4342
from pip._internal.operations.install.wheel import install_wheel
4443
from pip._internal.pyproject import load_pyproject_toml, make_pyproject_path
4544
from pip._internal.req.req_uninstall import UninstallPathSet
46-
from pip._internal.utils.deprecation import LegacyInstallReason, deprecated
45+
from pip._internal.utils.deprecation import deprecated
4746
from pip._internal.utils.hashes import Hashes
4847
from pip._internal.utils.misc import (
4948
ConfiguredBuildBackendHookCaller,
@@ -93,7 +92,6 @@ def __init__(
9392
self.constraint = constraint
9493
self.editable = editable
9594
self.permit_editable_wheels = permit_editable_wheels
96-
self.legacy_install_reason: Optional[LegacyInstallReason] = None
9795

9896
# source_dir is the local directory where the linked requirement is
9997
# located, or unpacked. In case unpacking is needed, creating and
@@ -757,10 +755,9 @@ def install(
757755
prefix=prefix,
758756
)
759757

760-
global_options = global_options if global_options is not None else []
761758
if self.editable and not self.is_wheel:
762759
install_editable_legacy(
763-
global_options=global_options,
760+
global_options=global_options if global_options is not None else [],
764761
prefix=prefix,
765762
home=home,
766763
use_user_site=use_user_site,
@@ -773,66 +770,20 @@ def install(
773770
self.install_succeeded = True
774771
return
775772

776-
if self.is_wheel:
777-
assert self.local_file_path
778-
install_wheel(
779-
self.name,
780-
self.local_file_path,
781-
scheme=scheme,
782-
req_description=str(self.req),
783-
pycompile=pycompile,
784-
warn_script_location=warn_script_location,
785-
direct_url=self.download_info if self.original_link else None,
786-
requested=self.user_supplied,
787-
)
788-
self.install_succeeded = True
789-
return
790-
791-
# TODO: Why don't we do this for editable installs?
792-
793-
# Extend the list of global options passed on to
794-
# the setup.py call with the ones from the requirements file.
795-
# Options specified in requirements file override those
796-
# specified on the command line, since the last option given
797-
# to setup.py is the one that is used.
798-
global_options = list(global_options) + self.global_options
799-
800-
try:
801-
if (
802-
self.legacy_install_reason is not None
803-
and self.legacy_install_reason.emit_before_install
804-
):
805-
self.legacy_install_reason.emit_deprecation(self.name)
806-
success = install_legacy(
807-
global_options=global_options,
808-
root=root,
809-
home=home,
810-
prefix=prefix,
811-
use_user_site=use_user_site,
812-
pycompile=pycompile,
813-
scheme=scheme,
814-
setup_py_path=self.setup_py_path,
815-
isolated=self.isolated,
816-
req_name=self.name,
817-
build_env=self.build_env,
818-
unpacked_source_directory=self.unpacked_source_directory,
819-
req_description=str(self.req),
820-
)
821-
except LegacyInstallFailure as exc:
822-
self.install_succeeded = False
823-
raise exc
824-
except Exception:
825-
self.install_succeeded = True
826-
raise
773+
assert self.is_wheel
774+
assert self.local_file_path
827775

828-
self.install_succeeded = success
829-
830-
if (
831-
success
832-
and self.legacy_install_reason is not None
833-
and self.legacy_install_reason.emit_after_success
834-
):
835-
self.legacy_install_reason.emit_deprecation(self.name)
776+
install_wheel(
777+
self.name,
778+
self.local_file_path,
779+
scheme=scheme,
780+
req_description=str(self.req),
781+
pycompile=pycompile,
782+
warn_script_location=warn_script_location,
783+
direct_url=self.download_info if self.original_link else None,
784+
requested=self.user_supplied,
785+
)
786+
self.install_succeeded = True
836787

837788

838789
def check_invalid_constraint_type(req: InstallRequirement) -> str:

src/pip/_internal/utils/deprecation.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -118,44 +118,3 @@ def deprecated(
118118
raise PipDeprecationWarning(message)
119119

120120
warnings.warn(message, category=PipDeprecationWarning, stacklevel=2)
121-
122-
123-
class LegacyInstallReason:
124-
def __init__(
125-
self,
126-
reason: str,
127-
replacement: Optional[str] = None,
128-
gone_in: Optional[str] = None,
129-
feature_flag: Optional[str] = None,
130-
issue: Optional[int] = None,
131-
emit_after_success: bool = False,
132-
emit_before_install: bool = False,
133-
):
134-
self._reason = reason
135-
self._replacement = replacement
136-
self._gone_in = gone_in
137-
self._feature_flag = feature_flag
138-
self._issue = issue
139-
self.emit_after_success = emit_after_success
140-
self.emit_before_install = emit_before_install
141-
142-
def emit_deprecation(self, name: str) -> None:
143-
deprecated(
144-
reason=self._reason.format(name=name),
145-
replacement=self._replacement,
146-
gone_in=self._gone_in,
147-
feature_flag=self._feature_flag,
148-
issue=self._issue,
149-
)
150-
151-
152-
LegacyInstallReasonFailedBdistWheel = LegacyInstallReason(
153-
reason=(
154-
"{name} was installed using the legacy 'setup.py install' "
155-
"method, because a wheel could not be built for it."
156-
),
157-
replacement="to fix the wheel build issue reported above",
158-
gone_in="23.1",
159-
issue=8368,
160-
emit_after_success=True,
161-
)

0 commit comments

Comments
 (0)