Changeset 1867 for install


Ignore:
Timestamp:
May 26, 2015 5:24:40 PM (6 years ago)
Author:
toby
Message:

new universal installer based on bootstrap.py

Location:
install
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • install/bootstrap.py

    r1532 r1867  
    11#!/usr/bin/env python
     2# Installs GSAS-II from network using subversion and creates platform-specific
     3# shortcuts.
     4# works for Mac & Linux; Windows being tested.
    25import os, stat, sys, platform, subprocess
    36home = 'https://subversion.xray.aps.anl.gov/pyGSAS/'
     
    1013    except:
    1114        missing.append(pkg)
     15# handle pyopenGl differently, because that we can install later
     16try:
     17    import OpenGL as ogl
     18    install_with_easyinstall = None
     19except ImportError:
     20    print '\nPyOpenGL not present. ',
     21    try:
     22        from setuptools.command import easy_install
     23    except ImportError:
     24        missing.append('setuptools')
     25    def install_with_easyinstall(package):
     26        try:
     27            print "trying system-wide ",
     28            easy_install.main(['-f',os.path.split(__file__)[0],package])
     29            return
     30        except:
     31            pass
     32        try:
     33            print "trying user level ",
     34            easy_install.main(['-f',os.path.split(__file__)[0],'--user',package])
     35            return
     36        except:
     37            print "\nInstall of '+package+' failed. Please report this information:"
     38            import traceback
     39            print traceback.format_exc()
     40            sys.exit()
    1241
    1342if missing:
     
    1746    for pkg in missing: print " ",pkg,
    1847    print
    19     if sys.platform.startswith('darwin'):
    20         print "We suggest installing the EPD Free Python package (epd_free-7.3-2-macosx-i386.dmg)\nat https://www.enthought.com/repo/free/\nor the 64-bit Canopy Express package at http://www.enthought.com/downloads"
    21     else:
    22         print "We suggest installing the Canopy Express package at http://www.enthought.com/downloads"
     48    print "We suggest installing the free Canopy Express package at http://www.enthought.com/downloads"
     49    print "or the free Anaconda python package at https://store.continuum.io/cshop/anaconda/"
    2350    sys.exit()
    2451
     52# path to where this script is located
    2553gsaspath = os.path.split(sys.argv[0])[0]
     54if not gsaspath: gsaspath = os.path.curdir
    2655gsaspath = os.path.abspath(os.path.expanduser(gsaspath))
    2756
    28 print 'Checking for subversion...',
    29 # add the standard location for wandisco svn to the path
    30 for path in os.environ['PATH'].split(':')+['/opt/subversion/bin',]:
     57print '\nChecking for subversion...',
     58if sys.platform.startswith('win'):
     59    pathlist = os.environ['PATH'].split(';')
     60    if os.path.exists(os.path.join(gsaspath,'svn')):
     61        pathlist.append(os.path.join(gsaspath,'svn','bin'))
     62else:
     63    pathlist = os.environ['PATH'].split(':')
     64    # add the standard location for wandisco svn to the path
     65    pathlist.append('/opt/subversion/bin')
     66for path in pathlist:
    3167    svn = os.path.join(path,'svn')
    3268    try:
     
    4076    raise Exception('Subversion (svn) not found')
    4177print ' found svn in',svn
    42 print 'OK'
    4378
    44 print 'GSAS-II is being bootstrapped from repository\n\t',home,'\nto '+gsaspath
     79print 'Ready to bootstrap GSAS-II from repository\n\t',home,'\nto '+gsaspath
     80proxycmds = []
     81if os.path.exists("proxyinfo.txt"):
     82    fp = open("proxyinfo.txt",'r')
     83    os.remove("proxyinfo.txt")
     84print(70*"=")
     85ans = raw_input("Enter the proxy address [none needed]: ")
     86if ans.strip() != "":
     87    proxycmds.append('--config-option')
     88    proxycmds.append('servers:global:http-proxy-host='+ans.strip())
     89    fp = open("proxyinfo.txt",'w')
     90    fp.write(ans.strip()+'\n')
     91    ans = raw_input("Enter the proxy port [8080]: ")
     92    if ans.strip() == "": ans="8080"
     93    proxycmds.append('--config-option')
     94    proxycmds.append('servers:global:http-proxy-port='+ans.strip())
     95    fp.write(ans.strip()+'\n')
     96    fp.close()
    4597
    4698print 'Determining system type...',
     
    58110    repos = 'osxppc'
    59111    print 'Mac OS X, PowerPC -- you will need to run scons on fsource files'
     112elif sys.platform.startswith('win'):
     113    repos = 'win'
     114    print 'Windows'
    60115else:
    61     print 'Unidentifed platform -- you may need to run scons on fsource files'
     116    print 'Unidentifed platform -- you probably will need to run scons to compile the fsource files'
    62117
    63118cmd = [svn, 'co', home+ 'trunk/', gsaspath, '--non-interactive', '--trust-server-cert']
     119if proxycmds: cmd += proxycmds
    64120msg = 'loading GSAS-II'
    65121   
    66122print 70*'*'
    67123print msg + ' from ' + cmd[2]
     124print 'svn load command:'
    68125for item in cmd: print item,
    69126print ""
    70127p = subprocess.call(cmd)
    71128if p:
    72     print 'subversion returned an error; Retrying...'
     129    print 'subversion returned an error; Retrying with command for older version...'
    73130    cmd = [svn, 'co', home+ 'trunk/', gsaspath]
     131    if proxycmds: cmd += proxycmds
     132    for item in cmd: print item,
     133    print ""
    74134    p = subprocess.call(cmd)
    75135
    76136#===========================================================================
    77 # could try to load .so files here and run scons if needed.
    78 
     137# install OpenGL, if needed.
     138if install_with_easyinstall:
     139    print '\nInstalling PyOpenGL. Lots of warnings will follow... ',
     140    install_with_easyinstall('PyOpenGl')
     141    print 'done.'
     142#===========================================================================
     143# import all .py files so that .pyc files get created
     144print 'Byte-compiling all .py files...',
     145import compileall
     146compileall.compile_dir(gsaspath,quiet=True)
     147print 'done'
     148#===========================================================================
     149# platform-dependent stuff
     150#===========================================================================
     151# on Windows,
     152if sys.platform.startswith('win') and os.path.exists(
     153    os.path.join(gsaspath,"makeBat.py")):
     154    execfile(os.path.join(gsaspath,"makeBat.py"))
    79155#===========================================================================
    80156# on a Mac, make an applescript
    81 if sys.platform.startswith('darwin') and os.path.exists(
     157elif sys.platform.startswith('darwin') and os.path.exists(
    82158    os.path.join(gsaspath,"makeMacApp.py")):
    83159    execfile(os.path.join(gsaspath,"makeMacApp.py"))
    84160#===========================================================================
    85161# On linux, make desktop icon
    86 if sys.platform.startswith('linux'):
     162elif sys.platform.startswith('linux'):
    87163    desktop_template = """
    88164[Desktop Entry]
     
    108184            stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
    109185        print("created GNOME desktop shortcut "+dfile)
     186
Note: See TracChangeset for help on using the changeset viewer.