forked from BorgwardtLab/GraphKernels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
81 lines (65 loc) · 1.82 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
#!/usr/bin/env python3
"""
Setup script for graphkernels package. Uses SWIG.
"""
from distutils import ccompiler
import pathlib
import numpy as np
import pkgconfig
import setuptools
import graphkernels
THIS_PATH = pathlib.Path('.')
GK_PATH = THIS_PATH / 'graphkernels'
CPP_PATH = GK_PATH / 'cppkernels'
CPP_FLAGS = [
'-flto',
'-g0',
'-march=native',
'-O3',
'-std=c++17',
'-Wall',
'-Werror',
'-Wextra',
'-Wl,-z,defs',
'-Wpedantic',
'-Wno-cast-function-type',
'-Wno-deprecated-copy',
'-Wno-sign-compare',
'-Wno-unused-parameter',
'-Wno-unused-variable',
]
SWIG_OPTS = ['-builtin', '-c++', '-O', '-py3', '-Wall']
try:
_INFO = pkgconfig.parse('eigen3 python3')
except pkgconfig.PackageNotFoundError as e:
e.message += """
Missing `eigen3` library. Please install it using the
package manager of your operating system.
"""
raise
INCLUDE_DIRS = [np.get_include(), *_INFO['include_dirs'], str(CPP_PATH)]
LIBRARIES = _INFO['libraries']
CPP_SOURCES = [str(s) for s in CPP_PATH.glob('*.cpp')]
def main():
_include_dir_flags = ccompiler.gen_preprocess_options(
macros=[], include_dirs=INCLUDE_DIRS
)
setuptools.setup(
ext_modules=[
setuptools.Extension(
name='_graphkernels',
sources=[str(GK_PATH / 'graphkernels.i'), *CPP_SOURCES],
include_dirs=INCLUDE_DIRS,
libraries=LIBRARIES,
swig_opts=[*SWIG_OPTS, *_include_dir_flags],
extra_compile_args=CPP_FLAGS,
extra_link_args=CPP_FLAGS,
language='c++',
optional=False,
)
],
version=graphkernels.__version__,
)
# Rest of options are specified in `setup.cfg`
if __name__ == '__main__':
main()