Unverified 提交 c9159b2d authored 作者: Maxim Kochurov's avatar Maxim Kochurov 提交者: GitHub

Fix import errors if setuptools is too old (#483)

* add fallback class * lint * Complain about ancient setuptools version * Add a hack to appease mypy * Tidy up --------- Co-authored-by: 's avatarBen Mares <services-git-throwaway1@tensorial.com>
上级 7bb18f3a
from setuptools.errors import CompileError as BaseCompileError
try:
from setuptools.errors import CompileError as BaseCompileError
except ImportError:
import warnings
from distutils.errors import CompileError as BaseCompileError # type: ignore
from importlib.metadata import version
# These exception classes were made available in setuptools
# since v59.0.0 via <https://github.com/pypa/setuptools/pull/2858>
# in preparation for distutils deprecation. Complain loudly if they
# are not available.
setuptools_version = version("setuptools")
warnings.warn(
f"You appear to be using an ancient version of setuptools: "
f"v{setuptools_version}. Please upgrade to at least v59.0.0. "
f"Support for this version of setuptools is provisionary and "
f"may be removed without warning in the future."
)
class MissingGXX(Exception):
"""
This error is raised when we try to generate c code,
but g++ is not available.
"""
class MissingGXX(Exception):
"""This error is raised when we try to generate c code, but g++ is not available."""
class CompileError(BaseCompileError):
"""This custom `Exception` prints compilation errors with their original
formatting.
"""
class CompileError(BaseCompileError): # pyright: ignore
"""Custom `Exception` prints compilation errors with their original formatting."""
def __str__(self):
return self.args[0]
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论