You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/08/08 16:30:54 UTC

[arrow] branch master updated: ARROW-2976: [Python] Fix pyarrow.get_library_dirs

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 0cef55a  ARROW-2976: [Python] Fix pyarrow.get_library_dirs
0cef55a is described below

commit 0cef55a486977f011f13218f6e4e4ba68844bebf
Author: Philipp Moritz <pc...@gmail.com>
AuthorDate: Wed Aug 8 12:30:49 2018 -0400

    ARROW-2976: [Python] Fix pyarrow.get_library_dirs
    
    Author: Philipp Moritz <pc...@gmail.com>
    
    Closes #2398 from pcmoritz/fix-get-library-dirs and squashes the following commits:
    
    6d88fcd0 <Philipp Moritz> fix windows build
    fe8f65cc <Philipp Moritz> fix get_library_dirs
---
 python/pyarrow/__init__.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py
index 8010b72..f4137d9 100644
--- a/python/pyarrow/__init__.py
+++ b/python/pyarrow/__init__.py
@@ -208,6 +208,24 @@ def get_library_dirs():
 
     library_dirs = [package_cwd]
 
+    # Search library paths via pkg-config. This is necessary if the user
+    # installed libarrow and the other shared libraries manually and they
+    # are not shipped inside the pyarrow package (see also ARROW-2976).
+    from subprocess import call, PIPE, Popen
+    pkg_config_executable = _os.environ.get('PKG_CONFIG', None) or 'pkg-config'
+    for package in ["arrow", "plasma", "arrow_python"]:
+        cmd = '{0} --exists {1}'.format(pkg_config_executable, package).split()
+        try:
+            if call(cmd) == 0:
+                cmd = [pkg_config_executable, "--libs-only-L", package]
+                proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
+                out, err = proc.communicate()
+                library_dir = out.rstrip().decode('utf-8')[2:] # strip "-L"
+                if library_dir not in library_dirs:
+                    library_dirs.append(library_dir)
+        except FileNotFoundError:
+            pass
+
     if _sys.platform == 'win32':
         # TODO(wesm): Is this necessary, or does setuptools within a conda
         # installation add Library\lib to the linker path for MSVC?