-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
83 lines (75 loc) · 2.83 KB
/
setup.py
File metadata and controls
83 lines (75 loc) · 2.83 KB
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
76
77
78
79
80
81
82
83
#! /usr/bin/env python
# System imports
#from distutils.core import *
from setuptools import setup, Extension
import os
import sys
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 = ['polytopewalk/swig/pwalk.i']
includeDirs = [numpy_include]
srcDir = os.path.abspath('polytopewalk/src')
for root, dirnames, filenames in os.walk(srcDir):
# add c++ files in directory to src
absPath = root
globStr = "%s/*.cpp" % absPath
files = glob.glob(globStr)
print(files)
includeDirs.append(absPath)
srcFiles += files
# add c++ files in subdirectories to src
for dirname in ['util', 'external', 'external/Eigen']:
absPath = os.path.join(root, dirname)
print('adding dir to path: %s' % absPath)
globStr = "%s/*.cpp" % absPath
files = glob.glob(globStr)
print(files)
includeDirs.append(absPath)
srcFiles += files
# only one level is needed for os.walk
break
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 "CXX" not in os.environ or os.environ["CC"] == "":
os.environ["CC"] = "clang++"
os.environ["CXX"] = "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 = ["-std=c++11", "-stdlib=libc++",
"-mmacosx-version-min=10.9", "--verbose", "-fno-rtti"]
extra_link_args=["-stdlib=libc++"]
else: # not supported yet. to be tested
os.environ["CC"] = "g++" # force compiling c as c++
extra_args = ["--verbose", "-std=c++11", "-fno-rtti"]
extra_link_args=[]
# inplace extension module
_pwalk = Extension("_pwalk",
srcFiles,
include_dirs=includeDirs,
swig_opts=['-c++'],
extra_compile_args=extra_args,
extra_link_args=extra_link_args)
# NumyTypemapTests setup
setup(name="polytopewalk",
description="Random walk in polytope",
author="Yuansi Chen",
version="1.0",
license="MIT",
packages=['polytopewalk'],
test_suite='nose.collector',
tests_require=['nose'],
ext_modules=[_pwalk])