Changeset 1867
- Timestamp:
- May 26, 2015 5:24:40 PM (8 years ago)
- Location:
- install
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
install/bootstrap.py
r1532 r1867 1 1 #!/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. 2 5 import os, stat, sys, platform, subprocess 3 6 home = 'https://subversion.xray.aps.anl.gov/pyGSAS/' … … 10 13 except: 11 14 missing.append(pkg) 15 # handle pyopenGl differently, because that we can install later 16 try: 17 import OpenGL as ogl 18 install_with_easyinstall = None 19 except 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() 12 41 13 42 if missing: … … 17 46 for pkg in missing: print " ",pkg, 18 47 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/" 23 50 sys.exit() 24 51 52 # path to where this script is located 25 53 gsaspath = os.path.split(sys.argv[0])[0] 54 if not gsaspath: gsaspath = os.path.curdir 26 55 gsaspath = os.path.abspath(os.path.expanduser(gsaspath)) 27 56 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',]: 57 print '\nChecking for subversion...', 58 if 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')) 62 else: 63 pathlist = os.environ['PATH'].split(':') 64 # add the standard location for wandisco svn to the path 65 pathlist.append('/opt/subversion/bin') 66 for path in pathlist: 31 67 svn = os.path.join(path,'svn') 32 68 try: … … 40 76 raise Exception('Subversion (svn) not found') 41 77 print ' found svn in',svn 42 print 'OK'43 78 44 print 'GSAS-II is being bootstrapped from repository\n\t',home,'\nto '+gsaspath 79 print 'Ready to bootstrap GSAS-II from repository\n\t',home,'\nto '+gsaspath 80 proxycmds = [] 81 if os.path.exists("proxyinfo.txt"): 82 fp = open("proxyinfo.txt",'r') 83 os.remove("proxyinfo.txt") 84 print(70*"=") 85 ans = raw_input("Enter the proxy address [none needed]: ") 86 if 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() 45 97 46 98 print 'Determining system type...', … … 58 110 repos = 'osxppc' 59 111 print 'Mac OS X, PowerPC -- you will need to run scons on fsource files' 112 elif sys.platform.startswith('win'): 113 repos = 'win' 114 print 'Windows' 60 115 else: 61 print 'Unidentifed platform -- you may need to run scons onfsource files'116 print 'Unidentifed platform -- you probably will need to run scons to compile the fsource files' 62 117 63 118 cmd = [svn, 'co', home+ 'trunk/', gsaspath, '--non-interactive', '--trust-server-cert'] 119 if proxycmds: cmd += proxycmds 64 120 msg = 'loading GSAS-II' 65 121 66 122 print 70*'*' 67 123 print msg + ' from ' + cmd[2] 124 print 'svn load command:' 68 125 for item in cmd: print item, 69 126 print "" 70 127 p = subprocess.call(cmd) 71 128 if p: 72 print 'subversion returned an error; Retrying ...'129 print 'subversion returned an error; Retrying with command for older version...' 73 130 cmd = [svn, 'co', home+ 'trunk/', gsaspath] 131 if proxycmds: cmd += proxycmds 132 for item in cmd: print item, 133 print "" 74 134 p = subprocess.call(cmd) 75 135 76 136 #=========================================================================== 77 # could try to load .so files here and run scons if needed. 78 137 # install OpenGL, if needed. 138 if 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 144 print 'Byte-compiling all .py files...', 145 import compileall 146 compileall.compile_dir(gsaspath,quiet=True) 147 print 'done' 148 #=========================================================================== 149 # platform-dependent stuff 150 #=========================================================================== 151 # on Windows, 152 if sys.platform.startswith('win') and os.path.exists( 153 os.path.join(gsaspath,"makeBat.py")): 154 execfile(os.path.join(gsaspath,"makeBat.py")) 79 155 #=========================================================================== 80 156 # on a Mac, make an applescript 81 if sys.platform.startswith('darwin') and os.path.exists(157 elif sys.platform.startswith('darwin') and os.path.exists( 82 158 os.path.join(gsaspath,"makeMacApp.py")): 83 159 execfile(os.path.join(gsaspath,"makeMacApp.py")) 84 160 #=========================================================================== 85 161 # On linux, make desktop icon 86 if sys.platform.startswith('linux'):162 elif sys.platform.startswith('linux'): 87 163 desktop_template = """ 88 164 [Desktop Entry] … … 108 184 stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) 109 185 print("created GNOME desktop shortcut "+dfile) 186
Note: See TracChangeset
for help on using the changeset viewer.