-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
executable file
·50 lines (41 loc) · 1.54 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import numpy
import subprocess
import os
import numpy # noqa
# compile kernel/libG6K.so if not done already
subprocess.check_call("make -C kernel",shell=True)
# read actual values of all build variables from kernel/Makefile
makefile_defs = subprocess.check_output("make -C kernel printvariables | grep '='", shell=True).splitlines()
def read_from_makefile(field):
global makefile_defs
data = [line for line in makefile_defs if line.startswith(field)][0]
data = "=" .join(data.split("=")[1:])
data = data.strip()
data = [arg for arg in data.split(" ") if arg.strip()]
return data
extra_compile_args = read_from_makefile("CXXFLAGS")
extra_link_args = read_from_makefile("LDFLAGS") + read_from_makefile("LIBADD")
kwds = {
"language": "c++",
"extra_compile_args": extra_compile_args,
"extra_link_args": extra_link_args,
"libraries": ["gmp", "pthread", "G6K"],
"include_dirs": [numpy.get_include(), "parallel-hashmap"]
}
extensions = [
Extension("g6k.siever", ["g6k/siever.pyx"], **kwds),
Extension("g6k.siever_params", ["g6k/siever_params.pyx"], **kwds)
]
setup(
name="G6K",
version="0.0.1",
ext_modules=cythonize(extensions, compiler_directives={'binding': True,
'embedsignature': True,
'language_level': 2}),
packages=[],
)