- Timestamp:
- May 27, 2018 7:32:50 PM (6 years ago)
- Location:
- install
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
install/g2conda/construct.yaml
r3201 r3404 1 1 name: g2conda 2 version: 0.1.2 3 #conda install numpy scipy matplotlib pillow h5py pyopengl pywin32 svn wxpython m2w64-gcc-libgfortran 2 version: 1.0.1 4 3 install_in_dependency_order: True 5 4 … … 9 8 10 9 packages: 11 - g 2load-0.1.8-010 - gsas2pkg 12 11 13 12 specs: 14 - python 2.7*13 - python 15 14 - conda 16 15 - numpy … … 19 18 - pillow 20 19 - pyopengl 21 - wxpython 3.*20 - wxpython 22 21 - svn 23 22 - hdf5 24 23 - h5py 25 24 - pywin32 [win] 25 - imageio 26 26 27 27 28 exclude: … … 37 38 welcome_image: gsas2-welcome.png 38 39 icon_image: gsas2.png 40 41 #### - gsas2pkg-1.0.3-0 42 #### - python.app [mac] -
install/g2pkg/meta.yaml
r3201 r3404 1 1 package: 2 name: g 2load3 version: 0.2.0# remember to change in g2conda/construct.yaml to match this2 name: gsas2pkg 3 version: "1.0.3" # remember to change in g2conda/construct.yaml to match this 4 4 5 5 source: … … 8 8 about: 9 9 home: https://subversion.xray.aps.anl.gov/trac/pyGSAS 10 11 build: 12 noarch: python 13 14 requirements: 15 run: 16 - python 17 - conda 18 - numpy 19 - scipy 20 - matplotlib 21 - pillow 22 - pyopengl 23 - wxpython 24 - svn 25 - hdf5 26 - h5py 27 - pywin32 [win] 28 - imageio 29 - python.app [mac] 30 -
install/g2pkg/src/bootstrap.py
r2410 r3404 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 # Installs GSAS-II from network using subversion and creates platform-specific shortcuts. 3 # works for Mac & Linux & Windows 5 4 import os, stat, sys, platform, subprocess 6 home = 'https://subversion.xray.aps.anl.gov/pyGSAS/' 7 print 70*'*' 5 6 g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS/' 7 path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) 8 print('Running bootstrap from {}'.format(path2GSAS2)) 9 ################################################################################ 10 ################################################################################ 11 # routines copied from GSASIIpath.py 12 proxycmds = [] 13 'Used to hold proxy information for subversion, set if needed in whichsvn' 14 svnLocCache = None 15 'Cached location of svn to avoid multiple searches for it' 16 17 def whichsvn(): 18 '''Returns a path to the subversion exe file, if any is found. 19 Searches the current path after adding likely places where GSAS-II 20 might install svn. 21 22 :returns: None if svn is not found or an absolute path to the subversion 23 executable file. 24 ''' 25 # use a previosuly cached svn location 26 global svnLocCache 27 if svnLocCache: return svnLocCache 28 # prepare to find svn 29 is_exe = lambda fpath: os.path.isfile(fpath) and os.access(fpath, os.X_OK) 30 svnprog = 'svn' 31 if sys.platform.startswith('win'): svnprog += '.exe' 32 gsaspath = os.path.split(__file__)[0] 33 # check for a proxy 34 proxyinfo = os.path.join(gsaspath,"proxyinfo.txt") 35 if os.path.exists(proxyinfo): 36 global proxycmds 37 proxycmds = [] 38 fp = open(proxyinfo,'r') 39 host = fp.readline().strip() 40 port = fp.readline().strip() 41 fp.close() 42 proxycmds.append('--config-option') 43 proxycmds.append('servers:global:http-proxy-host='+host) 44 proxycmds.append('--config-option') 45 proxycmds.append('servers:global:http-proxy-port='+port) 46 # add likely places to find subversion when installed with GSAS-II 47 pathlist = os.environ["PATH"].split(os.pathsep) 48 pathlist.append(os.path.split(sys.executable)[0]) 49 pathlist.append(gsaspath) 50 for rpt in ('..','bin'),('..','Library','bin'),('svn','bin'),('svn',),('.'): 51 pt = os.path.normpath(os.path.join(gsaspath,*rpt)) 52 if os.path.exists(pt): 53 pathlist.insert(0,pt) 54 # search path for svn or svn.exe 55 for path in pathlist: 56 exe_file = os.path.join(path, svnprog) 57 if is_exe(exe_file): 58 try: 59 p = subprocess.Popen([exe_file,'help'],stdout=subprocess.PIPE) 60 res = p.stdout.read() 61 p.communicate() 62 svnLocCache = os.path.abspath(exe_file) 63 return svnLocCache 64 except: 65 pass 66 svnLocCache = None 67 68 def svnVersion(svn=None): 69 '''Get the version number of the current subversion executable 70 71 :returns: a string with a version number such as "1.6.6" or None if 72 subversion is not found. 73 74 ''' 75 if not svn: svn = whichsvn() 76 if not svn: return 77 78 cmd = [svn,'--version','--quiet'] 79 s = subprocess.Popen(cmd, 80 stdout=subprocess.PIPE,stderr=subprocess.PIPE) 81 out,err = s.communicate() 82 if err: 83 print('subversion error!\nout= '+out) 84 print('err= '+err) 85 return None 86 return out.strip() 87 88 def svnVersionNumber(svn=None): 89 '''Get the version number of the current subversion executable 90 91 :returns: a fractional version number such as 1.6 or None if 92 subversion is not found. 93 94 ''' 95 ver = svnVersion(svn) 96 if not ver: return 97 M,m = ver.split('.')[:2] 98 return int(M)+int(m)/10. 99 100 ################################################################################ 101 ################################################################################ 102 print(70*'*') 8 103 #testing for incorrect locale code' 9 104 try: … … 11 106 locale.getdefaultlocale() 12 107 except ValueError: 13 print 'Your location is not set properly. This causes problems for matplotlib'14 print ' (see https://github.com/matplotlib/matplotlib/issues/5420.)'15 print 'Will try to bypass problem by setting LC_ALL to en_US.UTF-8 (US English)'108 print('Your location is not set properly. This causes problems for matplotlib') 109 print(' (see https://github.com/matplotlib/matplotlib/issues/5420.)') 110 print('Will try to bypass problem by setting LC_ALL to en_US.UTF-8 (US English)') 16 111 os.environ['LC_ALL'] = 'en_US.UTF-8' 17 112 locale.getdefaultlocale() 18 print 'Preloading matplotlib to build fonts...'113 print('Preloading matplotlib to build fonts...') 19 114 try: 20 115 import matplotlib 21 116 except: 22 117 pass 23 print 'Checking python packages...',118 print('Checking python packages...') 24 119 missing = [] 25 120 for pkg in ['numpy','scipy','matplotlib','wx',]: … … 30 125 31 126 if missing: 32 print"""Sorry, this version of Python cannot be used127 msg = """Sorry, this version of Python cannot be used 33 128 for GSAS-II. It is missing the following package(s): 34 \t""", 35 for pkg in missing: print " ",pkg, 36 print 37 print "This should not happen as this script should be called with a " 38 print "specially configured version of the free Anaconda python package." 39 print "Please contact Brian Toby (toby@anl.gov)" 129 \t""" 130 for pkg in missing: msg += " "+pkg 131 print(msg) 132 print("\nPlease install these package(s) and try running this again.") 133 print("Showing first error: ") 40 134 for pkg in ['numpy','scipy','matplotlib','wx',]: 41 135 exec('import '+pkg) … … 43 137 try: 44 138 import OpenGL 139 install_with_easyinstall = None 45 140 except: 46 print "Missing the OpenGL Python package." 47 print "This should not happen as this script should be called with a " 48 print "specially configured version of the free Anaconda python package," 49 print "but GSAS-II can install this package anyway." 50 print "Please contact Brian Toby (toby@anl.gov) to report this problem." 51 52 # path to where this script is located 53 gsaspath = os.path.split(sys.argv[0])[0] 54 if not gsaspath: gsaspath = os.path.curdir 55 gsaspath = os.path.abspath(os.path.expanduser(gsaspath)) 56 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')) 141 try: 142 from setuptools.command import easy_install 143 except ImportError: 144 print('You are missing the OpenGL Python package. This can be ') 145 print('installed by this script if the setuptools package is installed') 146 print('Please install either OpenGL (pyopengl) or setuptools') 147 print("package and try running this again.") 148 sys.exit() 149 print("Missing the OpenGL Python package. Will attempt to install this later.") 150 def install_with_easyinstall(package): 151 try: 152 print("trying system-wide ") 153 easy_install.main(['-f',os.path.split(__file__)[0],package]) 154 return 155 except: 156 pass 157 try: 158 print("trying user level ") 159 easy_install.main(['-f',os.path.split(__file__)[0],'--user',package]) 160 return 161 except: 162 print("\nInstall of "+package+" failed. Error traceback follows:") 163 import traceback 164 print(traceback.format_exc()) 165 sys.exit() 166 167 print('\nChecking for subversion...') 168 svn = whichsvn() 169 if not svn: 170 print("Sorry, subversion (svn) could not be found on your system.") 171 print("Please install this or place in path and rerun this.") 172 #raise Exception('Subversion (svn) not found') 173 sys.exit() 174 print(' found svn image: '+svn) 175 176 if install_with_easyinstall: 177 print('\nInstalling PyOpenGL. Lots of warnings will follow... ') 178 install_with_easyinstall('PyOpenGl') 179 print('done.') 180 181 print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2) 182 proxycmds = [] 183 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 184 host = None 185 port = '8080' 186 if os.path.exists(proxyinfo): 187 fp = open(proxyinfo,'r') 188 host = fp.readline().strip() 189 port = fp.readline().strip() 190 fp.close() 191 os.remove(proxyinfo) 192 print(70*"=") 193 if sys.version_info[0] == 2: 194 getinput = raw_input 62 195 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 if sys.platform.startswith('win'): 67 svn = 'svn.exe' 68 else: 69 svn = 'svn' 70 # use svn installed via conda 1st (mac) 71 if os.path.exists(os.path.join(os.path.split(sys.executable)[0],svn)): 72 pathlist.insert(0,os.path.split(sys.executable)[0]) 73 # use svn installed via conda 1st (Windows) 74 if os.path.exists(os.path.join(os.path.split(sys.executable)[0],'Library','bin',svn)): 75 pathlist.insert(0,os.path.join(os.path.split(sys.executable)[0],'Library','bin')) 76 77 for path in pathlist: 78 svn = os.path.join(path,'svn') 79 try: 80 p = subprocess.Popen([svn,'help'],stdout=subprocess.PIPE) 81 res = p.stdout.read() 82 p.communicate() 83 break 84 except: 85 pass 86 else: 87 raise Exception('Subversion (svn) not found') 88 print ' found svn image: '+svn 89 90 print 'Ready to bootstrap GSAS-II from repository\n\t',home,'\nto '+gsaspath 91 proxycmds = [] 92 if os.path.exists("proxyinfo.txt"): 93 fp = open("proxyinfo.txt",'r') 94 os.remove("proxyinfo.txt") 95 print(70*"=") 96 ans = raw_input("Enter the proxy address [none needed]: ") 97 if ans.strip() != "": 196 getinput = input 197 try: 198 if host: 199 ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ") 200 if ans.strip().lower() == "none": host = ans = "" 201 else: 202 ans = getinput("Enter your proxy address [none needed]: ") 203 except EOFError: 204 ans = "" 205 if ans.strip() != "" or host: 98 206 proxycmds.append('--config-option') 207 if ans.strip() == "": ans=host 99 208 proxycmds.append('servers:global:http-proxy-host='+ans.strip()) 100 fp = open( "proxyinfo.txt",'w')209 fp = open(proxyinfo,'w') 101 210 fp.write(ans.strip()+'\n') 102 ans = raw_input("Enter the proxy port [8080]: ")103 if ans.strip() == "": ans= "8080"211 ans = getinput("Enter the proxy port ["+port+"]: ") 212 if ans.strip() == "": ans=port 104 213 proxycmds.append('--config-option') 105 214 proxycmds.append('servers:global:http-proxy-port='+ans.strip()) … … 107 216 fp.close() 108 217 109 print 'Determining system type...', 110 if sys.platform.startswith('linux'): 111 #if platform.processor().find('86') <= -1: 112 # ans = raw_input("Note, GSAS requires an Intel-compatible processor and 32-bit" 113 # "libraries.\nAre you sure want to continue? [Yes]/no: ") 114 # if ans.lower().find('no') > -1: sys.exit() 115 repos = 'linux' 116 print 'Linux, assuming Intel-compatible' 117 elif sys.platform == "darwin" and platform.processor() == 'i386': 118 repos = 'osxi86' 119 print 'Mac OS X, Intel-compatible' 120 elif sys.platform == "darwin": 121 repos = 'osxppc' 122 print 'Mac OS X, PowerPC -- you will need to run scons on fsource files' 123 elif sys.platform.startswith('win'): 124 repos = 'win' 125 print 'Windows' 218 # patch: switch GSAS-II location if linked to XOR server (removed May/June 2017) 219 cmd = [svn, 'info'] 220 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 221 res,err = p.communicate() 222 if '.xor.' in str(res): 223 print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 224 cmd = [svn, 'switch','--relocate','https://subversion.xor.aps.anl.gov/pyGSAS', 225 'https://subversion.xray.aps.anl.gov/pyGSAS'] 226 if proxycmds: cmd += proxycmds 227 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 228 res,err = p.communicate() 229 if err: 230 print('Please report this error to toby@anl.gov:') 231 print(err) 232 print(res) 233 # patch: switch GSAS-II location if switched to 2frame version (removed August 2017) 234 if '2frame' in str(res): 235 print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 236 cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2, 237 '--non-interactive','--trust-server-cert', 238 '--accept','theirs-conflict','--force','--ignore-ancestry'] 239 if proxycmds: cmd += proxycmds 240 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 241 res,err = p.communicate() 242 if err: 243 print('Please report this error to toby@anl.gov:') 244 print(err) 245 print(res) 246 247 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2, '--non-interactive', '--trust-server-cert'] 248 if proxycmds: cmd += proxycmds 249 msg = 'Now preparing to install GSAS-II' 250 print('\n'+75*'*') 251 print(msg + u' from ' + cmd[2]) 252 msg = 'svn load command: ' 253 for item in cmd: msg += " "+item 254 print(msg) 255 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 256 print('\nsubversion output:') 257 out,err = s.communicate() 258 if err: 259 print('subversion returned an error:') 260 print(err) 261 print('Retrying with a cleanup and a command for older svn version...') 262 cmd = [svn, 'cleanup', path2GSAS2] 263 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 264 out,err = s.communicate() 265 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2] 266 if proxycmds: cmd += proxycmds 267 msg = "" 268 for item in cmd: msg += item 269 print(msg) 270 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 271 out,err = s.communicate() 272 if err: 273 print('subversion returned an error:') 274 print(err) 275 print(' *** GSAS-II failed to be installed. In case the cleanup worked, try running this again') 276 print(' *** If this installation continues to fail, a likely reason is a network access') 277 print(' *** problem, most commonly because you need to use a network proxy. Please') 278 print(' *** check with a network administrator or use http://www.whatismyproxy.com/\n') 279 sys.exit() 280 print('\n'+75*'*') 281 282 try: 283 import GSASIIpath 284 print('import of GSASIIpath completed') 285 except Exception as err: 286 print('\n'+75*'=') 287 print('Failed with import of GSASIIpath. This is unexpected.') 288 print('GSAS-II will not run without correcting this. Contact toby@anl.gov') 289 print(err) 290 print(75*'=') 291 sys.exit() 292 293 for a in sys.argv[1:]: 294 if 'allbin' in a.lower() or 'server' in a.lower(): 295 print('Loading all binaries with command...') 296 if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True): 297 print('Binary load failed') 298 sys.exit() 299 break 126 300 else: 127 print 'Unidentifed platform -- you probably will need to run scons to compile the fsource files' 128 129 cmd = [svn, 'co', home+ 'trunk/', gsaspath, '--non-interactive', '--trust-server-cert'] 130 if proxycmds: cmd += proxycmds 131 msg = 'loading GSAS-II' 132 133 print 70*'*' 134 print msg + ' from ' + cmd[2] 135 print 'svn load command:' 136 for item in cmd: print item, 137 print "" 138 p = subprocess.call(cmd) 139 if p: 140 print 'subversion returned an error; Retrying with command for older version...' 141 cmd = [svn, 'co', home+ 'trunk/', gsaspath] 142 if proxycmds: cmd += proxycmds 143 for item in cmd: print item, 144 print "" 145 p = subprocess.call(cmd) 146 301 GSASIIpath.DownloadG2Binaries(g2home) 302 303 #=========================================================================== 304 # test if the compiled files load correctly 305 #=========================================================================== 306 307 script = """ # commands that test each module can at least be loaded & run something in pyspg 308 try: 309 import GSASIIpath 310 GSASIIpath.SetBinaryPath() 311 import pyspg 312 import histogram2d 313 import polymask 314 import pypowder 315 import pytexture 316 pyspg.sgforpy('P -1') 317 print('==OK==') 318 except: 319 pass 320 """ 321 p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE, 322 cwd=path2GSAS2) 323 res,err = p.communicate() 324 if '==OK==' not in str(res) or p.returncode != 0: 325 print('\n'+75*'=') 326 print('Failed when testing the GSAS-II compiled files. GSAS-II will not run') 327 print('without correcting this.\n\nError message:') 328 #print(res) 329 print(err) 330 #print('\nAttempting to open a web page on compiling GSAS-II...') 331 print('Please see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') 332 #import webbrowser 333 #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') 334 print(75*'=') 335 # if '86' in platform.machine() and (sys.platform.startswith('linux') 336 # or sys.platform == "darwin" 337 # or sys.platform.startswith('win')): 338 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported') 339 # else: 340 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported') 341 sys.exit() 342 else: 343 print('Successfully tested compiled routines') 147 344 #=========================================================================== 148 345 # import all .py files so that .pyc files get created 149 print 'Byte-compiling all .py files...',346 print('Byte-compiling all .py files...') 150 347 import compileall 151 compileall.compile_dir( gsaspath,quiet=True)152 print 'done'348 compileall.compile_dir(path2GSAS2,quiet=True) 349 print('done') 153 350 #=========================================================================== 154 351 # platform-dependent stuff 155 352 #=========================================================================== 156 # on Windows, 353 if sys.version_info[0] > 2: 354 def execfile(file): 355 with open(file) as source_file: 356 exec(source_file.read()) 357 # on Windows, make a batch file with Python and GSAS-II location hard-coded 157 358 if sys.platform.startswith('win') and os.path.exists( 158 os.path.join( gsaspath,"makeBat.py")):159 execfile(os.path.join( gsaspath,"makeBat.py"))359 os.path.join(path2GSAS2,"makeBat.py")): 360 execfile(os.path.join(path2GSAS2,"makeBat.py")) 160 361 #=========================================================================== 161 362 # on a Mac, make an applescript 162 363 elif sys.platform.startswith('darwin') and os.path.exists( 163 os.path.join(gsaspath,"makeMacApp.py")): 164 print('running '+os.path.join(gsaspath,"makeMacApp.py")) 165 execfile(os.path.join(gsaspath,"makeMacApp.py")) 364 os.path.join(path2GSAS2,"makeMacApp.py")): 365 sys.argv = [os.path.join(path2GSAS2,"makeMacApp.py")] 366 print(u'running '+sys.argv[0]) 367 execfile(sys.argv[0]) 166 368 #=========================================================================== 167 369 # On linux, make desktop icon 168 elif sys.platform.startswith('linux'): 169 desktop_template = """ 170 [Desktop Entry] 171 Encoding=UTF-8 172 Version=1.0 173 Type=Application 174 Terminal=false 175 Exec=xterm -hold -e %s 176 Name=GSAS-II 177 Icon=%s 178 """ 179 loc = '~/Desktop/' 180 eloc = os.path.expanduser(loc) 181 dfile = os.path.join(eloc,'GSASII.desktop') 182 icon = os.path.join(gsaspath, 'gsas2.png') 183 script = os.path.join(gsaspath, 'GSASII.py') 184 os.chmod(script, # make the .py file executable and readable 185 stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) 186 if os.path.exists(eloc): 187 open(dfile,'w').write(desktop_template % (script,icon)) 188 os.chmod( 189 dfile, 190 stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH) 191 print("created GNOME desktop shortcut "+dfile) 192 370 elif sys.platform.startswith('linux') and os.path.exists( 371 os.path.join(path2GSAS2,"makeLinux.py")): 372 sys.argv = [os.path.join(path2GSAS2,"makeLinux.py")] 373 print(u'running '+sys.argv[0]) 374 execfile(sys.argv[0]) 375
Note: See TracChangeset
for help on using the changeset viewer.