Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
EXECUTE_PROCESS(COMMAND ln ${MORE_ARGS} -sf ${BUILD_OUTPUT_ROOT_DIRECTORY}
${CMAKE_CURRENT_BINARY_DIR}/build/latest)
else()
set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUBDIR_NAME}/")
set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUBDIR_NAME}/")
endif()

# where to put generated archives (.a files)
Expand Down
9 changes: 9 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ python setup.py build_ext --inplace
py.test pyarrow
```

To change the build type, use the `--build-type` option:

```bash
python setup.py build_ext --build-type=release --inplace
```

To pass through other build options to CMake, set the environment variable
`$PYARROW_CMAKE_OPTIONS`.

#### Build the documentation

```bash
Expand Down
34 changes: 16 additions & 18 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@
# Check if we're running 64-bit Python
is_64_bit = sys.maxsize > 2**32

# Check if this is a debug build of Python.
# if hasattr(sys, 'gettotalrefcount'):
# build_type = 'Debug'
# else:
# build_type = 'Release'

build_type = 'Debug'

if Cython.__version__ < '0.19.1':
raise Exception('Please upgrade to Cython 0.19.1 or newer')

Expand Down Expand Up @@ -104,13 +96,14 @@ def run(self):
# github.com/libdynd/dynd-python

description = "Build the C-extensions for arrow"
user_options = ([('extra-cmake-args=', None,
'extra arguments for CMake')] +
_build_ext.user_options)
user_options = ([('extra-cmake-args=', None, 'extra arguments for CMake'),
('build-type=', None, 'build type (debug or release)')]
+ _build_ext.user_options)

def initialize_options(self):
_build_ext.initialize_options(self)
self.extra_cmake_args = os.environ.get('PYARROW_CMAKE_OPTIONS', '')
self.build_type = os.environ.get('PYARROW_BUILD_TYPE', 'debug').lower()

CYTHON_MODULE_NAMES = [
'array',
Expand Down Expand Up @@ -152,9 +145,12 @@ def _run_cmake(self):
static_lib_option = ''
build_tests_option = ''

build_type_option = '-DCMAKE_BUILD_TYPE={0}'.format(self.build_type)

if sys.platform != 'win32':
cmake_command = ['cmake', self.extra_cmake_args, pyexe_option,
build_tests_option,
build_type_option,
static_lib_option, source]

self.spawn(cmake_command)
Expand All @@ -170,7 +166,8 @@ def _run_cmake(self):
# Generate the build files
extra_cmake_args = shlex.split(self.extra_cmake_args)
cmake_command = (['cmake'] + extra_cmake_args +
[source, pyexe_option,
[source,
pyexe_option,
static_lib_option,
build_tests_option,
'-G', cmake_generator])
Expand All @@ -179,7 +176,7 @@ def _run_cmake(self):

self.spawn(cmake_command)
# Do the build
self.spawn(['cmake', '--build', '.', '--config', build_type])
self.spawn(['cmake', '--build', '.', '--config', self.build_type])

if self.inplace:
# a bit hacky
Expand All @@ -188,14 +185,15 @@ def _run_cmake(self):
# Move the built libpyarrow library to the place expected by the Python
# build
if sys.platform != 'win32':
name, = glob.glob('libpyarrow.*')
name, = glob.glob(pjoin(self.build_type, 'libpyarrow.*'))
try:
os.makedirs(pjoin(build_lib, 'pyarrow'))
except OSError:
pass
shutil.move(name, pjoin(build_lib, 'pyarrow', name))
shutil.move(name,
pjoin(build_lib, 'pyarrow', os.path.split(name)[1]))
else:
shutil.move(pjoin(build_type, 'pyarrow.dll'),
shutil.move(pjoin(self.build_type, 'pyarrow.dll'),
pjoin(build_lib, 'pyarrow', 'pyarrow.dll'))

# Move the built C-extension to the place expected by the Python build
Expand Down Expand Up @@ -239,10 +237,10 @@ def get_ext_built(self, name):
if sys.platform == 'win32':
head, tail = os.path.split(name)
suffix = sysconfig.get_config_var('SO')
return pjoin(head, build_type, tail + suffix)
return pjoin(head, self.build_type, tail + suffix)
else:
suffix = sysconfig.get_config_var('SO')
return name + suffix
return pjoin(self.build_type, name + suffix)

def get_names(self):
return self._found_names
Expand Down