7
7
8
8
"""
9
9
import ctypes
10
- import ctypes .util
10
+ try :
11
+ import ctypes .util
12
+ except ImportError :
13
+ pass
11
14
import os
12
15
import os .path
13
16
import platform
@@ -23,7 +26,6 @@ def load_library():
23
26
"""
24
27
libpath = None
25
28
system = platform .system ()
26
-
27
29
magick_home = os .environ .get ('MAGICK_HOME' )
28
30
if magick_home :
29
31
if system == 'Windows' :
@@ -33,25 +35,29 @@ def load_library():
33
35
else :
34
36
libpath = 'lib' , 'libMagickWand.so' ,
35
37
libpath = os .path .join (magick_home , * libpath )
36
- else :
38
+ elif hasattr ( ctypes , 'util' ) :
37
39
if system == 'Windows' :
38
40
libpath = ctypes .util .find_library ('CORE_RL_wand_' )
39
41
else :
40
42
libpath = ctypes .util .find_library ('MagickWand' )
43
+ else :
44
+ raise ImportError ('cannot find MagickWand library; explicitly set '
45
+ 'MAGICK_HOME environment variable' )
41
46
libwand = ctypes .CDLL (libpath )
42
-
43
47
if system == 'Windows' :
44
48
# On Windows, the API is split between two libs. On other platforms,
45
49
# it's all contained in one.
46
50
libmagick_filename = 'CORE_RL_magick_'
47
51
if magick_home :
48
52
libmagick_path = os .path .join (magick_home ,
49
53
libmagick_filename + '.dll' )
50
- else :
54
+ elif hasattr ( ctypes , 'util' ) :
51
55
libmagick_path = ctypes .util .find_library (libmagick_filename )
56
+ else :
57
+ raise ImportError ('cannot find MagickWand library; explicitly set '
58
+ 'MAGICK_HOME environment variable' )
52
59
libmagick = ctypes .CDLL (libmagick_path )
53
60
return libwand , libmagick
54
-
55
61
return libwand , libwand
56
62
57
63
0 commit comments