From 6812c08876463ec47ea86ae0d9e83e17161c32bd Mon Sep 17 00:00:00 2001 From: Adam Hupp Date: Wed, 31 Mar 2010 16:30:01 -0700 Subject: - Grab fix for OSX from bitbucket.org/pfw/ - Produce a more sensible error message when no library is found --- magic.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'magic.py') diff --git a/magic.py b/magic.py index 60b999b..c072910 100644 --- a/magic.py +++ b/magic.py @@ -105,6 +105,13 @@ def from_buffer(buffer, mime=False): libmagic = ctypes.CDLL(ctypes.util.find_library('magic')) +if not libmagic._name: + import sys + if sys.platform == "darwin": + # try mac ports location + libmagic = ctypes.CDLL('/opt/local/lib/libmagic.dylib') +if not libmagic._name: + raise Exception('failed to find libmagic. Check your installation') magic_t = ctypes.c_void_p -- cgit v1.2.1