Skip to content

Commit

Permalink
ARROW-18340: [Python] PyArrow C++ header files no longer always inclu…
Browse files Browse the repository at this point in the history
…ded in installed pyarrow (apache#14656)

This PR adds code to `_run_cmake` to always copy PyArrow C++ header files to `pyarrow/iclude`.

Lead-authored-by: Alenka Frim <[email protected]>
Co-authored-by: Alenka Frim <[email protected]>
Co-authored-by: Joris Van den Bossche <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
AlenkaF and jorisvandenbossche authored Nov 22, 2022
1 parent 59f99d2 commit 1e9eb61
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
17 changes: 17 additions & 0 deletions python/pyarrow/tests/test_cpp_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)
16 changes: 10 additions & 6 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,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
Expand Down

0 comments on commit 1e9eb61

Please sign in to comment.