source: trunk/bin/install@ 1198

Last change on this file since 1198 was 1195, checked in by mar637, 18 years ago

added module test action. fixed makedist target including install script.

  • Property svn:executable set to *
File size: 3.6 KB
Line 
1#!/usr/bin/env python
2
3import distutils.sysconfig as dist
4import shutil
5import os
6import sys
7import getopt
8
9def usage():
10 print """Usage:
11 ./install [-p <prefix for asap binary>]
12 [-m <where to install python module>]
13 [-h] this message
14 """
15
16def get_libs(lib='_asap.so'):
17 lddcommand = "/usr/bin/ldd"
18 lddopts = ""
19 if (sys.platform == "darwin"):
20 lddcommand = "otool"
21 lddopts = "-L"
22 if not os.path.isfile(lddcommand):
23 raise IOError("ldd/otool is not available")
24 if not os.path.exists(lib):
25 raise IOError("File %s not found" %lib)
26 p = os.popen(lddcommand+" "+lddopts+" "+lib)
27 resolved = []
28 unresolved = []
29 for l in p.readlines():
30 lsp = l.split()
31 if lsp[2] == "not":
32 unresolved.append(lsp[0])
33 else:
34 resolved.append(lsp[2])
35 return resolved, unresolved
36
37try:
38 opts, args = getopt.getopt(sys.argv[1:], "p:m:h",
39 ["exec-prefix=", "module-dir=", "help"])
40
41except getopt.GetoptError:
42 usage()
43 sys.exit(2)
44
45execprefix = dist.EXEC_PREFIX
46moduledir = dist.get_python_lib()
47for k, v in opts:
48 if k in ("-h", "--help"):
49 usage()
50 sys.exit()
51 if k in ("-p", "--exec-prefix"):
52 v = os.path.expanduser(v)
53 v = os.path.expandvars(v)
54 if not os.path.exists(v):
55 print "The specified exec directory %s doesn't exist" % v
56 sys.exit(1)
57 p = os.path.join(v,"bin")
58 if not os.path.exists(p):
59 print "The specified exec directory %s doesn't exist" % p
60 sys.exit(1)
61 execprefix = v
62 if k in ("-m", "--module-dir"):
63 v = os.path.expanduser(v)
64 v = os.path.expandvars(v)
65 if not os.path.exists(v):
66 print "The specified module directory %s doesn't exist" % v
67 sys.exit(1)
68 moduledir = v
69
70print "Looking fo all required libraries..."
71try:
72 libs, missing = get_libs(lib="asap/_asap.so")
73 if len(missing):
74 print " The following libraries are missing:"
75 print missing
76 sys.exit(1)
77 else:
78 print " All required libraries are present."
79except IOError,msg:
80 print msg+" Skipping test."
81
82print 'Looking for dependent python modules...'
83try:
84 import matplotlib
85except ImportError:
86 print "Matplotlib not found"
87 sys.exit(1)
88if int(matplotlib.__version__.split(".")[1]) < 87:
89 print "Warning: matplotlib version < 0.87." \
90 "This might cause errors. Please upgrade."
91try:
92 import matplotlib.backends.backend_tkagg
93except ImportError:
94 print "Matplotlib doesn't have Tk support"
95 sys.exit(1)
96try:
97 import numpy
98except ImportError:
99 try:
100 import numarray
101 except ImportError:
102 print "You need to have either 'numpy' or 'numarray' installed."
103 sys.exit(1)
104try:
105 import IPython
106except ImportError:
107 print "IPython should be installed."
108 sys.exit(1)
109
110print " All required modules were found."
111moddir = os.path.join(moduledir, "asap")
112bindir = os.path.join(execprefix, "bin")
113try:
114 if os.path.exists(moddir):
115 print "Found previous installation of ASAP. Removing..."
116 shutil.rmtree(moddir)
117 print "Installing asap module in %s" % moddir
118 shutil.copytree("asap", moddir)
119 print "Installing asap scripts in %s" % bindir
120 shutil.copy2("bin/asap", bindir)
121 shutil.copy2("bin/asap_update_data", bindir)
122 if not os.path.exists("asap/data/ephemerides"):
123 print "Warning - no data directory present"
124 print "Please run asap_update_data after the installation is completed."
125 print "Installation completed."
126except OSError, oe:
127 print oe
Note: See TracBrowser for help on using the repository browser.