@@ -94,7 +94,24 @@ def _libtiledb_exists(library_dirs):
94
94
try :
95
95
# note: this is a relative path on linux
96
96
# https://bugs.python.org/issue21042
97
- CDLL (lib_name )
97
+
98
+ lib = CDLL (lib_name )
99
+
100
+ if os .name == "posix" :
101
+ # Workaround to retrieving full path of shared library based
102
+ # on https://stackoverflow.com/a/35683698
103
+
104
+ dlinfo = lib .dlinfo
105
+ dlinfo .argtypes = c_void_p , c_int , c_void_p
106
+ dlinfo .restype = c_int
107
+
108
+ class LINKMAP (Structure ):
109
+ _fields_ = [("l_addr" , c_void_p ), ("l_name" , c_char_p )]
110
+
111
+ lmptr = POINTER (LINKMAP )()
112
+ dlinfo (lib ._handle , 2 , byref (lmptr ))
113
+ lib_name = lmptr .contents .l_name .decode ()
114
+
98
115
return lib_name
99
116
except :
100
117
pass
@@ -284,7 +301,7 @@ def find_or_install_libtiledb(setuptools_cmd):
284
301
if wheel_build and is_windows () and lib_exists :
285
302
do_install = True
286
303
287
- print ("prefix_dir: " , prefix_dir or None )
304
+ print ("prefix_dir: " , prefix_dir )
288
305
print ("do_install: " , do_install )
289
306
290
307
if do_install :
@@ -377,35 +394,26 @@ def do_copy(src, dest):
377
394
print ("-------------------\n " )
378
395
setuptools_cmd .distribution .package_data .update ({"tiledb" : libtiledb_objects })
379
396
380
- libtiledbso = CDLL (
381
- lib_exists or os .path .join ( dest_dir , libtiledb_library_names ()[ 0 ])
397
+ libtiledb_dir = (
398
+ os .path .dirname ( os . path . dirname ( lib_exists )) if lib_exists else prefix_dir
382
399
)
383
-
384
- libtiledbso .tiledb_version .argtypes = [
385
- POINTER (c_int ),
386
- POINTER (c_int ),
387
- POINTER (c_int ),
388
- ]
389
- major , minor , patch = c_int (), c_int (), c_int ()
390
- libtiledbso .tiledb_version (major , minor , patch )
400
+ version_header = os .path .join (
401
+ libtiledb_dir , "include" , "tiledb" , "tiledb_version.h"
402
+ )
403
+ with open (version_header ) as header :
404
+ lines = list (header )[- 3 :]
405
+ major , minor , patch = [int (l .split ()[- 1 ]) for l in lines ]
391
406
392
407
ext_attr_update (
393
408
"cython_compile_time_env" ,
394
409
{
395
410
"TILEDBPY_MODULAR" : TILEDBPY_MODULAR ,
396
- "LIBTILEDB_VERSION_MAJOR" : major . value ,
397
- "LIBTILEDB_VERSION_MINOR" : minor . value ,
398
- "LIBTILEDB_VERSION_PATCH" : patch . value ,
411
+ "LIBTILEDB_VERSION_MAJOR" : major ,
412
+ "LIBTILEDB_VERSION_MINOR" : minor ,
413
+ "LIBTILEDB_VERSION_PATCH" : patch ,
399
414
},
400
415
)
401
416
402
- if is_windows ():
403
- from ctypes .wintypes import HMODULE
404
-
405
- kernel32 = WinDLL ("kernel32" , use_last_error = True )
406
- kernel32 .FreeLibrary .argtypes = [HMODULE ]
407
- kernel32 .FreeLibrary (libtiledbso ._handle )
408
-
409
417
410
418
class LazyCommandClass (dict ):
411
419
"""
0 commit comments