source: trunk/bin/install@ 1173

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

matplotlib version number has to be cats to int

  • 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 int(matplotlib.__version__.split(".")[1]) < 87:
56 print "Warning: matplotlib version < 0.87." \
57 "This might cause errors. Please upgrade."
58try:
59 import matplotlib.backends.backend_tkagg
60except ImportError:
61 print "Matplotlib doesn't have Tk support"
62 sys.exit(1)
63try:
64 import numpy
65except ImportError:
66 try:
67 import numarray
68 except ImportError:
69 print "You need to have either 'numpy' or 'numarray' installed."
70 sys.exit(1)
71try:
72 import IPython
73except ImportError:
74 print "IPython should be installed."
75 sys.exit(1)
76
77print "All required modules were found."
78moddir = os.path.join(moduledir, "asap")
79bindir = os.path.join(execprefix, "bin")
80try:
81 if os.path.exists(moddir):
82 print "Found previous installation of ASAP. Removing..."
83 shutil.rmtree(moddir)
84 print "Installing asap module in %s" % moddir
85 shutil.copytree("asap", moddir)
86 print "Installing asap startup script in %s" % bindir
87 shutil.copy2("bin/asap", bindir)
88 shutil.copytree("data", os.path.join(moddir,"data"))
89 print "Installation completed."
90except OSError, oe:
91 print oe
Note: See TracBrowser for help on using the repository browser.