-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
What's the problem this feature will solve?
The Migration Advice in PEP 0632 says that setuptools is a sufficient replacement for distutils.errors. However, only DistutilsError and RemovedCommandError exist there. In distutils, there are:
In [7]: [e for e in dir(distutils.errors) if e.endswith('Error')]
Out[7]:
['CCompilerError',
'CompileError',
'DistutilsArgError',
'DistutilsByteCompileError',
'DistutilsClassError',
'DistutilsError',
'DistutilsExecError',
'DistutilsFileError',
'DistutilsGetoptError',
'DistutilsInternalError',
'DistutilsModuleError',
'DistutilsOptionError',
'DistutilsPlatformError',
'DistutilsSetupError',
'DistutilsTemplateError',
'LibError',
'LinkError',
'PreprocessError',
'UnknownFileError']
While all of the Distutils-prefixed ones derive from DistutilsError, the ones without the prefix are derived from CCompilerError, and so cannot be caught using anything exported by setuptools. Concretely, this makes it difficult to check for compiler flags, as done here.
Describe the solution you'd like
Re-export all distutils.errors.* in setuptools.errors.
Alternative Solutions
Currently, we use distutils.errors, but won't be able to after Python 3.12. One can use a generic Exception too, but that's not recommended.
Or as a complete alternative, if setuptools had a way to check whether a compiler supported a flag in a builtin way, then we wouldn't need to catch the CompileError ourselves.
Additional context
No response
Code of Conduct
- I agree to follow the PSF Code of Conduct