Skip to content

Commit

Permalink
Merge pull request #8215 from ThomasWaldmann/fix-cythonize-import-err…
Browse files Browse the repository at this point in the history
…or-reporting-master

setup.py: fix import error reporting for cythonize import, see #8208 (master)
  • Loading branch information
ThomasWaldmann committed May 12, 2024
2 parents 5e36ba7 + ce2a824 commit 1525c72
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@

try:
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_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__)]

Expand Down Expand Up @@ -80,7 +86,12 @@ def __init__(self, *args, **kwargs):

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):
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}
Expand Down

0 comments on commit 1525c72

Please sign in to comment.