forked from sibyl-team/sib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
78 lines (60 loc) · 1.71 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
from setuptools import setup, Extension
import sys
import setuptools
import unittest
import os
import subprocess
#decomment the 2 line below
#if you have problems in compiling sib
#os.environ["CC"] = "c++-9"
#os.environ["CXX"] = "c++-9"
def sib_test():
test_loader = unittest.TestLoader()
test_suite = test_loader.discover('test', pattern='*_tests.py')
return test_suite
__version__ = '0.1.2'
COMPILE_FLAGS = "-fPIC -std=c++11 -Wall -O3 -g -fopenmp"
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
def __str__(self):
import pybind11
return pybind11.get_include()
ext_modules = [
Extension(
'_sib',
["bp.cpp",
#"bp.h",
#"cavity.h",
"params.cpp",
#"params.h",
"pysib.cpp",
"drop.cpp"
],
define_macros=[('VERSION', '"' + subprocess.Popen(['git', 'show', '-s',
'--pretty=%h %ad %d'],
stdout=subprocess.PIPE).communicate()[0].decode()[:-1] + '"')],
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
"./lib",
],
extra_compile_args=[*COMPILE_FLAGS.split(" ")],
extra_link_args=["-lgomp", "-lm"],
language='c++'
),
]
setup(
name="sib",
version=__version__,
author="Sybil Team",
description="""Belief Propagation for inference in epidemics""",
py_modules=[
"sib"
],
ext_modules=ext_modules,
setup_requires=['pybind11>=2.5.0'],
test_suite="setup.sib_test",
)