From f39d38668add998395414064449f7fd0a68bd650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 7 Aug 2022 16:21:20 +0200 Subject: [PATCH 1/2] Deprecate --no-binary implying setup.py install --- news/11452.removal.rst | 2 ++ src/pip/_internal/utils/deprecation.py | 17 +++++++++++++++-- src/pip/_internal/wheel_builder.py | 10 +++++----- 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 news/11452.removal.rst diff --git a/news/11452.removal.rst b/news/11452.removal.rst new file mode 100644 index 00000000000..ac29324abc8 --- /dev/null +++ b/news/11452.removal.rst @@ -0,0 +1,2 @@ +Deprecate installation with 'setup.py install' when no-binary is enabled for +source distributions without 'pyproject.toml'. diff --git a/src/pip/_internal/utils/deprecation.py b/src/pip/_internal/utils/deprecation.py index 7c7ace6ff4c..a7acf07bb3a 100644 --- a/src/pip/_internal/utils/deprecation.py +++ b/src/pip/_internal/utils/deprecation.py @@ -124,8 +124,8 @@ class LegacyInstallReason: def __init__( self, reason: str, - replacement: Optional[str], - gone_in: Optional[str], + replacement: Optional[str] = None, + gone_in: Optional[str] = None, feature_flag: Optional[str] = None, issue: Optional[int] = None, emit_after_success: bool = False, @@ -173,3 +173,16 @@ def emit_deprecation(self, name: str) -> None: issue=8559, emit_before_install=True, ) + +LegacyInstallReasonNoBinaryForcesSetuptoolsInstall = LegacyInstallReason( + reason=( + "{name} is being installed using the legacy " + "'setup.py install' method, because the '--no-binary' option was enabled " + "for it and this currently disables local wheel building for projects that " + "don't have a 'pyproject.toml' file." + ), + replacement="to enable the '--use-pep517' option", + gone_in="23.1", + issue=11451, + emit_before_install=True, +) diff --git a/src/pip/_internal/wheel_builder.py b/src/pip/_internal/wheel_builder.py index 60db28e92c3..6f359421d80 100644 --- a/src/pip/_internal/wheel_builder.py +++ b/src/pip/_internal/wheel_builder.py @@ -19,7 +19,10 @@ 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.deprecation import ( + LegacyInstallReasonMissingWheelPackage, + LegacyInstallReasonNoBinaryForcesSetuptoolsInstall, +) 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 @@ -80,10 +83,7 @@ def _should_build( assert check_bdist_wheel is not None if not check_bdist_wheel(req): - logger.info( - "Skipping wheel build for %s, due to binaries being disabled for it.", - req.name, - ) + req.legacy_install_reason = LegacyInstallReasonNoBinaryForcesSetuptoolsInstall return False if not is_wheel_installed(): From 857df9059d24ec43f088da88b957665bd3b05d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 18 Sep 2022 10:05:11 +0200 Subject: [PATCH 2/2] Add maintenance comment --- src/pip/_internal/wheel_builder.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pip/_internal/wheel_builder.py b/src/pip/_internal/wheel_builder.py index 6f359421d80..15b30af58e4 100644 --- a/src/pip/_internal/wheel_builder.py +++ b/src/pip/_internal/wheel_builder.py @@ -83,6 +83,11 @@ def _should_build( assert check_bdist_wheel is not None if not check_bdist_wheel(req): + # /!\ When we change this to unconditionally return True, we must also remove + # support for `--install-option`. Indeed, `--install-option` implies + # `--no-binary` so we can return False here and run `setup.py install`. + # `--global-option` and `--build-option` can remain until we drop support for + # building with `setup.py bdist_wheel`. req.legacy_install_reason = LegacyInstallReasonNoBinaryForcesSetuptoolsInstall return False