Skip to content

Commit 812768f

Browse files
committed
Build native.pyx stub and libpandas.so
1 parent af4c697 commit 812768f

File tree

3 files changed

+56
-16
lines changed

3 files changed

+56
-16
lines changed

CMakeLists.txt

+53-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
# Copyright 2014 Cloudera, Inc.
1+
# Assembled from BSD/MIT/Apache-licensed code from a variety of copyright
2+
# holders, including at least
23
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
4+
# Copyright 2012-25 Cloudera, Inc.
5+
# Copyright (C) 2011-15 DyND Developers
6+
# Copyright (C) 2012-15 Continuum Analytics, Inc.
147

158
cmake_minimum_required(VERSION 2.7)
169

@@ -518,6 +511,7 @@ include_directories(SYSTEM
518511
${GFLAGS_INCLUDE_DIR}
519512
${NUMPY_INCLUDE_DIRS}
520513
${PYTHON_INCLUDE_DIRS}
514+
pandas/
521515
src)
522516

523517
############################################################
@@ -572,9 +566,8 @@ endif (UNIX)
572566
add_subdirectory(src/pandas)
573567
add_subdirectory(src/pandas/util)
574568

575-
# NumPy shared library must be manually imported / linked
569+
# Python and NumPy shared libraries must be manually imported / linked
576570
set(LINK_LIBS
577-
python
578571
)
579572

580573
add_library(pandas SHARED
@@ -584,3 +577,49 @@ set_target_properties(pandas PROPERTIES LINKER_LANGUAGE CXX)
584577

585578
# install(TARGETS pandas
586579
# LIBRARY DESTINATION lib)
580+
581+
############################################################
582+
# Setup and build Cython modules
583+
############################################################
584+
585+
foreach(pyx_api_file
586+
pandas/native.pyx)
587+
set_source_files_properties(${pyx_api_file} PROPERTIES CYTHON_API 1)
588+
endforeach(pyx_api_file)
589+
590+
foreach(module native)
591+
string(REPLACE "." ";" directories ${module})
592+
list(GET directories -1 module_name)
593+
list(REMOVE_AT directories -1)
594+
595+
string(REPLACE "." "/" module_root "${module}")
596+
set(module_SRC pandas/${module_root}.pyx)
597+
set_source_files_properties(${module_SRC} PROPERTIES CYTHON_IS_CXX 1)
598+
599+
cython_add_module(${module_name}
600+
${module_name}_pyx
601+
${module_name}_output
602+
${module_SRC})
603+
604+
if (directories)
605+
string(REPLACE ";" "/" module_output_directory ${directories})
606+
set_target_properties(${module_name} PROPERTIES
607+
LIBRARY_OUTPUT_DIRECTORY ${module_output_directory})
608+
endif()
609+
610+
if(APPLE)
611+
set(module_install_rpath "@loader_path")
612+
else()
613+
set(module_install_rpath "$ORIGIN")
614+
endif()
615+
list(LENGTH directories i)
616+
while(${i} GREATER 0)
617+
set(module_install_rpath "${module_install_rpath}/..")
618+
math(EXPR i "${i} - 1" )
619+
endwhile(${i} GREATER 0)
620+
set_target_properties(${module_name} PROPERTIES
621+
INSTALL_RPATH ${module_install_rpath})
622+
target_link_libraries(${module_name} pandas)
623+
endforeach(module)
624+
625+
add_dependencies(pandas native_pyx)

cmake_modules/toolchain.cmake

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ if ("$ENV{DISABLE_NATIVE_TOOLCHAIN}" STREQUAL "")
2020
set(ENV{GOOGLETEST_PREFIX}
2121
"$ENV{NATIVE_TOOLCHAIN}/googletest-$ENV{GOOGLETEST_VERSION}")
2222

23-
message(STATUS "FOO: $ENV{GLOG_PREFIX}")
24-
2523
# Setting SYSTEM_GCC will use the toolchain dependencies compiled with the original
2624
# host's compiler.
2725
if ("$ENV{SYSTEM_GCC}" STREQUAL "")

pandas/native.pyx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# cython: profile=False
2+
3+
cimport numpy

0 commit comments

Comments
 (0)