forked from jgomezdans/gp_emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
75 lines (59 loc) · 1.81 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
#!/usr/bin/env python
from distutils.core import setup
from setuptools import setup
import distutils.command.build as _build
import setuptools.command.install as _install
import sys
import os
import os.path as op
import distutils.spawn as ds
import distutils.dir_util as dd
def run_cmake():
if ds.find_executable('cmake') is None:
print "CMake is required"
print "Please install cmake version >= 2.6 and re-run setup"
sys.exit(-1)
build_dir = op.join(op.split(__file__)[0], 'build')
dd.mkpath(build_dir)
os.chdir(build_dir)
try:
ds.spawn(['cmake','../'])
except ds.DistutilsExecError:
print "Error while running cmake"
sys.exit(-1)
try:
ds.spawn(['make','-j'])
except ds.DistutilsExecError:
print "Error while compiling"
sys.exit(-1)
class install(_install.install):
def run(self):
cwd = os.getcwd()
run_cmake()
os.chdir(cwd)
_install.install.run(self)
class build(_build.build):
def run(self):
cwd = os.getcwd()
run_cmake()
os.chdir(cwd)
_build.build.run(self)
class benchmark(_install.install):
def run(self):
os.system("python tests/benchmark.py")
class test(_install.install):
def run(self):
cwd = os.getcwd()
testdir = op.join(op.split(__file__)[0], 'tests')
os.chdir(testdir)
os.system("python unit_tests.py")
os.chdir(cwd)
setup(name='gp_emulator',
version='1.4.3',
description='A Python GaussianProcess emulator software package',
author='J Gomez-Dans',
author_email='[email protected]',
url='http://bitbucket.org/gomezdansj/gp_emulator',
packages=['gp_emulator'],
cmdclass={'build':build, 'install':install, 'test':test, 'benchmark':benchmark},
)