MCPcopy Create free account
hub / github.com/apache/arrow / create_library_symlinks

Function create_library_symlinks

python/pyarrow/__init__.py:357–397  ·  view source on GitHub ↗

With Linux and macOS wheels, the bundled shared libraries have an embedded ABI version like libarrow.so.17 or libarrow.17.dylib and so linking to them with -larrow won't work unless we create symlinks at locations like site-packages/pyarrow/libarrow.so. This unfortunate workaround a

()

Source from the content-addressed store, hash-verified

355
356
357def create_library_symlinks():
358 """
359 With Linux and macOS wheels, the bundled shared libraries have an embedded
360 ABI version like libarrow.so.17 or libarrow.17.dylib and so linking to them
361 with -larrow won't work unless we create symlinks at locations like
362 site-packages/pyarrow/libarrow.so. This unfortunate workaround addresses
363 prior problems we had with shipping two copies of the shared libraries to
364 permit third party projects like turbodbc to build their C++ extensions
365 against the pyarrow wheels.
366
367 This function must only be invoked once and only when the shared libraries
368 are bundled with the Python package, which should only apply to wheel-based
369 installs. It requires write access to the site-packages/pyarrow directory
370 and so depending on your system may need to be run with root.
371 """
372 import glob
373 if _sys.platform == 'win32':
374 return
375 package_cwd = _os.path.dirname(__file__)
376
377 if _sys.platform == 'linux':
378 bundled_libs = glob.glob(_os.path.join(package_cwd, '*.so.*'))
379
380 def get_symlink_path(hard_path):
381 return hard_path.rsplit('.', 1)[0]
382 else:
383 bundled_libs = glob.glob(_os.path.join(package_cwd, '*.*.dylib'))
384
385 def get_symlink_path(hard_path):
386 return '.'.join((hard_path.rsplit('.', 2)[0], 'dylib'))
387
388 for lib_hard_path in bundled_libs:
389 symlink_path = get_symlink_path(lib_hard_path)
390 if _os.path.exists(symlink_path):
391 continue
392 try:
393 _os.symlink(lib_hard_path, symlink_path)
394 except PermissionError:
395 print("Tried creating symlink {}. If you need to link to "
396 "bundled shared libraries, run "
397 "pyarrow.create_library_symlinks() as root")
398
399
400def get_library_dirs():

Callers

nothing calls this directly

Calls 2

get_symlink_pathFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected