-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·77 lines (69 loc) · 3.21 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
76
77
#!/usr/bin/env python2.7
import glob
import numpy as np
import os
import platform
from os.path import abspath
from setuptools import setup, Extension
# Borrowed from https://bitbucket.org/django/django/src/tip/setup.py
def fullsplit(path, result=None):
"""
Split a pathname into components (the opposite of os.path.join) in a
platform-neutral way.
"""
if result is None:
result = []
head, tail = os.path.split(path)
if head == "":
return [tail] + result
if head == path:
return result
return fullsplit(head, [tail] + result)
def find_tbb():
include_path = glob.glob("vendor/tbb*/include")
assert include_path, "Can't find TBB include directory."
assert len(include_path) == 1, "Multiple versions of TBB installed? Ambiguous include path"
library_path = glob.glob("vendor/tbb*/build/*_release/")
assert library_path, ("Can't find TBB library directory.\n\n"
" Please build the included version of TBB first.\n"
" Go into vendor/tbb44_20151115oss/ and run 'make'.")
assert len(library_path) == 1, "Multiple versions of TBB built? Ambiguous library path"
return map(abspath, (include_path[0], library_path[0]))
if __name__ == "__main__":
packages, data_files, extensions = [], [], []
root_dir = os.path.dirname(__file__)
if root_dir != "":
os.chdir(root_dir)
for dirpath, dirnames, filenames in os.walk("sgdf"):
if os.path.basename(dirpath).startswith("_"):
c_sources = filter(lambda name: name.endswith(".c") or name.endswith(".cpp"), filenames)
if c_sources:
extension_name = ".".join(fullsplit(dirpath))
print "Extension:", extension_name
tbb_include_dir, tbb_library_path = find_tbb()
extension_kwargs = dict(include_dirs=[np.get_include(), tbb_include_dir],
library_dirs=[tbb_library_path],
libraries=["tbb"],
extra_compile_args=["-std=c++11", "-g", "-O3"])
if platform.system() == "Darwin":
tbb_link_arg = "-Wl,-rpath,%s" % tbb_library_path
extension_kwargs.setdefault("extra_link_args", []).append(tbb_link_arg)
extension = Extension(extension_name,
map(lambda name: os.path.join(dirpath, name), c_sources),
**extension_kwargs)
extensions.append(extension)
elif "__init__.py" in filenames:
packages.append(".".join(fullsplit(dirpath)))
elif filenames:
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
setup(name="sgdf",
version="0.1.dev0",
description="Streaming gradient domain fusion",
url="https://github.com/sarajkim/sgdf",
scripts=glob.glob("bin/sgdf*"),
packages=packages,
data_files=data_files,
ext_modules=extensions,
install_requires=["matplotlib", "numpy", "scipy", "Pillow"],
test_suite="nose.collector",
tests_require=["nose", "unittest2"])