-
Notifications
You must be signed in to change notification settings - Fork 10
/
install.py
163 lines (152 loc) · 6.64 KB
/
install.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
######################## Install Script v.1.0. #########################
# #
# This script installs exonailer in your computer #
# #
########################################################################
p_name = "exonailer"
import glob
import sys
import os
import shutil
import subprocess
def CheckLibraries():
try:
import numpy
except ImportError:
print " ----------------------------------------------------------"
print ' ERROR: '+p_name+' will not be installed in your system because'
print ' numpy is not installed in your system.'
print ' To install it, go to: http://www.numpy.org/\n\n'
sys.exit(1)
print " > Numpy is ok!"
try:
import scipy
except ImportError:
print " ----------------------------------------------------------"
print ' ERROR: '+p_name+' will not be installed in your system because'
print ' scipy is not installed in your system.'
print ' To install it, go to: http://www.scipy.org/\n\n'
sys.exit(1)
print " > Scipy is ok!"
try:
import astropy
except ImportError:
print " ----------------------------------------------------------"
print ' ERROR: '+p_name+' will not be installed in your system because'
print ' astropy is not installed in your system.'
print ' To install it, go to: http://www.astropy.org/ \n\n'
sys.exit(1)
print " > Astropy is ok!"
try:
import batman
except ImportError:
print " ----------------------------------------------------------"
print ' ERROR: '+p_name+' will not be installed in your system because'
print ' batman is not installed in your system.'
print ' To install it, go to: http://astro.uchicago.edu/~kreidberg/batman/ \n\n'
sys.exit(1)
print " > batman is ok!"
try:
import emcee
except ImportError:
print " ----------------------------------------------------------"
print ' ERROR: '+p_name+' will not be installed in your system because'
print ' emcee is not installed in your system.'
print ' To install it, go to: http://dan.iel.fm/emcee/current/ \n\n'
sys.exit(1)
print " > emcee is ok!"
try:
import radvel
except ImportError:
print " ----------------------------------------------------------"
print ' ERROR: '+p_name+' will not be installed in your system because'
print ' radvel is not installed in your system.'
print ' To install it, go to: http://radvel.readthedocs.io/en/latest/ \n\n'
sys.exit(1)
print " > radvel is ok!"
try:
import radvel
except ImportError:
print " ----------------------------------------------------------"
print ' ERROR: '+p_name+' will not be installed in your system because'
print ' radvel is not installed in your system.'
print ' To install it, go to: http://radvel.readthedocs.io/en/latest/ \n\n'
sys.exit(1)
print " > radvel is ok!"
def Build(directory):
# We obtain al files and folders of the current directory...
files_and_folders = glob.glob(directory+'/*')
CFileFound = False
SetupFileFound = False
# ...and we check each folder or file:
for cf in files_and_folders:
# We search for files named Proceso_f2py, or for the setup.py - file.c
# combination. If present, we build the process.
pf2py = 'Proceso_f2py'
stp = 'setup.py'
if( cf[-len(pf2py):] == pf2py ):
print " > Fortran code found in directory "+directory+". Building..."
cwd = os.getcwd()
os.chdir(directory)
subprocess.Popen('chmod u+wrx Proceso_f2py',shell = True).wait()
subprocess.Popen('chmod g+wrx Proceso_f2py',shell = True).wait()
subprocess.Popen('chmod o+wrx Proceso_f2py',shell = True).wait()
p = subprocess.Popen('./Proceso_f2py',stdout = subprocess.PIPE, stderr = subprocess.PIPE,shell = True)
p.wait()
if(p.returncode != 0 and p.returncode != None):
print " ----------------------------------------------------------"
print " > ERROR: "+p_name+" couldn't be installed."
print " > Problem building code in "+directory+". The error was:\n"
out, err = p.communicate()
print err
print " > If you can't solve the problem, please communicate"
print " > with the "+p_name+" team for help.\n\n"
os.chdir(cwd)
sys.exit()
os.chdir(cwd)
print " >...done!"
elif( cf[-len(stp):] == stp ):
SetupFileFound = True
elif( cf[-2:] == '.c' ):
CFileFound = True
if( SetupFileFound and CFileFound ):
print " > C code found in directory "+directory+". Building..."
cwd = os.getcwd()
os.chdir(directory)
p = subprocess.Popen('python setup.py build',stdout = subprocess.PIPE, stderr = subprocess.PIPE,shell = True)
p.wait()
if(p.returncode != 0 and p.returncode != None):
print " ----------------------------------------------------------"
print " > ERROR: "+p_name+" couldn't be installed."
print " > Problem building code in "+directory+". The error was:\n"
out, err = p.communicate()
print spaced(err,"\t \t")
print " > If you can't solve the problem, please communicate"
print " > with the "+p_name+" team for help.\n \n"
os.chdir(cwd)
sys.exit()
libfolder = getDirs('build/.')
for name in libfolder:
if(name[0:3]=='lib'):
filename = glob.glob('build/'+name+'/*')
shutil.copy2(filename[0],'../.')
shutil.rmtree('build')
os.chdir(cwd)
print ' >...done!'
break
def getDirs(foldername):
return os.walk(foldername).next()[1]
def spaced(input,space):
fixed = False
i = 0
input = space+input
while(not fixed):
if(input[i:i+1] == '\n'):
input = input[0:i+1]+space+input[i+1:]
i = i + len(space)
i = i + 1
if(i == len(input)-1):
fixed = True
return input
CheckLibraries()
Build('utilities/flicker-noise')