-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
50 lines (39 loc) · 1.43 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
import setuptools
import platform
import subprocess
from setuptools.command.build import build
from setuptools import find_namespace_packages
'''
Template from https://python.plainenglish.io/building-hybrid-python-c-packages-8985fa1c5b1d
based an modification of https://www.benjack.io/2017/06/12/python-cpp-tests.html
'''
libname='qoptkit'
class CustomBuild(build):
def run(self):
try:
subprocess.check_output(['g++', '--version'])
except OSError:
raise RuntimeError("g++ must be installed to build qoptkit." )
if platform.system() != "Darwin":
try:
subprocess.check_output(['ar', '--version'])
except OSError:
raise RuntimeError("ar tool must be installed to build qoptkit." )
try:
subprocess.check_output(['make', '--version'])
except OSError:
raise RuntimeError("Make must be installed to build qoptkit." )
try:
subprocess.check_call(['make'],cwd='./src/' + libname )
except OSError:
raise RuntimeError("Compilation failed. Check C++ dependencies are all installed. ( In particular Eigen3 library )" )
setuptools.setup(
cmdclass={
"build": CustomBuild,
},
packages=find_namespace_packages(where="src"),
package_dir={"": "src"},
package_data={
libname : ["*"],
}
)