-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
93 lines (88 loc) · 3.62 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
90
91
92
93
import os
import platform
from setuptools import setup
from setuptools.extension import Extension
import subprocess
this_dir = os.path.dirname(os.path.abspath(__file__))
dynareadout_dir = os.path.join('lib', 'dynareadout')
c_args = []
cpp_args = []
link_args = []
if platform.system() == "Windows":
cpp_args.append("/std:c++17")
cpp_args.append("/w")
c_args.append("/w")
else:
cpp_args.append("-std=c++17")
cpp_args.append("-w")
c_args.append("-ansi")
c_args.append("-w")
link_args.append("-lpthread")
if platform.system() == "Linux":
link_args.append("-lstdc++fs")
elif platform.system() == "Darwin":
out = subprocess.run(["brew", "--prefix", "boost"], capture_output=True, text=True)
boost_prefix = str(out.stdout).strip()
cpp_args.append(f"-I{boost_prefix}/include")
link_args.append(f"-L{boost_prefix}/lib")
ext_libraries = [[
'dynareadout_c', {
'sources': [
# C Source Files
os.path.join(dynareadout_dir, 'src', 'binary_search.c'),
os.path.join(dynareadout_dir, 'src', 'binout_directory.c'),
os.path.join(dynareadout_dir, 'src', 'binout_glob.c'),
os.path.join(dynareadout_dir, 'src', 'binout_read.c'),
os.path.join(dynareadout_dir, 'src', 'binout.c'),
os.path.join(dynareadout_dir, 'src', 'd3_buffer.c'),
os.path.join(dynareadout_dir, 'src', 'd3plot_data.c'),
os.path.join(dynareadout_dir, 'src', 'd3plot_part_nodes.c'),
os.path.join(dynareadout_dir, 'src', 'd3plot_state.c'),
os.path.join(dynareadout_dir, 'src', 'd3plot.c'),
os.path.join(dynareadout_dir, 'src', 'extra_string.c'),
os.path.join(dynareadout_dir, 'src', 'include_transform.c'),
os.path.join(dynareadout_dir, 'src', 'key.c'),
os.path.join(dynareadout_dir, 'src', 'line.c'),
os.path.join(dynareadout_dir, 'src', 'multi_file.c'),
os.path.join(dynareadout_dir, 'src', 'path_view.c'),
os.path.join(dynareadout_dir, 'src', 'path.c'),
os.path.join(dynareadout_dir, 'src', 'string_builder.c'),
os.path.join(dynareadout_dir, 'src', 'sync.c'),
],
'include_dirs': [
os.path.join(dynareadout_dir, 'src'),
],
'cflags': c_args,
}
]]
dynareadout = Extension(
name='dynareadout',
extra_compile_args=cpp_args,
extra_link_args=link_args,
include_dirs=[
os.path.join(this_dir, 'lib', 'pybind11', 'include'),
os.path.join(dynareadout_dir, 'src'),
os.path.join(dynareadout_dir, 'src', 'cpp')
],
sources=[
# C++ Source Files
os.path.join(dynareadout_dir, 'src', 'cpp', 'binout.cpp'),
os.path.join(dynareadout_dir, 'src', 'cpp', 'd3plot_part.cpp'),
os.path.join(dynareadout_dir, 'src', 'cpp', 'd3plot_state.cpp'),
os.path.join(dynareadout_dir, 'src', 'cpp', 'd3plot.cpp'),
os.path.join(dynareadout_dir, 'src', 'cpp', 'include_transform.cpp'),
os.path.join(dynareadout_dir, 'src', 'cpp', 'key.cpp'),
# C++ Source Files for pybind11 module
os.path.join(dynareadout_dir, 'src', 'python', 'pybind11_binout.cpp'),
os.path.join(dynareadout_dir, 'src', 'python', 'pybind11_d3plot.cpp'),
os.path.join(dynareadout_dir, 'src', 'python', 'pybind11_key.cpp'),
os.path.join(dynareadout_dir, 'src', 'python', 'pybind11_module.cpp'),
],
libraries=['dynareadout_c'],
)
setup(name='dynareadout',
version='24.07',
ext_modules=[dynareadout],
zip_safe=False,
include_package_data=True,
libraries=ext_libraries)