[ 
https://issues.apache.org/jira/browse/ARROW-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16214510#comment-16214510
 ] 

ASF GitHub Bot commented on ARROW-1087:
---------------------------------------

wesm closed pull request #1219: ARROW-1087: [Python] Add pyarrow.get_include 
function. Bundle includes in all builds
URL: https://github.com/apache/arrow/pull/1219
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/python/.gitignore b/python/.gitignore
index 1bf20c4ca..6a63e5a2a 100644
--- a/python/.gitignore
+++ b/python/.gitignore
@@ -17,6 +17,10 @@ Testing/
 *.cpp
 pyarrow/version.py
 pyarrow/*_api.h
+
+# Bundled headers
+pyarrow/include
+
 # Python files
 
 # setup.py working directory
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 169e7ad02..8c7348298 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -226,9 +226,11 @@ function(bundle_arrow_implib library_path)
       COPYONLY)
 endfunction(bundle_arrow_implib)
 
+# Always bundle includes
+file(COPY ${ARROW_INCLUDE_DIR}/arrow DESTINATION 
${BUILD_OUTPUT_ROOT_DIRECTORY}/include)
+
 if (PYARROW_BUNDLE_ARROW_CPP)
   # arrow
-  file(COPY ${ARROW_INCLUDE_DIR}/arrow DESTINATION 
${BUILD_OUTPUT_ROOT_DIRECTORY}/include)
   bundle_arrow_lib(ARROW_SHARED_LIB
     ABI_VERSION ${ARROW_ABI_VERSION}
     SO_VERSION ${ARROW_SO_VERSION})
diff --git a/python/doc/source/extending.rst b/python/doc/source/extending.rst
new file mode 100644
index 000000000..2d6caed26
--- /dev/null
+++ b/python/doc/source/extending.rst
@@ -0,0 +1,33 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements.  See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership.  The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License.  You may obtain a copy of the License at
+
+..   http://www.apache.org/licenses/LICENSE-2.0
+
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied.  See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+.. currentmodule:: pyarrow
+.. _extending:
+
+Building C++ and Cython Extensions using pyarrow
+================================================
+
+pyarrow features both a Cython and C++ API. We intend to fully document the
+details of how to do this.
+
+The Arrow C++ header files are bundled with a pyarrow installation. To get the
+absolute path to this directory (like ``numpy.get_include()``), use:
+
+.. code-block:: python
+
+   import pyarrow as pa
+   pa.get_include()
diff --git a/python/doc/source/index.rst b/python/doc/source/index.rst
index c2ae769b2..b933d2359 100644
--- a/python/doc/source/index.rst
+++ b/python/doc/source/index.rst
@@ -43,5 +43,6 @@ structures.
    plasma
    pandas
    parquet
+   extending
    api
    getting_involved
diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py
index e37c123d2..f954d4b27 100644
--- a/python/pyarrow/__init__.py
+++ b/python/pyarrow/__init__.py
@@ -142,3 +142,15 @@ def _plasma_store_entry_point():
 # Deprecations
 
 from pyarrow.util import _deprecate_class  # noqa
+
+# ----------------------------------------------------------------------
+# Returning absolute path to the pyarrow include directory (if bundled, e.g. in
+# wheels)
+
+def get_include():
+    """
+    Return absolute path to directory containing Arrow C++ include
+    headers. Similar to numpy.get_include
+    """
+    import os
+    return os.path.join(os.path.dirname(__file__), 'include')
diff --git a/python/pyarrow/tests/test_misc.py 
b/python/pyarrow/tests/test_misc.py
new file mode 100644
index 000000000..55787f135
--- /dev/null
+++ b/python/pyarrow/tests/test_misc.py
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os
+
+import pyarrow as pa
+
+
+def test_get_include():
+    include_dir = pa.get_include()
+    assert os.path.exists(os.path.join(include_dir, 'arrow', 'api.h'))
diff --git a/python/setup.py b/python/setup.py
index edcf397f3..ccab8fb65 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -220,11 +220,7 @@ def _run_cmake(self):
             build_prefix = self.build_type
 
         if self.bundle_arrow_cpp:
-            print(pjoin(build_prefix, 'include'), pjoin(build_lib, 'pyarrow'))
-            if os.path.exists(pjoin(build_lib, 'pyarrow', 'include')):
-                shutil.rmtree(pjoin(build_lib, 'pyarrow', 'include'))
-            shutil.move(pjoin(build_prefix, 'include'),
-                        pjoin(build_lib, 'pyarrow'))
+            print(pjoin(build_lib, 'pyarrow'))
             move_shared_libs(build_prefix, build_lib, "arrow")
             move_shared_libs(build_prefix, build_lib, "arrow_python")
             if self.with_plasma:
@@ -232,6 +228,12 @@ def _run_cmake(self):
             if self.with_parquet:
                 move_shared_libs(build_prefix, build_lib, "parquet")
 
+        print('Bundling includes: ' + pjoin(build_prefix, 'include'))
+        if os.path.exists(pjoin(build_lib, 'pyarrow', 'include')):
+            shutil.rmtree(pjoin(build_lib, 'pyarrow', 'include'))
+        shutil.move(pjoin(build_prefix, 'include'),
+                    pjoin(build_lib, 'pyarrow'))
+
         # Move the built C-extension to the place expected by the Python build
         self._found_names = []
         for name in self.CYTHON_MODULE_NAMES:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [Python] add get_include to expose directory containing header files
> --------------------------------------------------------------------
>
>                 Key: ARROW-1087
>                 URL: https://issues.apache.org/jira/browse/ARROW-1087
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>            Reporter: Jacob Scott
>            Assignee: Wes McKinney
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 0.8.0
>
>
> {{numpy.get_include}} streamlines extension development:
> {code}
>  import numpy as np
>         ...
>         Extension('extension_name', ...
>                 include_dirs=[np.get_include()])
> {code}
> It would be nice if pyarrow had the same thing



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to