Skip to content

Commit

Permalink
Deprecate setup.py install fallback when wheel package is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Aug 6, 2022
1 parent afe136c commit ae802e3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions news/8559.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Deprecate installation with 'setup.py install' when the 'wheel' package is absent for
source distributions without 'pyproject.toml'.
5 changes: 5 additions & 0 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@ def install(
install_options = list(install_options) + self.install_options

try:
if (
self.legacy_install_reason is not None
and self.legacy_install_reason.emit_before_install
):
self.legacy_install_reason.emit_deprecation(self.name)
success = install_legacy(
install_options=install_options,
global_options=global_options,
Expand Down
14 changes: 14 additions & 0 deletions src/pip/_internal/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,17 @@ def emit_deprecation(self, name: str) -> None:
issue=8368,
emit_after_success=True,
)


LegacyInstallReasonMissingWheelPackage = LegacyInstallReason(
reason=(
"{name} is being installed using the legacy "
"'setup.py install' method, because it does not have a "
"'pyproject.toml' and the 'wheel' package "
"is not installed."
),
replacement="to enable the '--use-pep517' option",
gone_in=None,
issue=8559,
emit_before_install=True,
)
7 changes: 2 additions & 5 deletions src/pip/_internal/wheel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pip._internal.operations.build.wheel_editable import build_wheel_editable
from pip._internal.operations.build.wheel_legacy import build_wheel_legacy
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.deprecation import LegacyInstallReasonMissingWheelPackage
from pip._internal.utils.logging import indent_log
from pip._internal.utils.misc import ensure_dir, hash_file, is_wheel_installed
from pip._internal.utils.setuptools_build import make_setuptools_clean_args
Expand Down Expand Up @@ -86,11 +87,7 @@ def _should_build(

if not is_wheel_installed():
# we don't build legacy requirements if wheel is not installed
logger.info(
"Using legacy 'setup.py install' for %s, "
"since package 'wheel' is not installed.",
req.name,
)
req.legacy_install_reason = LegacyInstallReasonMissingWheelPackage
return False

return True
Expand Down

0 comments on commit ae802e3

Please sign in to comment.