Skip to content

Commit

Permalink
Workaround for bdist_wheel.dist_info_dir problems (#4684)
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri authored Oct 16, 2024
2 parents 9af0877 + 0534fde commit 8ad3ea7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions newsfragments/4684.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add workaround for ``bdist_wheel --dist-info-dir`` errors
when customisation does not inherit from setuptools.
43 changes: 32 additions & 11 deletions setuptools/build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: # pragma: nocover
# pypa/setuptools#4683
if "--dist-info-dir not recognized" not in str(ex):
raise
_IncompatibleBdistWheel.emit()
return _build(['bdist_wheel'])

def build_sdist(
self, sdist_directory: StrPath, config_settings: _ConfigSettings = None
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 8ad3ea7

Please sign in to comment.