This repository has been archived by the owner on Jun 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
64 lines (53 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
try:
from setuptools import setup
from setuptools.command.build import build
from setuptools.command.build_clib import build_clib
except ImportError:
from distutils.core import setup
from distutils.command.build import build
from distutils.command.build_clib import build_clib
from os import path, chdir
import subprocess
import shutil
import versioneer
class CMakeBuilder(build_clib):
def run(self):
root_dir = path.dirname(path.realpath(__file__))
build_dir = path.realpath(self.build_temp)
clib_dir = path.realpath(self.build_clib)
# Run cmake and make in temp dir
self.mkpath(build_dir)
chdir(build_dir)
cmake_cmd = "cmake %s" % root_dir
if subprocess.call(cmake_cmd, shell=True) != 0:
raise EnvironmentError("Error calling cmake. Check that it's installed? Check the path provided to the Opesci-FD root directory?")
if subprocess.call("make") != 0:
raise EnvironmentError("Error calling make")
chdir(root_dir)
# Copy lib and include directories to opesci package
self.copy_tree(path.join(root_dir, 'include'),
path.join(clib_dir, 'opesci/include'))
self.copy_tree(path.join(build_dir, 'lib'),
path.join(clib_dir, 'opesci/lib'))
class PythonBuilder(build):
def run(self):
# Pass build_lib to the CMake builder as build_clib
build_clib = self.get_finalized_command('build_clib')
build_clib.build_clib = self.build_lib
build_clib.run()
# Invoke the actual Python build
build.run(self)
setup(name='opesci',
version = versioneer.get_version(),
description = """Framework for automatic generation of
Finite Difference models for use in seismic imaging.""",
author = "Imperial College London and SENAI Cimatec",
author_email = "[email protected]",
url = "http://opesci.org",
packages = ['opesci'],
package_data = {'opesci' : ['lib/*.so', 'include/*.h',
'templates/*.txt',
'templates/staggered/*.txt',
'templates/staggered/*.cpp']},
cmdclass = {'build_clib': CMakeBuilder, 'build': PythonBuilder}
)