From 96be735ca2e77b7db876133dfda0b4df3ced4ac0 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Oct 2024 18:12:02 +0100 Subject: [PATCH 1/4] Workaround for bdist_wheel.dist_info_dir problems --- setuptools/build_meta.py | 43 ++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index ecf434bbf3..3231105e69 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -417,17 +417,27 @@ def build_wheel( config_settings: _ConfigSettings = None, metadata_directory: StrPath | None = None, ): - cmd = ['bdist_wheel'] - if metadata_directory: - cmd.extend(['--dist-info-dir', metadata_directory]) - with suppress_known_deprecation(): - return self._build_with_temp_dir( - cmd, - '.whl', - wheel_directory, - config_settings, - self._arbitrary_args(config_settings), - ) + def _build(cmd: list[str]): + with suppress_known_deprecation(): + return self._build_with_temp_dir( + cmd, + '.whl', + wheel_directory, + config_settings, + self._arbitrary_args(config_settings), + ) + + if metadata_directory is None: + return _build(['bdist_wheel']) + + try: + return _build(['bdist_wheel', '--dist-info-dir', metadata_directory]) + except SystemExit as ex: + # pypa/setuptools#4683 + if "--dist-info-dir" not in str(ex): + raise + _IncompatibleBdistWheel.emit() + return _build(['bdist_wheel']) def build_sdist( self, sdist_directory: StrPath, config_settings: _ConfigSettings = None @@ -514,6 +524,17 @@ def run_setup(self, setup_script='setup.py'): sys.argv[0] = sys_argv_0 +class _IncompatibleBdistWheel(SetuptoolsDeprecationWarning): + _SUMMARY = "wheel.bdist_wheel is deprecated, please import it from setuptools" + _DETAILS = """ + Ensure that any custom bdist_wheel implementation is a subclass of + setuptools.command.bdist_wheel.bdist_wheel. + """ + _DUE_DATE = (2025, 10, 15) + # Initially introduced in 2024/10/15, but maybe too disruptive to be enforced? + _SEE_URL = "https://github.com/pypa/wheel/pull/631" + + # The primary backend _BACKEND = _BuildMetaBackend() From a663287c9c5f0bfc5e05addfb3a15fea7fc716c3 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Oct 2024 20:31:58 +0100 Subject: [PATCH 2/4] Add pragma for edge-case code path --- setuptools/build_meta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index 3231105e69..19d0e1688e 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -432,7 +432,7 @@ def _build(cmd: list[str]): try: return _build(['bdist_wheel', '--dist-info-dir', metadata_directory]) - except SystemExit as ex: + except SystemExit as ex: # pragma: nocover # pypa/setuptools#4683 if "--dist-info-dir" not in str(ex): raise From 50b732a4006f3b84315d4473f7c203e4fe13aed9 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Oct 2024 20:34:44 +0100 Subject: [PATCH 3/4] Check for more specific error message --- setuptools/build_meta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index 19d0e1688e..e730a27f25 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -434,7 +434,7 @@ def _build(cmd: list[str]): return _build(['bdist_wheel', '--dist-info-dir', metadata_directory]) except SystemExit as ex: # pragma: nocover # pypa/setuptools#4683 - if "--dist-info-dir" not in str(ex): + if "--dist-info-dir not recognized" not in str(ex): raise _IncompatibleBdistWheel.emit() return _build(['bdist_wheel']) From 0534fde847e0bd0c2214d6821c042c0eb5c0ffc3 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Oct 2024 20:34:54 +0100 Subject: [PATCH 4/4] Add news fragment --- newsfragments/4684.bugfix.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 newsfragments/4684.bugfix.rst diff --git a/newsfragments/4684.bugfix.rst b/newsfragments/4684.bugfix.rst new file mode 100644 index 0000000000..40f554cccc --- /dev/null +++ b/newsfragments/4684.bugfix.rst @@ -0,0 +1,2 @@ +Add workaround for ``bdist_wheel --dist-info-dir`` errors +when customisation does not inherit from setuptools.