source: trunk/bin/install@ 1172

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

added matplotlib version check. added usage. added ipython detection

  • Property svn:executable set to *
File size: 2.5 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
16try:
17 opts, args = getopt.getopt(sys.argv[1:], "p:m:h",
18 ["exec-prefix=", "module-dir=", "help"])
19
20except getopt.GetoptError:
21 usage()
22 sys.exit(2)
23
24execprefix = dist.EXEC_PREFIX
25moduledir = dist.get_python_lib()
26for k, v in opts:
27 if k in ("-h", "--help"):
28 usage()
29 sys.exit()
30 if k in ("-p", "--exec-prefix"):
31 v = os.path.expanduser(v)
32 v = os.path.expandvars(v)
33 if not os.path.exists(v):
34 print "The specified exec directory %s doesn't exist" % v
35 sys.exit(1)
36 p = os.path.join(v,"bin")
37 if not os.path.exists(p):
38 print "The specified exec directory %s doesn't exist" % p
39 sys.exit(1)
40 execprefix = v
41 if k in ("-m", "--module-dir"):
42 v = os.path.expanduser(v)
43 v = os.path.expandvars(v)
44 if not os.path.exists(v):
45 print "The specified module directory %s doesn't exist" % v
46 sys.exit(1)
47 moduledir = v
48
49print 'Looking for dependent modules...'
50try:
51 import matplotlib
52except ImportError:
53 print "Matplotlib not found"
54 sys.exit(1)
55if matplotlib.__version__.split(".")[1] < 87:
56 print "Warning: matplotlib version < 0.87." \
57 "This might cause errors. Please upgrade."
58
59try:
60 import matplotlib.backends.backend_tkagg
61except ImportError:
62 print "Matplotlib doesn't have Tk support"
63 sys.exit(1)
64try:
65 import numpy
66except ImportError:
67 try:
68 import numarray
69 except ImportError:
70 print "You need to have either 'numpy' or 'numarray' installed."
71 sys.exit(1)
72try:
73 import IPython
74except ImportError:
75 print "IPython should be installed."
76 sys.exit(1)
77
78print "All required modules were found."
79moddir = os.path.join(moduledir, "asap")
80bindir = os.path.join(execprefix, "bin")
81try:
82 if os.path.exists(moddir):
83 print "Found previous installation of ASAP. Removing..."
84 shutil.rmtree(moddir)
85 print "Installing asap module in %s" % moddir
86 shutil.copytree("asap", moddir)
87 print "Installing asap startup script in %s" % bindir
88 shutil.copy2("bin/asap", bindir)
89 shutil.copytree("data", os.path.join(moddir,"data"))
90 print "Installation completed."
91except OSError, oe:
92 print oe
Note: See TracBrowser for help on using the repository browser.