2007-04-29 06:47:40 +00:00
|
|
|
#!/usr/bin/env python
|
2006-11-10 08:07:56 +00:00
|
|
|
|
2007-04-29 06:47:40 +00:00
|
|
|
import os, sys
|
2006-11-10 08:07:56 +00:00
|
|
|
|
2007-04-29 06:47:40 +00:00
|
|
|
def okay(msg):
|
|
|
|
print msg
|
|
|
|
a=raw_input(" Press <ENTER> to continue (anything else will terminate): ")
|
2006-11-10 08:07:56 +00:00
|
|
|
|
2007-04-29 06:47:40 +00:00
|
|
|
if a:
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
# Simple python script to install mma from tarball
|
|
|
|
# This should be fixed to be more versatile. Volunteers?
|
|
|
|
|
|
|
|
# Before we do anything, make sure we have an up-to-date python.
|
|
|
|
|
|
|
|
pyMaj=2
|
|
|
|
pyMin=4
|
|
|
|
|
|
|
|
if sys.version_info[0] < pyMaj or sys.version_info[1] < pyMin:
|
|
|
|
print
|
|
|
|
print "You need a more current version of Python to run MMA and this install script."
|
|
|
|
print "We're looking for something equal or greater than version %s.%s" % \
|
|
|
|
(pyMaj,pyMin)
|
|
|
|
print "Current Python version is ", sys.version
|
|
|
|
print
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
# Banner. Check to make sure user has root permissions.
|
|
|
|
|
|
|
|
print """
|
|
|
|
This script will install mma, the standard library and the
|
|
|
|
python modules using symbolic links to the current directory.
|
|
|
|
"""
|
|
|
|
|
|
|
|
try:
|
|
|
|
u=os.getuid()
|
|
|
|
except:
|
|
|
|
u=1
|
|
|
|
|
|
|
|
if u:
|
|
|
|
okay("""You do not appear to be running this script as 'root' user.
|
|
|
|
Continuing will probably cause all kinds of strange errors
|
|
|
|
and a generally unsatisfactory experience. But, we can try...
|
|
|
|
""")
|
|
|
|
|
2011-07-26 22:49:39 +00:00
|
|
|
rootdir = "/usr/local/share"
|
|
|
|
rootexe = "/usr/local/bin"
|
|
|
|
|
|
|
|
dir = rootdir + "/mma"
|
|
|
|
exe = rootexe + "/mma"
|
|
|
|
|
|
|
|
# Check to make sure install directories exist. Offer to create
|
|
|
|
# ... these might need to be created in Mac OS X
|
|
|
|
|
|
|
|
if not os.path.exists(rootdir):
|
|
|
|
okay("""The directory %s does not exist. Create okay?""" % rootdir)
|
|
|
|
if os.system("mkdir -p %s" % rootdir):
|
|
|
|
print "Opps, create failed. Were you root?"
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if not os.path.exists(rootexe):
|
|
|
|
okay("""The directory %s does not exist. Create okay?""" % rootexe)
|
|
|
|
if os.system("mkdir -p %s" % rootexe):
|
|
|
|
print "Opps, create failed. Were you root?"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2007-04-29 06:47:40 +00:00
|
|
|
if os.path.exists(dir):
|
|
|
|
okay("""The directory %s currently exists. Proceeding will overwrite
|
|
|
|
with a new link. YOU MAY LOSE DATA.""" % dir)
|
|
|
|
|
|
|
|
if os.path.exists(exe):
|
|
|
|
okay("""The file %s currently exists. Proceeding will remove this
|
|
|
|
file with a new link. YOU MAY LOSE DATA.""" % exe)
|
|
|
|
|
|
|
|
okay("""Okay, I'm ready to create the links. I will create 2 links:
|
|
|
|
- The main distribution and library at %s
|
|
|
|
- The callable executable at %s
|
|
|
|
""" % (dir, exe) )
|
|
|
|
|
|
|
|
os.system("ln -sf `pwd` %s" % dir)
|
|
|
|
os.system("ln -sf `pwd`/mma.py %s" % exe)
|
|
|
|
|
2009-05-17 22:34:44 +00:00
|
|
|
|
|
|
|
print "There are some man pages in %s/docs/man that you may wish to install." % dir
|
|
|
|
|
|
|
|
|
2007-04-29 06:47:40 +00:00
|
|
|
print "Everything seems to be okay. We suggest you first update the database"
|
|
|
|
print "with the command mma -G."
|
2009-05-17 22:34:44 +00:00
|
|
|
print "Have Fun!"
|