Changeset 4477 for install/g2pkg/src
- Timestamp:
- Jun 9, 2020 12:32:49 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
install/g2pkg/src/bootstrap.py
r3515 r4477 2 2 # Installs GSAS-II from network using subversion and creates platform-specific shortcuts. 3 3 # works for Mac & Linux & Windows 4 from __future__ import division, print_function 4 5 import os, stat, sys, platform, subprocess, datetime 5 6 … … 7 8 g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS/' 8 9 path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) 10 11 skipInstallChecks = False # if set to True, continue installation even if current Python lacks packages and 12 # skips platform-dependent installation steps 13 skipDownloadSteps = False # if False, svn is used to download GSAS-II files and binaries 14 skipProxy = False # if False then the script creates a prompt asking for proxy info 15 showWXerror = False # if True, errors are shown in wxPython windows (used on Windows only) 16 help = False # if True, a help message is shown 17 allBinaries = False # if True, causes all binaries to be installed 18 binaryVersion=None # if specified, gives a specific numpy version to use (such as 1.18) 19 # for selecting a set of binaries to use 20 numpyVersion=None 21 22 for a in sys.argv[1:]: 23 if 'noinstall' in a.lower(): 24 skipInstallChecks = True 25 if sys.platform.startswith('win'): showWXerror = True 26 elif 'nonet' in a.lower(): 27 skipDownloadSteps = True 28 skipProxy = True 29 elif 'noproxy' in a.lower(): 30 skipProxy = True 31 elif 'allbin' in a.lower() or 'server' in a.lower(): 32 allBinaries = True 33 elif 'binary' in a.lower(): 34 numpyVersion = a.split('=')[1] 35 skipInstallChecks = True 36 if sys.platform.startswith('win'): showWXerror = True 37 skipProxy = True 38 else: 39 help = True 40 if 'help' in a.lower(): 41 help = True 42 43 if help: 44 print(''' 45 bootstrap.py options: 46 47 --noinstall skip post-install, such as creating run shortcuts, turns on 48 wxpython error display in Windows 49 --noproxy do not ask for proxy information 50 --server load all binary versions 51 --allbin load all binary versions (same as --server) 52 --help this message 53 --nonet skip steps requiring internet 54 --binary=ver specifies a specific numpy binary directory to use (such as 55 --binary=1.18); turns on --noinstall and --noproxy 56 ''') 57 sys.exit() 58 9 59 now = str(datetime.datetime.now()) 10 60 print('Running bootstrap from {} at {}\n\tId: {}'.format(path2GSAS2,now,version)) 61 print ("Python: %s"%sys.version.split()[0]) 62 try: 63 import numpy as np 64 print ("numpy: %s"%np.__version__) 65 except: 66 pass 11 67 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a') 12 68 fp.write('Running bootstrap from {} at {}\n\tId: {}\n'.format(path2GSAS2,now,version)) 13 69 fp.close() 70 14 71 ################################################################################ 15 72 ################################################################################ 73 def BailOut(msg): 74 '''Exit with an error message. Use a GUI to show the error when 75 showWXerror == True (on windows when --noinstall is specified) 76 ''' 77 print(msg) 78 if showWXerror: 79 import wx 80 app = wx.App() 81 app.MainLoop() 82 dlg = wx.MessageDialog(None,msg,'GSAS-II installation error', 83 wx.OK | wx.ICON_ERROR | wx.STAY_ON_TOP) 84 dlg.Raise() 85 dlg.ShowModal() 86 dlg.Destroy() 87 else: 88 print("Recreate error this using command:") 89 print(" {} {} {}".format( 90 os.path.abspath(sys.executable), 91 os.path.abspath(os.path.expanduser(__file__)), 92 ' '.join(sys.argv[1:]), 93 ),file=sys.stderr) 94 print("\nBOOTSTRAP WARNING: ",file=sys.stderr) 95 for line in msg.split('\n'): 96 print(line,file=sys.stderr) 97 sys.exit() 98 16 99 def GetConfigValue(*args): return True 17 100 # routines copied from GSASIIpath.py … … 47 130 '''Loads a proxy for subversion from the file created by bootstrap.py 48 131 ''' 49 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 50 if os.path.exists(proxyinfo): 51 global proxycmds 52 global host,port # only in bootstrap.py 53 proxycmds = [] 54 fp = open(proxyinfo,'r') 132 global proxycmds 133 proxycmds = [] 134 proxyinfo = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt") 135 if not os.path.exists(proxyinfo): 136 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 137 if not os.path.exists(proxyinfo): 138 return '','','' 139 fp = open(proxyinfo,'r') 140 host = fp.readline().strip() 141 # allow file to begin with comments 142 while host.startswith('#'): 55 143 host = fp.readline().strip() 56 port = fp.readline().strip() 57 fp.close() 58 setsvnProxy(host,port) 59 if not host.strip(): return '','' 60 return host,port 61 return '','' 62 63 def setsvnProxy(host,port): 144 port = fp.readline().strip() 145 etc = [] 146 line = fp.readline() 147 while line: 148 etc.append(line.strip()) 149 line = fp.readline() 150 fp.close() 151 setsvnProxy(host,port,etc) 152 return host,port,etc 153 154 def setsvnProxy(host,port,etc=[]): 64 155 '''Sets the svn commands needed to use a proxy 65 156 ''' … … 68 159 host = host.strip() 69 160 port = port.strip() 70 if not host.strip(): return 71 proxycmds.append('--config-option') 72 proxycmds.append('servers:global:http-proxy-host='+host) 73 if port.strip(): 161 if host: 74 162 proxycmds.append('--config-option') 75 proxycmds.append('servers:global:http-proxy-port='+port) 163 proxycmds.append('servers:global:http-proxy-host='+host) 164 if port: 165 proxycmds.append('--config-option') 166 proxycmds.append('servers:global:http-proxy-port='+port) 167 for item in etc: 168 proxycmds.append(item) 76 169 77 170 def whichsvn(): … … 90 183 svnprog = 'svn' 91 184 if sys.platform.startswith('win'): svnprog += '.exe' 92 host,port = getsvnProxy()185 host,port,etc = getsvnProxy() 93 186 if GetConfigValue('debug') and host: 94 187 print('DBG_Using proxy host {} port {}'.format(host,port)) … … 170 263 print('Checking python packages...') 171 264 missing = [] 172 for pkg in ['numpy','scipy','matplotlib','wx', ]:265 for pkg in ['numpy','scipy','matplotlib','wx','OpenGL',]: 173 266 try: 174 267 exec('import '+pkg) … … 176 269 missing.append(pkg) 177 270 178 if missing :271 if missing and not skipInstallChecks: 179 272 msg = """Sorry, this version of Python cannot be used 180 273 for GSAS-II. It is missing the following package(s): 181 274 \t""" 182 275 for pkg in missing: msg += " "+pkg 183 print(msg) 184 print("\nPlease install these package(s) and try running this again.") 185 print("Showing first error: ") 186 for pkg in ['numpy','scipy','matplotlib','wx',]: 187 exec('import '+pkg) 188 sys.exit() 189 try: 190 import OpenGL 191 install_with_easyinstall = None 192 except: 193 try: 194 from setuptools.command import easy_install 195 except ImportError: 196 print('You are missing the OpenGL Python package. This can be ') 197 print('installed by this script if the setuptools package is installed') 198 print('Please install either OpenGL (pyopengl) or setuptools') 199 print("package and try running this again.") 200 sys.exit() 201 print("Missing the OpenGL Python package. Will attempt to install this later.") 202 def install_with_easyinstall(package): 203 try: 204 print("trying system-wide ") 205 easy_install.main(['-f',os.path.split(__file__)[0],package]) 206 return 207 except: 208 pass 209 try: 210 print("trying user level ") 211 easy_install.main(['-f',os.path.split(__file__)[0],'--user',package]) 212 return 213 except: 214 print("\nInstall of "+package+" failed. Error traceback follows:") 215 import traceback 216 print(traceback.format_exc()) 217 sys.exit() 218 219 host = None 220 port = '80' 221 print('\nChecking for subversion...') 222 svn = whichsvn() # resets host & port if proxyinfo.txt is found 223 if not svn: 224 print("Sorry, subversion (svn) could not be found on your system.") 225 print("Please install this or place in path and rerun this.") 226 #raise Exception('Subversion (svn) not found') 227 sys.exit() 228 print(' found svn image: '+svn) 229 230 if install_with_easyinstall: 231 print('\nInstalling PyOpenGL. Lots of warnings will follow... ') 232 install_with_easyinstall('PyOpenGl') 233 print('done.') 276 msg += "\nPlease install these package(s) and try running bootstrap.py again." 277 #print("Showing first error: ") 278 #for pkg in ['numpy','scipy','matplotlib','wx','OpenGL',]: 279 # exec('import '+pkg) 280 BailOut(msg) 281 282 if not skipDownloadSteps: 283 host = None 284 port = '80' 285 print('\nChecking for subversion...') 286 svn = whichsvn() # resets host & port if proxyinfo.txt is found 287 if not svn: 288 msg ="Sorry, subversion (svn) could not be found on your system." 289 msg += "\nPlease install this or place in path and rerun this." 290 BailOut(msg) 291 else: 292 print(' found svn image: '+svn) 293 294 #if install_with_easyinstall: 295 # print('\nInstalling PyOpenGL. Lots of warnings will follow... ') 296 # install_with_easyinstall('PyOpenGl') 297 # print('done.') 234 298 235 299 print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2) 236 300 proxycmds = [] 237 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 238 if os.path.exists(proxyinfo): 239 fp = open(proxyinfo,'r') 240 host = fp.readline().strip() 241 port = fp.readline().strip() 242 fp.close() 243 os.remove(proxyinfo) 244 print(70*"=") 301 host,port,etc = getsvnProxy() 245 302 if sys.version_info[0] == 2: 246 303 getinput = raw_input … … 248 305 getinput = input 249 306 250 # get proxy from environment variable307 # get proxy setting from environment variable 251 308 key = None 252 309 for i in os.environ.keys(): … … 259 316 key = i 260 317 break 318 val = '' 261 319 if key: 262 320 val = os.environ[key].strip() 321 if val: 263 322 if val[-1] == '/': 264 323 val = val[:-1] … … 272 331 # get proxy from user, if terminal available 273 332 try: 274 if host: 333 if skipProxy: 334 host = "" 335 elif host: 336 print('\n'+75*'*') 275 337 ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ").strip() 276 338 if ans.lower() == "none": host = "" … … 282 344 if ans == "": ans=port 283 345 port = ans 346 print('If your site needs additional svn commands (such as \n\t', 347 '--config-option servers:global:http-proxy-username=*account*','\n\t', 348 '--config-option servers:global:http-proxy-password=*password*', 349 '\nenter them now:') 350 if etc: 351 prevetc = ' '.join(etc) 352 print('\nDefault for next input is "{}"'.format(prevetc)) 353 prompt = "Enter additional svn options (if any) [use previous]: " 354 else: 355 prompt = "Enter additional svn options (if any) [none]: " 356 ans = 'start' 357 etcstr = '' 358 while ans: 359 ans = getinput(prompt).strip() 360 prompt = "more svn options (if any): " 361 if etcstr: etcstr += ' ' 362 etcstr += ans 363 if etcstr.strip(): 364 etc = etcstr.split() 284 365 except EOFError: 285 366 host = "" 286 367 port = "" 368 etc = [] 369 setsvnProxy(host,port,etc) 370 # delete old proxy files 371 localproxy = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt") 372 for proxyinfo in localproxy,os.path.join(path2GSAS2,"proxyinfo.txt"): 373 if os.path.exists(proxyinfo): 374 try: 375 os.remove(proxyinfo) 376 print('Deleted file {}'.format(proxyinfo)) 377 except: 378 pass 287 379 if host: 288 proxycmds.append('--config-option')289 proxycmds.append('servers:global:http-proxy-host='+host.strip())290 if port:291 proxycmds.append('--config-option')292 proxy cmds.append('servers:global:http-proxy-port='+port.strip())293 fp = open(proxyinfo,'w')294 fp.write(host.strip()+'\n')295 fp.write(port.strip()+'\n')296 fp.close()297 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a')298 fp.write('Proxy info written: {} port\n'.format(host,port))299 print('Proxy info written: {} port'.format(host,port))300 fp.close()301 302 # patch: switch GSAS-II location if linked to XOR server (removed May/June 2017)303 cmd = [svn, 'info'] 304 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)305 res,err = p.communicate() 306 if '.xor.' in str(res): 307 print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')308 cmd = [svn, 'switch','--relocate','https://subversion.xor.aps.anl.gov/pyGSAS', 309 'https://subversion.xray.aps.anl.gov/pyGSAS']310 if proxycmds: cmd += proxycmds380 try: 381 fp = open(proxyinfo,'w') 382 except: 383 fp = open(localproxy,'w') 384 proxyinfo = localproxy 385 try: 386 fp.write(host.strip()+'\n') 387 fp.write(port.strip()+'\n') 388 for i in etc: 389 if i.strip(): 390 fp.write(i.strip()+'\n') 391 fp.close() 392 msg = 'Proxy info written: {} port {} etc {}\n'.format(host,port,etc) 393 print(msg) 394 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a') 395 fp.write(msg) 396 fp.close() 397 except Exception as err: 398 print('Error writing file {}:\n{}'.format(proxyinfo,err)) 399 400 if not skipDownloadSteps: 401 # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017) 402 cmd = [svn, 'info'] 311 403 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 312 404 res,err = p.communicate() 313 if err: 314 print('Please report this error to toby@anl.gov:') 315 print(err) 316 print(res) 317 # patch: switch GSAS-II location if switched to 2frame version (removed August 2017) 318 if '2frame' in str(res): 319 print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 320 cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2, 321 '--non-interactive','--trust-server-cert', 322 '--accept','theirs-conflict','--force','--ignore-ancestry'] 323 if proxycmds: cmd += proxycmds 324 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 325 res,err = p.communicate() 326 if err: 327 print('Please report this error to toby@anl.gov:') 328 print(err) 329 print(res) 330 331 print('\n'+75*'*') 332 print('Now preparing to install GSAS-II') 333 tryagain = True 334 err = False 335 firstPass = 0 336 while(tryagain): 337 tryagain = False 338 if err: 339 print('Retrying after a cleanup...') 340 cmd = [svn, 'cleanup', path2GSAS2] 405 if '.xor.' in str(res): 406 print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 407 cmd = [svn, 'switch','--relocate','https://subversion.xor.aps.anl.gov/pyGSAS', 408 'https://subversion.xray.aps.anl.gov/pyGSAS'] 409 if proxycmds: cmd += proxycmds 410 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 411 res,err = p.communicate() 412 if err: 413 print('Please report this error to toby@anl.gov:') 414 print(err) 415 print(res) 416 # patch: switch GSAS-II location if switched to 2frame version (removed August 2017) 417 if '2frame' in str(res): 418 print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 419 cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2, 420 '--non-interactive','--trust-server-cert', 421 '--accept','theirs-conflict','--force','--ignore-ancestry'] 422 if proxycmds: cmd += proxycmds 423 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 424 res,err = p.communicate() 425 if err: 426 print('Please report this error to toby@anl.gov:') 427 print(err) 428 print(res) 429 430 print('\n'+75*'*') 431 print('Now preparing to install GSAS-II') 432 tryagain = True 433 err = False 434 firstPass = 0 435 while(tryagain): 436 tryagain = False 437 if err: 438 print('Retrying after a cleanup...') 439 cmd = [svn, 'cleanup', path2GSAS2] 440 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 441 out,err = MakeByte2str(s.communicate()) 442 if err: 443 print('subversion returned an error:') 444 print(out) 445 print(err) 446 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2, '--non-interactive', '--trust-server-cert'] 447 if proxycmds: cmd += proxycmds 448 msg = 'svn load command: ' 449 for item in cmd: msg += " "+item 450 print(msg) 341 451 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 342 out,err = s.communicate() 452 print('\nsubversion output:') 453 out,err = MakeByte2str(s.communicate()) 343 454 if err: 344 455 print('subversion returned an error:') 345 456 print(out) 346 457 print(err) 347 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2, '--non-interactive', '--trust-server-cert'] 348 if proxycmds: cmd += proxycmds 349 msg = 'svn load command: ' 350 for item in cmd: msg += " "+item 351 print(msg) 352 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 353 print('\nsubversion output:') 354 out,err = s.communicate() 458 if firstPass == 0: tryagain = True 459 firstPass += 1 355 460 if err: 356 print('subversion returned an error:') 357 print(out) 358 print(err) 359 if firstPass == 0: tryagain = True 360 firstPass += 1 361 if err: 362 print('Retrying with a command for older svn version...') 363 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2] 364 if proxycmds: cmd += proxycmds 365 msg = "" 366 for item in cmd: msg += " " + item 367 print(msg) 368 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 369 out,err = s.communicate() 370 if err: 371 print('subversion returned an error:') 372 print(err) 373 print(' *** GSAS-II failed to be installed. A likely reason is a network access') 374 print(' *** problem, most commonly because you need to use a network proxy. Please') 375 print(' *** check with a network administrator or use http://www.whatismyproxy.com/\n') 376 sys.exit() 377 print('\n'+75*'*') 378 461 print('Retrying with a command for older svn version...') 462 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2] 463 if proxycmds: cmd += proxycmds 464 msg = "" 465 for item in cmd: msg += " " + item 466 print(msg) 467 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 468 out,err = MakeByte2str(s.communicate()) 469 if err: 470 msg = 'subversion returned an error:\n' 471 msg += err 472 if os.path.exists(os.path.join(path2GSAS2,"makeBat.py")): 473 msg += '\nGSAS-II appears to be installed but failed to be updated. A likely reason' 474 msg += '\nis a network access problem. If your web browser works, but this update did' 475 msg += '\nnot, the most common reason is you need to use a network proxy. Please' 476 msg += '\ncheck with a network administrator or use http://www.whatismyproxy.com/' 477 msg += '\n\nIf installing from the gsas2full dist and your computer is not connected' 478 msg += '\nto the internet, this error message can be ignored.\n' 479 else: 480 # this will happen only with initial installs where all files 481 # are to be downloaded (not gsas2full or updates) 482 msg += '\n\n *** GSAS-II failed to be installed. A likely reason is a network access' 483 msg += '\n *** problem, most commonly because you need to use a network proxy. Please' 484 msg += '\n *** check with a network administrator or use http://www.whatismyproxy.com/\n' 485 BailOut(msg) 486 print('\n'+75*'*') 487 488 # subsequent commands require GSASIIpath which better be here now, import it 379 489 try: 380 490 import GSASIIpath 381 491 print('import of GSASIIpath completed') 382 492 except Exception as err: 383 print('\n'+75*'=') 384 print('Failed with import of GSASIIpath. This is unexpected.') 385 print('GSAS-II will not run without correcting this. Contact toby@anl.gov') 386 print(err) 387 print(75*'=') 388 sys.exit() 389 390 for a in sys.argv[1:]: 391 if 'allbin' in a.lower() or 'server' in a.lower(): 392 print('Loading all binaries with command...') 393 if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True): 394 print('Binary load failed') 395 sys.exit() 396 break 493 msg = 'Failed with import of GSASIIpath. This is unexpected.' 494 msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov' 495 BailOut(msg) 496 497 if skipDownloadSteps: 498 pass 499 elif allBinaries: 500 print('Loading all binaries with command...') 501 if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True): 502 msg = 'Binary load failed. Subversion problem? Please seek help' 503 BailOut(msg) 504 elif numpyVersion: 505 binaryVersion = GSASIIpath.GetBinaryPrefix()+'_n'+numpyVersion 506 if not GSASIIpath.svnSwitchDir('bindist','',g2home+ 'Binaries/'+binaryVersion,None,True): 507 msg = 'Binary load failed with '+binaryVersion+'. Subversion problem? Please seek help' 508 BailOut(msg) 397 509 else: 398 510 GSASIIpath.DownloadG2Binaries(g2home) … … 401 513 # test if the compiled files load correctly 402 514 #=========================================================================== 403 404 script = """ # commands that test each module can at least be loaded & run something in pyspg 515 GSASIItested = False 516 if not skipInstallChecks: 517 script = """ 518 # commands that test each module can at least be loaded & run something in pyspg 405 519 try: 406 520 import GSASIIpath 407 GSASIIpath.SetBinaryPath( )521 GSASIIpath.SetBinaryPath(loadBinary=False) 408 522 import pyspg 409 523 import histogram2d … … 413 527 pyspg.sgforpy('P -1') 414 528 print('==OK==') 415 except :416 p ass529 except Exception as err: 530 print(err) 417 531 """ 418 p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE, 419 cwd=path2GSAS2) 420 res,err = p.communicate() 421 if '==OK==' not in str(res) or p.returncode != 0: 422 print('\n'+75*'=') 423 print('Failed when testing the GSAS-II compiled files. GSAS-II will not run') 424 print('without correcting this.\n\nError message:') 425 #print(res) 426 print(err) 427 #print('\nAttempting to open a web page on compiling GSAS-II...') 428 print('Please see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') 429 #import webbrowser 430 #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') 431 print(75*'=') 432 # if '86' in platform.machine() and (sys.platform.startswith('linux') 433 # or sys.platform == "darwin" 434 # or sys.platform.startswith('win')): 435 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported') 436 # else: 437 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported') 438 sys.exit() 439 else: 440 print('Successfully tested compiled routines') 532 p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE, 533 cwd=path2GSAS2) 534 res,err = MakeByte2str(p.communicate()) 535 if '==OK==' not in str(res) or p.returncode != 0: 536 #print('\n'+75*'=') 537 msg = 'Failed when testing the GSAS-II compiled files. GSAS-II will not run' 538 msg += ' without correcting this.\n\nError message:\n' 539 if res: 540 msg += res 541 msg += '\n' 542 if err: 543 msg += err 544 #print('\nAttempting to open a web page on compiling GSAS-II...') 545 msg += '\n\nPlease see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII if you wish to compile for yourself (usually not needed for windows and Mac, but sometimes required for Linux.)' 546 BailOut(msg) 547 #import webbrowser 548 #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') 549 #print(75*'=') 550 # if '86' in platform.machine() and (sys.platform.startswith('linux') 551 # or sys.platform == "darwin" 552 # or sys.platform.startswith('win')): 553 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported') 554 # else: 555 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported') 556 else: 557 print('Successfully tested compiled routines') 558 GSASIItested = True 441 559 #=========================================================================== 442 560 # import all .py files so that .pyc files get created 443 print('Byte-compiling all .py files...') 444 import compileall 445 compileall.compile_dir(path2GSAS2,quiet=True) 446 print('done') 447 #=========================================================================== 448 # platform-dependent stuff 561 if not skipInstallChecks: 562 print('Byte-compiling all .py files...') 563 import compileall 564 compileall.compile_dir(path2GSAS2,quiet=True) 565 print('done') 566 #=========================================================================== 567 # do platform-dependent stuff 449 568 #=========================================================================== 450 569 if sys.version_info[0] > 2: … … 452 571 with open(file) as source_file: 453 572 exec(source_file.read()) 573 574 if skipInstallChecks: 575 pass 576 #=========================================================================== 454 577 # on Windows, make a batch file with Python and GSAS-II location hard-coded 455 if sys.platform.startswith('win') and os.path.exists(578 elif sys.platform.startswith('win') and os.path.exists( 456 579 os.path.join(path2GSAS2,"makeBat.py")): 457 580 execfile(os.path.join(path2GSAS2,"makeBat.py"))
Note: See TracChangeset
for help on using the changeset viewer.