Skip to content

Commit dd7a258

Browse files
committed
Workaround for bdist_wheel.dist_info_dir problems
1 parent b828db4 commit dd7a258

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

setuptools/dist.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,13 @@ def _parse_command_opts(self, parser, args):
849849
args[:1] = shlex.split(alias, True)
850850
command = args[0]
851851

852-
nargs = _Distribution._parse_command_opts(self, parser, args)
852+
try:
853+
nargs = _Distribution._parse_command_opts(self, parser, args)
854+
except Exception as ex:
855+
if "--dist-info-dir" in args and "dist-info-dir not recognized" in str(ex):
856+
nargs = self._workaround_dist_info_dir(parser, args)
857+
else:
858+
raise
853859

854860
# Handle commands that want to consume all remaining arguments
855861
cmd_class = self.get_command_class(command)
@@ -860,6 +866,13 @@ def _parse_command_opts(self, parser, args):
860866

861867
return nargs
862868

869+
def _workaround_dist_info_dir(self, parser, args):
870+
# pypa/setuptools#4683
871+
_IncompatibleBdistWheel.emit()
872+
i = args.index("--dist-info-dir")
873+
args = args[:i] + args[i + 2 :] # Remove problematic arguments
874+
return _Distribution._parse_command_opts(self, parser, args)
875+
863876
def get_cmdline_options(self):
864877
"""Return a '{cmd: {opt:val}}' map of all command-line options
865878
@@ -953,3 +966,14 @@ def run_command(self, command):
953966
class DistDeprecationWarning(SetuptoolsDeprecationWarning):
954967
"""Class for warning about deprecations in dist in
955968
setuptools. Not ignored by default, unlike DeprecationWarning."""
969+
970+
971+
class _IncompatibleBdistWheel(SetuptoolsDeprecationWarning):
972+
_SUMMARY = "wheel.bdist_wheel is deprecated, please import it from setuptools"
973+
_DETAILS = """
974+
Ensure that any custom bdist_wheel implementation is a subclass of
975+
setuptools.command.bdist_wheel.bdist_wheel.
976+
"""
977+
_DUE_DATE = (2025, 10, 15)
978+
# Initially introduced in 2024/10/15, but maybe too disruptive to be enforced?
979+
_SEE_URL = "https://github.com/pypa/wheel/pull/631"

0 commit comments

Comments
 (0)