-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
70 lines (59 loc) · 2.24 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
#! /usr/bin/env python
# System imports
from distutils.core import *
from distutils import sysconfig
import glob
# Third-party modules - we depend on numpy for everything
import numpy
# Obtain the numpy include directory. This logic works across numpy versions.
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
# gather up all the source files
srcFiles = ['example.i']
includeDirs = [numpy_include]
srcDir = os.path.abspath('src')
for root, dirnames, filenames in os.walk(srcDir):
for dirname in dirnames:
absPath = os.path.join(root, dirname)
print('adding dir to path: %s' % absPath)
globStr = "%s/*.c*" % absPath
files = glob.glob(globStr)
print(files)
includeDirs.append(absPath)
srcFiles += files
print("includeDirs:")
print(includeDirs)
print("srcFiles:")
print(srcFiles)
# set the compiler flags so it'll build on different platforms (feel free
# to file a pull request with a fix if it doesn't work on yours)
if sys.platform == 'darwin':
# default to clang++ as this is most likely to have c++11 support on OSX
if "CC" not in os.environ or os.environ["CC"] == "":
os.environ["CC"] = "clang++"
# we need to set the min os x version for clang to be okay with
# letting us use c++11; also, we don't use dynamic_cast<>, so
# we can compile without RTTI to avoid its overhead
extra_args = ["-stdlib=libc++",
"-mmacosx-version-min=10.7","-fno-rtti",
"-std=c++0x"] # c++11
else: # only tested on travis ci linux servers
os.environ["CC"] = "g++" # force compiling c as c++
extra_args = ['-std=c++0x','-fno-rtti']
# inplace extension module
_example = Extension("_example",
srcFiles,
include_dirs=includeDirs,
swig_opts=['-c++'],
extra_compile_args=extra_args,
)
# NumyTypemapTests setup
setup( name = "SWIG Numpy Example",
description = "Example project to wrap a C/C++ library in Numpy",
author = "D Blalock",
version = "1.0",
license = "MIT",
ext_modules = [_example]
)