1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | import distutils.sysconfig as dist
|
---|
4 | import shutil
|
---|
5 | import os
|
---|
6 | import sys
|
---|
7 | import getopt
|
---|
8 |
|
---|
9 | def usage():
|
---|
10 | pass
|
---|
11 |
|
---|
12 | try:
|
---|
13 | opts, args = getopt.getopt(sys.argv[1:], "p:m:h",
|
---|
14 | ["exec-prefix=", "module-dir=", "help"])
|
---|
15 |
|
---|
16 | except getopt.GetoptError:
|
---|
17 | print "error"
|
---|
18 | sys.exit(2)
|
---|
19 |
|
---|
20 | execprefix = dist.EXEC_PREFIX
|
---|
21 | moduledir = dist.get_python_lib()
|
---|
22 | for k, v in opts:
|
---|
23 | if k in ("-h", "--help"):
|
---|
24 | usage()
|
---|
25 | sys.exit()
|
---|
26 | if k in ("-p", "--exec-prefix"):
|
---|
27 | v = os.path.expanduser(v)
|
---|
28 | v = os.path.expandvars(v)
|
---|
29 | if not os.path.exists(v):
|
---|
30 | print "The specified exec directory %s doesn't exist" % v
|
---|
31 | sys.exit(1)
|
---|
32 | p = os.path.join(v,"bin")
|
---|
33 | if not os.path.exists(p):
|
---|
34 | print "The specified exec directory %s doesn't exist" % p
|
---|
35 | sys.exit(1)
|
---|
36 | execprefix = v
|
---|
37 | if k in ("-m", "--module-dir"):
|
---|
38 | v = os.path.expanduser(v)
|
---|
39 | v = os.path.expandvars(v)
|
---|
40 | if not os.path.exists(v):
|
---|
41 | print "The specified module directory %s doesn't exist" % v
|
---|
42 | sys.exit(1)
|
---|
43 | moduledir = v
|
---|
44 |
|
---|
45 | print 'Looking for dependent modules...'
|
---|
46 | try:
|
---|
47 | import matplotlib
|
---|
48 | except ImportError:
|
---|
49 | print "Matplotlib not found"
|
---|
50 | sys.exit(1)
|
---|
51 | try:
|
---|
52 | import matplotlib.backends.backend_tkagg
|
---|
53 | except ImportError:
|
---|
54 | print "Matplotlib doesn't have Tk support"
|
---|
55 | sys.exit(1)
|
---|
56 | try:
|
---|
57 | import numpy
|
---|
58 | except ImportError:
|
---|
59 | try:
|
---|
60 | import numarray
|
---|
61 | except ImportError:
|
---|
62 | print "You need to have either 'numpy' or 'numarray' installed."
|
---|
63 | sys.exit(1)
|
---|
64 | print "Looks like everything is here"
|
---|
65 | moddir = os.path.join(moduledir, "asap")
|
---|
66 | bindir = os.path.join(execprefix, "bin")
|
---|
67 | try:
|
---|
68 | if os.path.exists(moddir):
|
---|
69 | print "Found previous installation of ASAP. Removing..."
|
---|
70 | shutil.rmtree(moddir)
|
---|
71 | print "Installing asap module in %s" % moddir
|
---|
72 | shutil.copytree("asap", moddir)
|
---|
73 | print "Installing asap startup script in %s" % bindir
|
---|
74 | shutil.copy2("bin/asap", bindir)
|
---|
75 | shutil.copytree("data", os.path.join(moddir,"data"))
|
---|
76 | print "Installation completed."
|
---|
77 | except OSError, oe:
|
---|
78 | print oe
|
---|