File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 2
2
# openslide-python - Python bindings for the OpenSlide library
3
3
#
4
4
# Copyright (c) 2010-2013 Carnegie Mellon University
5
- # Copyright (c) 2016-2021 Benjamin Gilbert
5
+ # Copyright (c) 2016-2023 Benjamin Gilbert
6
6
#
7
7
# This library is free software; you can redistribute it and/or modify it
8
8
# under the terms of version 2.1 of the GNU Lesser General Public License
51
51
52
52
53
53
def _load_library ():
54
+ def try_load (names ):
55
+ for name in names :
56
+ try :
57
+ return cdll .LoadLibrary (name )
58
+ except OSError :
59
+ if name == names [- 1 ]:
60
+ raise
61
+
54
62
if platform .system () == 'Windows' :
55
63
try :
56
- return cdll . LoadLibrary ( 'libopenslide-0.dll' )
64
+ return try_load ([ 'libopenslide-1.dll' , 'libopenslide- 0.dll'] )
57
65
except FileNotFoundError :
58
66
import os
59
67
@@ -68,7 +76,7 @@ def _load_library():
68
76
)
69
77
elif platform .system () == 'Darwin' :
70
78
try :
71
- return cdll . LoadLibrary ( 'libopenslide.0.dylib' )
79
+ return try_load ([ 'libopenslide.1.dylib' , 'libopenslide. 0.dylib'] )
72
80
except OSError :
73
81
# MacPorts doesn't add itself to the dyld search path, but
74
82
# does add itself to the find_library() search path
@@ -83,7 +91,7 @@ def _load_library():
83
91
)
84
92
return cdll .LoadLibrary (lib )
85
93
else :
86
- return cdll . LoadLibrary ( 'libopenslide.so.0' )
94
+ return try_load ([ 'libopenslide.so.1' , 'libopenslide.so.0' ] )
87
95
88
96
89
97
_lib = _load_library ()
You can’t perform that action at this time.
0 commit comments