Return lists of directories likely to contain Arrow C++ libraries for linking C or Cython extensions using pyarrow
()
| 388 | |
| 389 | |
| 390 | def get_library_dirs(): |
| 391 | """ |
| 392 | Return lists of directories likely to contain Arrow C++ libraries for |
| 393 | linking C or Cython extensions using pyarrow |
| 394 | """ |
| 395 | # Use pyarrow.lib location instead of just __file__. That works |
| 396 | # for both editable and non-editable builds as it points |
| 397 | # to the actual location of the compiled C++ extension. |
| 398 | from pyarrow import lib as _lib |
| 399 | package_cwd = _os.path.dirname(_lib.__file__) |
| 400 | library_dirs = [package_cwd] |
| 401 | |
| 402 | def append_library_dir(library_dir): |
| 403 | if library_dir not in library_dirs: |
| 404 | library_dirs.append(library_dir) |
| 405 | |
| 406 | # Search library paths via pkg-config. This is necessary if the user |
| 407 | # installed libarrow and the other shared libraries manually and they |
| 408 | # are not shipped inside the pyarrow package (see also ARROW-2976). |
| 409 | pkg_config_executable = _os.environ.get('PKG_CONFIG') or 'pkg-config' |
| 410 | for pkgname in ["arrow", "arrow_python"]: |
| 411 | if _has_pkg_config(pkgname): |
| 412 | library_dir = _read_pkg_config_variable(pkgname, |
| 413 | ["--libs-only-L"]) |
| 414 | # pkg-config output could be empty if Arrow is installed |
| 415 | # as a system package. |
| 416 | if library_dir: |
| 417 | if not library_dir.startswith("-L"): |
| 418 | raise ValueError( |
| 419 | "pkg-config --libs-only-L returned unexpected " |
| 420 | f"value {library_dir!r}") |
| 421 | append_library_dir(library_dir[2:]) |
| 422 | |
| 423 | if _sys.platform == 'win32': |
| 424 | # TODO(wesm): Is this necessary, or does setuptools within a conda |
| 425 | # installation add Library\lib to the linker path for MSVC? |
| 426 | python_base_install = _os.path.dirname(_sys.executable) |
| 427 | library_dir = _os.path.join(python_base_install, 'Library', 'lib') |
| 428 | |
| 429 | if _os.path.exists(_os.path.join(library_dir, 'arrow.lib')): |
| 430 | append_library_dir(library_dir) |
| 431 | |
| 432 | # GH-45530: Add pyarrow.libs dir containing delvewheel-mangled |
| 433 | # msvcp140.dll |
| 434 | pyarrow_libs_dir = _os.path.abspath( |
| 435 | _os.path.join(_os.path.dirname(__file__), _os.pardir, "pyarrow.libs") |
| 436 | ) |
| 437 | if _os.path.exists(pyarrow_libs_dir): |
| 438 | append_library_dir(pyarrow_libs_dir) |
| 439 | |
| 440 | # ARROW-4074: Allow for ARROW_HOME to be set to some other directory |
| 441 | if _os.environ.get('ARROW_HOME'): |
| 442 | append_library_dir(_os.path.join(_os.environ['ARROW_HOME'], 'lib')) |
| 443 | else: |
| 444 | # Python wheels bundle the Arrow libraries in the pyarrow directory. |
| 445 | append_library_dir(_os.path.dirname(_os.path.abspath(__file__))) |
| 446 | |
| 447 | return library_dirs |
nothing calls this directly
no test coverage detected