source: trunk/bin/install@ 1182

Last change on this file since 1182 was 1181, checked in by mar637, 18 years ago

finishing touches to making scons makedist=xyz work

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