From 4dca850298260145989a38ad3850c3a15ce86703 Mon Sep 17 00:00:00 2001 From: Chris Wilcox Date: Wed, 18 Mar 2020 14:31:04 -0700 Subject: [PATCH] fix: change exception type --- setup.py | 10 ++++++++-- src/crc32c/__init__.py | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 6ae3f184..1eab290b 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ import setuptools import setuptools.command.build_ext - +import warnings _EXTRA_DLL = "extra-dll" _DLL_FILENAME = "crc32c.dll" @@ -90,11 +90,17 @@ def main(build_cffi=True): if __name__ == "__main__": + import sys try: main() except KeyboardInterrupt: raise - except Exception: + except SystemExit: # If installation fails, it is likely a compilation error with CFFI # Try to install again. + warnings.warn( + "Compiling the CFFI Extension crc32c has failed. Only a pure " + "python implementation will be usable." + ) main(build_cffi=False) + diff --git a/src/crc32c/__init__.py b/src/crc32c/__init__.py index 2458c896..b44591c9 100644 --- a/src/crc32c/__init__.py +++ b/src/crc32c/__init__.py @@ -15,9 +15,9 @@ import warnings _SLOW_CRC32C_WARNING = ( - "Currently using crcmod in pure python form. This is a slow " - "implementation. If you can compile a c extension, you will have much " - "better performance." + "As the c extension couldn't be imported, `google-crc32c` is using a " + "pure python implementation that is significantly slower. If possible, " + "please configure a c build environment and compile the extension" ) # If available, default to CFFI Implementation, otherwise, use pure python.