diff --git a/python/pyarrow/tests/test_cpp_internals.py b/python/pyarrow/tests/test_cpp_internals.py index 1c44bff9b5b..83800b77f89 100644 --- a/python/pyarrow/tests/test_cpp_internals.py +++ b/python/pyarrow/tests/test_cpp_internals.py @@ -15,6 +15,9 @@ # specific language governing permissions and limitations # under the License. +import os.path +from os.path import join as pjoin + from pyarrow._pyarrow_cpp_tests import get_cpp_tests @@ -31,3 +34,17 @@ def wrapper(case=case): inject_cpp_tests(globals()) + + +def test_pyarrow_include(): + # We need to make sure that pyarrow/include is always + # created. Either with PyArrow C++ header files or with + # Arrow C++ and PyArrow C++ header files together + + source = os.path.dirname(os.path.abspath(__file__)) + pyarrow_dir = pjoin(source, '..') + pyarrow_include = pjoin(pyarrow_dir, 'include') + pyarrow_cpp_include = pjoin(pyarrow_include, 'arrow', 'python') + + assert os.path.exists(pyarrow_include) + assert os.path.exists(pyarrow_cpp_include) diff --git a/python/setup.py b/python/setup.py index bcc427f87df..e6ef23afd0a 100755 --- a/python/setup.py +++ b/python/setup.py @@ -436,19 +436,23 @@ def copy_libs(dir): else: build_prefix = self.build_type + pyarrow_include = pjoin(build_lib, 'pyarrow', 'include') + # Move Arrow C++ headers to pyarrow/include if self.bundle_arrow_cpp or self.bundle_arrow_cpp_headers: arrow_cpp_include = pjoin(build_prefix, 'include') print('Bundling includes: ' + arrow_cpp_include) - pyarrow_include = pjoin(build_lib, 'pyarrow', 'include') if os.path.exists(pyarrow_include): shutil.rmtree(pyarrow_include) shutil.move(arrow_cpp_include, pyarrow_include) - # pyarrow/include file is first deleted in the previous step - # so we need to add the PyArrow C++ include folder again - pyarrow_cpp_include = pjoin(pyarrow_cpp_home, 'include') - shutil.move(pjoin(pyarrow_cpp_include, 'arrow', 'python'), - pjoin(pyarrow_include, 'arrow', 'python')) + # Move PyArrow headers to pyarrow/include + pyarrow_cpp_include = pjoin(pyarrow_cpp_home, 'include') + pyarrow_include_sub = pjoin(pyarrow_include, 'arrow', 'python') + print('Moving PyArrow C++ includes: ' + pyarrow_include_sub) + if os.path.exists(pyarrow_include_sub): + shutil.rmtree(pyarrow_include_sub) + shutil.move(pjoin(pyarrow_cpp_include, 'arrow', 'python'), + pyarrow_include_sub) # Move the built C-extension to the place expected by the Python # build