Skip to content

Commit

Permalink
ARROW-54: [Python] Rename package to "pyarrow"
Browse files Browse the repository at this point in the history
Also fixed rpath issues (at great cost) per ARROW-53

Author: Wes McKinney <wesm@apache.org>

Closes #23 from wesm/ARROW-54 and squashes the following commits:

b8ce0e8 [Wes McKinney] Update installation instructions
cae9b39 [Wes McKinney] Fix rpath issues per ARROW-53
7554539 [Wes McKinney] Twiddle rpath stuff, remove empty arrow_test_util module
8cca41a [Wes McKinney] Fix Travis CI script for renamed package
1d37c93 [Wes McKinney] Opt in to building unit tests
60088d0 [Wes McKinney] Rename package to pyarrow
e3d0caf [Wes McKinney] Note on other Python interpreters
80d3bac [Wes McKinney] Start installation document
  • Loading branch information
wesm committed Mar 9, 2016
1 parent 8367527 commit 6fdcd49
Show file tree
Hide file tree
Showing 34 changed files with 300 additions and 201 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ matrix:
- $TRAVIS_BUILD_DIR/ci/travis_script_cpp.sh
- $TRAVIS_BUILD_DIR/ci/travis_script_python.sh
- compiler: clang
language: cpp
language: objective-c
osx_image: xcode6.4
os: osx
addons:
before_script:
Expand All @@ -40,7 +41,6 @@ before_install:
- ulimit -c unlimited -S
- export CPP_BUILD_DIR=$TRAVIS_BUILD_DIR/cpp-build
- export ARROW_CPP_INSTALL=$TRAVIS_BUILD_DIR/cpp-install
- export LD_LIBRARY_PATH=$ARROW_CPP_INSTALL/lib:$LD_LIBRARY_PATH

after_script:
- rm -rf $CPP_BUILD_DIR
Expand Down
2 changes: 1 addition & 1 deletion ci/travis_script_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export ARROW_HOME=$ARROW_CPP_INSTALL

python setup.py build_ext --inplace

py.test -vv -r sxX arrow
py.test -vv -r sxX pyarrow

