Skip to content

Commit

Permalink
fix: change exception type
Browse files Browse the repository at this point in the history
  • Loading branch information
crwilcox committed Mar 18, 2020
1 parent d6114e3 commit 4dca850
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions setup.py
Expand Up @@ -18,7 +18,7 @@

import setuptools
import setuptools.command.build_ext

import warnings

_EXTRA_DLL = "extra-dll"
_DLL_FILENAME = "crc32c.dll"
Expand Down Expand Up @@ -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)

6 changes: 3 additions & 3 deletions src/crc32c/__init__.py
Expand Up @@ -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.
Expand Down

0 comments on commit 4dca850

Please sign in to comment.