forked from JGCRI/gcamwrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
89 lines (79 loc) · 3.21 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os
import platform
import shutil
from setuptools import setup, find_packages, Extension
def readme():
with open('README.md') as f:
return f.read()
def get_requirements():
with open('requirements.txt') as f:
return f.read().split()
GCAM_INCLUDE = os.environ["GCAM_INCLUDE"]
GCAM_LIB = os.environ["GCAM_LIB"]
BOOST_INCLUDE = os.environ["BOOST_INCLUDE"]
BOOST_LIB = os.environ["BOOST_LIB"]
TBB_INCLUDE = os.environ["TBB_INCLUDE"]
TBB_LIB = os.environ["TBB_LIB"]
EIGEN_INCLUDE = os.environ["EIGEN_INCLUDE"]
JAVA_INCLUDE = os.environ["JAVA_INCLUDE"]
JAVA_PLATFORM_INCLUDE = JAVA_INCLUDE + '/' + os.uname()[0].lower()
JAVA_LIB = os.environ["JAVA_LIB"]
# the exact set of libs to link will be platform specific due to boost
gcam_libs = ['gcam', 'hector', 'jvm', 'tbb', 'tbbmalloc', 'tbbmalloc_proxy']
gcam_compile_args = []
gcam_link_args = []
if platform.system() == "Windows" :
# boost "auto links" on Windows with compiler specific names
# so do not include any of them
gcam_compile_args = []
else :
gcam_libs += ['boost_system', 'boost_filesystem']
# boost appends the python version to the boost python library name
py_version_suffix = ''.join(platform.python_version_tuple()[0:2])
gcam_libs += [lib + py_version_suffix for lib in ['boost_python', 'boost_numpy']]
# ensure we use the correct c++ std
gcam_compile_args += ['-std=c++14']
# add rpath info to find the dynamic linked libs
gcam_link_args += ['-Wl,-rpath,'+JAVA_LIB, '-Wl,-rpath,'+BOOST_LIB, '-Wl,-rpath,'+TBB_LIB]
gcam_module = Extension(
'gcam_module',
sources = ['src/gcam.cpp',
'src/solution_debugger.cpp',
'src/query_processor_base.cpp',
'src/set_data_helper.cpp',
'src/get_data_helper.cpp'],
include_dirs=['inst/include', GCAM_INCLUDE, BOOST_INCLUDE, TBB_INCLUDE, EIGEN_INCLUDE, JAVA_INCLUDE, JAVA_PLATFORM_INCLUDE],
library_dirs=[GCAM_LIB, BOOST_LIB, TBB_LIB, JAVA_LIB],
libraries=gcam_libs,
define_macros=[('NDEBUG', '1'),
('BOOST_DATE_TIME_NO_LIB', '1'),
('FUSION_MAX_VECTOR_SIZE', '30'),
('BOOST_MATH_TR1_NO_LIB', '1'),
('BOOST_PYTHON_STATIC_LIB', '1'),
('BOOST_NUMPY_STATIC_LIB', '1')],
extra_link_args=gcam_link_args,
language='c++',
extra_compile_args = gcam_compile_args
)
try:
# workaround to deal with R and Python being PITA about package data
shutil.copy(os.path.join('inst', 'extdata', 'query_library.yml'), 'gcamwrapper')
setup(
name='gcamwrapper',
version='0.1.0',
packages=find_packages(),
ext_modules=[gcam_module],
install_requires=get_requirements(),
#include_package_data=True,
package_data={'gcamwrapper': ['query_library.yml']},
url='https://github.com/JGCRI/gcamwrapper',
license='ECL 2',
author='Pralit Patel, Chris R. Vernon',
author_email='pralit.patel@pnnl.gov, chris.vernon@pnnl.gov',
description='Python API for GCAM',
long_description=readme(),
long_description_content_type='text/markdown',
python_requires='>=3.6.*, <4'
)
finally:
os.unlink(os.path.join('gcamwrapper', 'query_library.yml'))