# if [ $TRAVIS_OS_NAME == "linux" ]; then
# valgrind --tool=memcheck py.test -vv -r sxX arrow
Expand Down
29 changes: 18 additions & 11 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ if ("$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "1")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
endif()

if(APPLE)
# In newer versions of CMake, this is the default setting
set(CMAKE_MACOSX_RPATH 1)
endif()

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
Expand Down Expand Up @@ -339,10 +334,13 @@ endfunction()
if ("$ENV{GTEST_HOME}" STREQUAL "")
set(GTest_HOME ${THIRDPARTY_DIR}/googletest-release-1.7.0)
endif()
find_package(GTest REQUIRED)
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
ADD_THIRDPARTY_LIB(gtest
STATIC_LIB ${GTEST_STATIC_LIB})

if(ARROW_BUILD_TESTS)
find_package(GTest REQUIRED)
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
ADD_THIRDPARTY_LIB(gtest
STATIC_LIB ${GTEST_STATIC_LIB})
endif()

## Google PerfTools
##
Expand All @@ -366,7 +364,7 @@ ADD_THIRDPARTY_LIB(gtest
############################################################
# Linker setup
############################################################
set(ARROW_MIN_TEST_LIBS arrow arrow_test_main arrow_test_util ${ARROW_BASE_LIBS})
set(ARROW_MIN_TEST_LIBS arrow arrow_test_main ${ARROW_BASE_LIBS})
set(ARROW_TEST_LINK_LIBS ${ARROW_MIN_TEST_LIBS})

############################################################
Expand Down Expand Up @@ -461,9 +459,18 @@ add_library(arrow
${LIBARROW_LINKAGE}
${ARROW_SRCS}
)

if (APPLE)
set_target_properties(arrow
PROPERTIES
BUILD_WITH_INSTALL_RPATH ON
INSTALL_NAME_DIR "@rpath")
endif()

set_target_properties(arrow
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}"
)
target_link_libraries(arrow ${LIBARROW_LINK_LIBS})

add_subdirectory(src/arrow)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ install(FILES
# Unit tests
#######################################

set(ARROW_TEST_LINK_LIBS arrow_test_util ${ARROW_MIN_TEST_LIBS})
set(ARROW_TEST_LINK_LIBS ${ARROW_MIN_TEST_LIBS})

ADD_ARROW_TEST(array-test)
44 changes: 17 additions & 27 deletions cpp/src/arrow/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,27 @@ install(FILES
status.h
DESTINATION include/arrow/util)

#######################################
# arrow_test_util
#######################################

add_library(arrow_test_util)
target_link_libraries(arrow_test_util
)

SET_TARGET_PROPERTIES(arrow_test_util PROPERTIES LINKER_LANGUAGE CXX)

#######################################
# arrow_test_main
#######################################

add_library(arrow_test_main
test_main.cc)

if (APPLE)
target_link_libraries(arrow_test_main
gtest
arrow_test_util
dl)
set_target_properties(arrow_test_main
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
target_link_libraries(arrow_test_main
gtest
arrow_test_util
pthread
dl
)
if (ARROW_BUILD_TESTS)
add_library(arrow_test_main
test_main.cc)

if (APPLE)
target_link_libraries(arrow_test_main
gtest
dl)
set_target_properties(arrow_test_main
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
target_link_libraries(arrow_test_main
gtest
pthread
dl
)
endif()
endif()

ADD_ARROW_TEST(bit-util-test)
Expand Down
31 changes: 21 additions & 10 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ if ("$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "1")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
endif()

# Top level cmake dir
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
option(PYARROW_BUILD_TESTS
"Build the PyArrow C++ googletest unit tests"
OFF)
endif()

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
Expand Down Expand Up @@ -322,10 +329,12 @@ function(ADD_THIRDPARTY_LIB LIB_NAME)
endfunction()

## GMock
find_package(GTest REQUIRED)
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
ADD_THIRDPARTY_LIB(gtest
STATIC_LIB ${GTEST_STATIC_LIB})
if (PYARROW_BUILD_TESTS)
find_package(GTest REQUIRED)
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
ADD_THIRDPARTY_LIB(gtest
STATIC_LIB ${GTEST_STATIC_LIB})
endif()

## Arrow
find_package(Arrow REQUIRED)
Expand Down Expand Up @@ -391,6 +400,10 @@ endif (UNIX)
# Subdirectories
############################################################

if (UNIX)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()

add_subdirectory(src/pyarrow)
add_subdirectory(src/pyarrow/util)

Expand All @@ -407,10 +420,11 @@ set(LINK_LIBS
arrow
)

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

add_library(pyarrow SHARED
${PYARROW_SRCS})
target_link_libraries(pyarrow ${LINK_LIBS})
set_target_properties(pyarrow PROPERTIES LINKER_LANGUAGE CXX)

if(APPLE)
set_target_properties(pyarrow PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
Expand All @@ -420,9 +434,6 @@ endif()
# Setup and build Cython modules
############################################################

set(USE_RELATIVE_RPATH ON)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)

set(CYTHON_EXTENSIONS
array
config
Expand All @@ -437,7 +448,7 @@ foreach(module ${CYTHON_EXTENSIONS})
list(REMOVE_AT directories -1)

string(REPLACE "." "/" module_root "${module}")
set(module_SRC arrow/${module_root}.pyx)
set(module_SRC pyarrow/${module_root}.pyx)
set_source_files_properties(${module_SRC} PROPERTIES CYTHON_IS_CXX 1)

cython_add_module(${module_name}
Expand All @@ -463,7 +474,7 @@ foreach(module ${CYTHON_EXTENSIONS})
endwhile(${i} GREATER 0)

# for inplace development for now
set(module_install_rpath "${CMAKE_SOURCE_DIR}/arrow/")
#set(module_install_rpath "${CMAKE_SOURCE_DIR}/pyarrow/")

set_target_properties(${module_name} PROPERTIES
INSTALL_RPATH ${module_install_rpath})
Expand Down
38 changes: 0 additions & 38 deletions python/arrow/__init__.py

This file was deleted.

87 changes: 87 additions & 0 deletions python/doc/INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
## Building pyarrow (Apache Arrow Python library)

First, clone the master git repository:

```bash
git clone https://github.com/apache/arrow.git arrow
```

#### System requirements

Building pyarrow requires:

* A C++11 compiler

* Linux: gcc >= 4.8 or clang >= 3.5
* OS X: XCode 6.4 or higher preferred

* [cmake][1]

#### Python requirements

You will need Python (CPython) 2.7, 3.4, or 3.5 installed. Earlier releases and
are not being targeted.

> This library targets CPython only due to an emphasis on interoperability with
> pandas and NumPy, which are only available for CPython.
The build requires NumPy, Cython, and a few other Python dependencies:

```bash
pip install cython
cd arrow/python
pip install -r requirements.txt
```

#### Installing Arrow C++ library

First, you should choose an installation location for Arrow C++. In the future
using the default system install location will work, but for now we are being
explicit:

```bash
export ARROW_HOME=$HOME/local
```

Now, we build Arrow:

```bash
cd arrow/cpp

mkdir dev-build
cd dev-build

cmake -DCMAKE_INSTALL_PREFIX=$ARROW_HOME ..

make

# Use sudo here if $ARROW_HOME requires it
make install
```

#### Install `pyarrow`

```bash
cd arrow/python

python setup.py install
```

> On XCode 6 and prior there are some known OS X `@rpath` issues. If you are
> unable to import pyarrow, upgrading XCode may be the solution.

```python
In [1]: import pyarrow

In [2]: pyarrow.from_pylist([1,2,3])
Out[2]:
<pyarrow.array.Int64Array object at 0x7f899f3e60e8>
[
1,
2,
3
]
```

[1]: https://cmake.org/
38 changes: 38 additions & 0 deletions python/pyarrow/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.

# flake8: noqa

from pyarrow.array import (Array, from_pylist, total_allocated_bytes,
BooleanArray, NumericArray,
Int8Array, UInt8Array,
ListArray, StringArray)

from pyarrow.error import ArrowException

from pyarrow.scalar import (ArrayValue, Scalar, NA, NAType,
BooleanValue,
Int8Value, Int16Value, Int32Value, Int64Value,
UInt8Value, UInt16Value, UInt32Value, UInt64Value,
FloatValue, DoubleValue, ListValue, StringValue)

from pyarrow.schema import (null, bool_,
int8, int16, int32, int64,
uint8, uint16, uint32, uint64,
float_, double, string,
list_, struct, field,
DataType, Field, Schema)
Loading

0 comments on commit 6fdcd49

Please sign in to comment.