-
Notifications
You must be signed in to change notification settings - Fork 4
/
macscript.py
executable file
·58 lines (46 loc) · 1.68 KB
/
macscript.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
#!/usr/bin/env python
from distutils.core import setup, Extension
from shutil import copy
import glob
import os
import re
import sys
'''
Big old hack to get around the problems caused by Anaconda and its implementation of gcc
and also to deal with the fact clang gets confused by the -std flag
(I shouldn't be the one to have to sort this out should I?)
'''
oldpath = os.environ['PATH']
pathnames = re.split(":",oldpath)
newpath = ""
for pn in pathnames:
if 'naconda' not in pn:
newpath += pn + ":"
newpath = newpath[:-1]
os.environ['PATH']=newpath
skmodule = Extension('skimage',
sources=['source/pyskimage.cpp', 'source/skimage.cpp'],
language='c++',
extra_compile_args=['-std=c++11'])
setup(ext_modules=[skmodule])
bascmodule = Extension('bascmod',
sources=['source/pybasc.cpp', 'source/skimage.cpp',
'bayesys/bayesys3.c', 'bayesys/random.c',
'bayesys/hilbert.c', 'bayesys/app.c',
'source/options.cpp'],
language='c++')
setup(ext_modules=[bascmodule])
filelist = glob.glob("build/lib*")
if "PYTHONPATH" in os.environ:
pypath = os.environ["PYTHONPATH"]
newpypath = "/".join(re.split("/",os.path.realpath(__file__))[:-1])
newpypath += "/build/"
newpypath += re.split("/",filelist[0])[-1]
print("To set your python path: PYTHONPATH=$PYTHONPATH:"+newpypath+"\n")
libraries = glob.glob(filelist[0]+"/*.so")
for lib in libraries:
newlib = re.split("/", lib)[-1]
newlib = newlib[0:7]+".so"
print(lib, newlib)
copy(lib,newlib)
os.environ['PATH']=oldpath