-
Notifications
You must be signed in to change notification settings - Fork 97
/
setup.py
76 lines (65 loc) · 2.27 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
"""The general `setup.py` file."""
# Author: Ioannis Siglidis <[email protected]>
# License: BSD 3 clause
import sys
from platform import system
from setuptools import Extension, find_packages, setup
from numpy import get_include
from Cython.Build import build_ext
# Compile extensions
# Set optimization arguments for compilation
OS = system()
if OS == "Windows":
extra_compile_args = ["/O2", "/w"]
elif OS in ["Linux", "Darwin"]:
extra_compile_args = ["-O3", "-w"]
# Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++.
import distutils.sysconfig
cfg_vars = distutils.sysconfig.get_config_vars()
for key, value in cfg_vars.items():
if type(value) == str:
cfg_vars[key] = value.replace("-Wstrict-prototypes", "")
# Add the _c_functions extension on kernels
ext_address = "./grakel/kernels/_c_functions/"
ext = Extension(
name="grakel.kernels._c_functions",
sources=[
ext_address + "functions.pyx",
ext_address + "src/ArashPartov.cpp",
ext_address + "src/sm_core.cpp",
],
include_dirs=[ext_address + "include", get_include()],
depends=[ext_address + "include/functions.hpp"],
language="c++",
extra_compile_args=extra_compile_args,
)
# Add the bliss library extension for calculating isomorphism
isodir = "./grakel/kernels/_isomorphism/"
blissdir = isodir + "bliss-0.50/"
# The essential bliss source files
blisssrcs = ["graph.cc", "heap.cc", "orbit.cc", "partition.cc", "uintseqhash.cc"]
blisssrcs = [blissdir + src for src in blisssrcs]
pn = str(sys.version_info[0])
# Compile intpybliss
intpybliss = Extension(
name="grakel.kernels._isomorphism.intpybliss",
define_macros=[("MAJOR_VERSION", "0"), ("MINOR_VERSION", "50beta")],
include_dirs=[blissdir],
language="c++",
extra_compile_args=extra_compile_args,
sources=[isodir + "intpyblissmodule_" + pn + ".cc"] + blisssrcs,
)
# Make bliss extension
bliss = Extension(
name="grakel.kernels._isomorphism.bliss",
include_dirs=[isodir],
language="c++",
extra_compile_args=extra_compile_args,
sources=[isodir + "bliss.pyx"],
)
setup(
packages=find_packages(),
package_data={"grakel.tests": ["data/Cuneiform/*.txt", "data/MUTAG/*.txt"]},
ext_modules=[intpybliss, bliss, ext],
cmdclass={"build_ext": build_ext},
)