use cmake to build python module

This commit is contained in:
Thomas Fussell 2017-07-04 16:03:34 -07:00
parent bb96d01f49
commit 16bfbf78f5
6 changed files with 35 additions and 14 deletions

View File

@ -32,7 +32,16 @@ if(TESTS)
endif()
if(ARROW)
add_subdirectory(arrow/xlntarrow)
option(ARROW_INCLUDE_PATH "Include path of Apache Arrow" "")
option(ARROW_LIBRARY_PATH "Library path of Apache Arrow" "")
if(NOT ARROW_INCLUDE_PATH)
message("Missing Apache Arrow include path.")
elseif(NOT ARROW_LIBRARY_PATH)
message("Missing Apache Arrow library path.")
else()
add_subdirectory(arrow/xlntarrow)
add_subdirectory(arrow/xlntpyarrow)
endif()
endif()
add_subdirectory(source)

View File

@ -9,7 +9,9 @@ set(XLNT_ARROW
${CMAKE_CURRENT_SOURCE_DIR}/xlntarrow.cpp)
add_library(xlntarrow SHARED ${XLNT_ARROW})
target_compile_definitions(xlntarrow PRIVATE XLNT_EXPORT=1)
target_link_libraries(xlntarrow PRIVATE xlnt)
target_link_libraries(xlntarrow PRIVATE ${ARROW_LIBRARY_PATH}/arrow.lib)
target_include_directories(xlntarrow PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(xlntarrow PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../miniconda3/include)
target_include_directories(xlntarrow PRIVATE ${ARROW_INCLUDE_PATH})
target_include_directories(xlntarrow PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)

View File

@ -1,11 +1,12 @@
#include <iostream>
#include <arrow/api.h>
#include <xlnt/xlnt_config.hpp>
namespace xlnt {
namespace arrow {
void xlsx2arrow(std::istream &s, ::arrow::Table &table);
void arrow2xlsx(const ::arrow::Table &table, std::istream &s);
void XLNT_API xlsx2arrow(std::istream &s, ::arrow::Table &table);
void XLNT_API arrow2xlsx(const ::arrow::Table &table, std::istream &s);
}
}

View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.2)
project(xlntpyarrow)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/setup.py")
add_custom_target(xlntpyarrow
COMMAND python ${CMAKE_CURRENT_BINARY_DIR}/setup.py build_ext)

View File

@ -1,5 +1,6 @@
from distutils.core import setup, Extension
from distutils import sysconfig
import os
description = """
xlntpyarrow allows Apache Arrow tables to be written to and read from an XLSX
@ -10,24 +11,25 @@ cfg_vars = sysconfig.get_config_vars()
if 'CFLAGS' in cfg_vars:
cfg_vars['CFLAGS'] = cfg_vars['CFLAGS'].replace('-Wstrict-prototypes', '')
project_root = '/root/xlnt'
conda_root = '/root/miniconda3'
project_root = '${CMAKE_SOURCE_DIR}'
conda_root = '${ARROW_INCLUDE_PATH}'
include_dirs = [
os.path.join(project_root, 'include'),
os.path.join(project_root, 'arrow/xlntarrow'),
os.path.join(project_root, 'arrow/xlntpyarrow'),
os.path.join(conda_root, 'include')
conda_root
]
library_dirs = [
os.path.join(project_root, 'build/arrow/xlntarrow'),
os.path.join(project_root, 'build/source'),
os.path.join(conda_root, 'lib')
os.path.join(project_root, 'build/arrow/xlntarrow/Debug'),
os.path.join(project_root, 'build/source/Debug'),
os.path.join(conda_root, '../lib')
]
xlntpyarrow_extension = Extension(
'xlntpyarrow',
['xlntpyarrow.cpp'],
['${CMAKE_CURRENT_SOURCE_DIR}/xlntpyarrow.cpp'],
language = 'c++',
include_dirs = include_dirs,
libraries = [
@ -35,8 +37,8 @@ xlntpyarrow_extension = Extension(
'xlntarrow',
'xlnt'
],
library_dirs = libarary_dirs,
extra_compile_args=['-std=c++11']
library_dirs = library_dirs,
extra_compile_args=['${CMAKE_CXX_FLAGS}']
)
classifiers = [

View File

@ -68,7 +68,6 @@ file(GLOB DETAIL_ROOT_SOURCES ${XLNT_SOURCE_DIR}/detail/*.cpp)
file(GLOB DETAIL_CRYPTOGRAPHY_HEADERS ${XLNT_SOURCE_DIR}/detail/cryptography/*.hpp)
file(GLOB DETAIL_CRYPTOGRAPHY_SOURCES ${XLNT_SOURCE_DIR}/detail/cryptography/*.c*)
file(GLOB DETAIL_EXTERNAL_HEADERS ${XLNT_SOURCE_DIR}/detail/external/*.hpp)
#file(GLOB DETAIL_EXTERNAL_SOURCES ${XLNT_SOURCE_DIR}/detail/external/*.cpp) not needed
file(GLOB DETAIL_HEADER_FOOTER_HEADERS ${XLNT_SOURCE_DIR}/detail/header_footer/*.hpp)
file(GLOB DETAIL_HEADER_FOOTER_SOURCES ${XLNT_SOURCE_DIR}/detail/header_footer/*.cpp)
file(GLOB DETAIL_IMPLEMENTATIONS_HEADERS ${XLNT_SOURCE_DIR}/detail/implementations/*.hpp)