forked from nanshe-org/spams-python
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
88 lines (76 loc) · 2.78 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
78
79
80
81
82
83
84
85
86
87
88
import os
#os.environ['DISTUTILS_DEBUG'] = "1"
from distutils.core import setup, Extension
import distutils.util
import numpy
# includes numpy : package numpy.distutils , numpy.get_include()
# python setup.py build --inplace
# python setup.py install --prefix=dist,
incs = ['.'] + map(lambda x: os.path.join('spams',x),[ 'linalg', 'prox', 'decomp', 'dictLearn']) + [numpy.get_include()] + ['/usr/include/python2.7/']
osname = distutils.util.get_platform()
cc_flags = ['-fPIC', '-fopenmp']
link_flags = ['-fopenmp', '-s' ]
libs = ['stdc++', 'blas', 'lapack' ]
libdirs = []
if osname.startswith("macosx"):
cc_flags = ['-fPIC', '-fopenmp','-m32']
link_flags = ['-m32', '-framework', 'Python']
if osname.startswith("win32"):
cc_flags = ['-fPIC', '-fopenmp','-DWIN32']
link_flags = ['-fopenmp', '-mwindows']
path = os.environ['PATH']
os.environ['PATH'] = 'C:/MinGW/bin;' + path
libs = ['stdc++', 'Rblas', 'Rlapack' ]
libdirs = ['C:/Program Files/R/R-2.15.1/bin/i386']
if osname.startswith("win-amd64"):
cc_flags = ['-openmp', '-EHsc', '-DWIN32', '-DCYGWIN', '-DWINDOWS', '-I','C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/include']
link_flags = []
libs = [ 'Rblas', 'Rlapack' ]
libdirs = ['C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/lib/amd64','C:/Program Files/R/R-2.15.1/bin/x64']
##path = os.environ['PATH']; print "XX OS %s, path %s" %(osname,path)
spams_wrap = Extension(
'_spams_wrap',
sources = ['spams_wrap.cpp'],
include_dirs = incs,
extra_compile_args = ['-DNDEBUG', '-DUSE_BLAS_LIB'] + cc_flags,
library_dirs = libdirs,
libraries = libs,
# strip the .so
extra_link_args = link_flags,
language = 'c++',
depends = ['spams.h'],
)
def mkhtml(d = None,base = 'sphinx'):
if d == None:
d = base
else:
d = os.path.join(base,d)
if not os.path.isdir(base):
return []
hdir = d
l1 = os.listdir(hdir)
l = []
for s in l1:
s = os.path.join(d,s)
if not os.path.isdir(s):
l.append(s)
return l
setup (name = 'spams',
version= '2.5',
description='Python interface for SPAMS',
author = 'Julien Mairal',
author_email = 'nomail',
url = 'http://',
ext_modules = [spams_wrap,],
py_modules = ['spams', 'spams_wrap', 'myscipy_rand'],
# scripts = ['test_spams.py'],
data_files = [
('test',['test_spams.py', 'test_decomp.py', 'test_dictLearn.py', 'test_linalg.py', 'test_prox.py', 'test_utils.py']),
('doc',['doc_spams.pdf', 'python-interface.pdf']),
('doc/sphinx/_sources',mkhtml('_sources')),
('doc/sphinx/_static',mkhtml('_static')),
('doc/sphinx',mkhtml()),
('doc/html',mkhtml(base = 'html')),
('extdata',['boat.png', 'lena.png'])
],
)