1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#!/usr/bin/env python
import shutil, os, sys
def okay(msg):
print msg
a=raw_input(" Press <ENTER> to continue (anything else will terminate): ")
if a:
sys.exit(1)
return
# Simple python script to install mma from tarball
# This should be fixed to be more versatile. Volunteers?
###########################################
####### Banner, get destination
print """
This script will install mma, the standard library and the
python modules.
YOU WILL NEED TO BE LOGGED IN AS ROOT TO CONTINUE!
We recommend that you install the package with this script
in the default locations. This script will create a
directory 'mma' in /usr/local/share. If this isn't
what you want, then stop this script and change
the directory location. But, please note that ONLY
/usr/local/share and /usr/share are supported as default
locations.
The main executable script will be installed in /usr/local/bin.
If you want to install the python modules in the python
tree, that will work. Just create a file called 'mma.pth'
in the python/site-packages directory, a directory called
'mma' and copy the contents of the modules directory in this
distribution to that location.
If you ever decide to get rid of MMA, just delete the executable
in /usr/local/mma and the directory tree in /usr/local/share/mma.
"""
okay("")
###########################################
######## Copy the executable.
dest='/usr/local/bin/mma'
if os.path.exists(dest):
okay("Existing mma executable '%s' is being overwritten." % dest)
print "Copying mma to", dest
shutil.copy( 'mma', dest)
###########################################
######## Copy the library
dest = '/usr/local/share/mma/'
if os.path.exists(dest):
okay("Exisiting mma tree '%s' is being removed." % dest)
shutil.rmtree( dest )
print "Copying library to", dest
os.makedirs(dest)
shutil.copytree( "lib", dest+"/lib")
###########################################
######## Copy the includes
print "Copying includes to", dest
shutil.copytree( "includes", dest+"/includes")
###########################################
######## Copy the modules
print "Copying python modules to", dest
shutil.copytree( "modules", dest+"/modules")
###########################################
######## Set permissions/udate database
print "Setting permissions on MMADIR database file for user update."
os.system("chmod a+w " + dest+"/lib/MMADIR")
print
print "Updating database file. This uses mma with the -G option."
print "If this fails, something was not installed properly"
print "and you should contact Bob and we'll figure it out."
print "Note: Some warnings will be printed, but they can safely be ignored."
okay("")
os.system("mma -G")
|