Merge pull request #8215 from ThomasWaldmann/fix-cythonize-import-error-reporting-master

setup.py: fix import error reporting for cythonize import, see #8208 (master)
This commit is contained in:
TW 2024-05-12 18:40:52 +02:00 committed by GitHub
commit 1525c72549
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 2 deletions

View File

@ -16,8 +16,14 @@ from setuptools.command.sdist import sdist
try: try:
from Cython.Build import cythonize from Cython.Build import cythonize
except ImportError:
cythonize_import_error_msg = None
except ImportError as exc:
# either there is no Cython installed or there is some issue with it.
cythonize = None cythonize = None
cythonize_import_error_msg = "ImportError: " + str(exc)
if "failed to map segment from shared object" in cythonize_import_error_msg:
cythonize_import_error_msg += " Check if the borg build uses a +exec filesystem."
sys.path += [os.path.dirname(__file__)] sys.path += [os.path.dirname(__file__)]
@ -80,7 +86,12 @@ else:
cython_c_files = [fn.replace(".pyx", ".c") for fn in cython_sources] cython_c_files = [fn.replace(".pyx", ".c") for fn in cython_sources]
if not on_rtd and not all(os.path.exists(path) for path in cython_c_files): if not on_rtd and not all(os.path.exists(path) for path in cython_c_files):
raise ImportError("The GIT version of Borg needs Cython. Install Cython or use a released version.") raise ImportError(
"The GIT version of Borg needs a working Cython. "
+ "Install or fix Cython or use a released borg version. "
+ "Importing cythonize failed with: "
+ cythonize_import_error_msg
)
cmdclass = {"build_ext": build_ext, "sdist": Sdist} cmdclass = {"build_ext": build_ext, "sdist": Sdist}