Changeset 4477 for install/bootstrap.py
- Timestamp:
- Jun 9, 2020 12:32:49 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
install/bootstrap.py
r4376 r4477 9 9 path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) 10 10 11 skipInstallSteps = False 12 skipDownloadSteps = False 13 skipProxy = False 14 showWXerror = False 15 help = False 16 allBinaries = False 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 17 22 for a in sys.argv[1:]: 18 23 if 'noinstall' in a.lower(): 19 skipInstall Steps = True24 skipInstallChecks = True 20 25 if sys.platform.startswith('win'): showWXerror = True 21 26 elif 'nonet' in a.lower(): … … 24 29 elif 'noproxy' in a.lower(): 25 30 skipProxy = True 26 elif 'help' in a.lower():27 help = True28 31 elif 'allbin' in a.lower() or 'server' in a.lower(): 29 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 30 38 else: 39 help = True 40 if 'help' in a.lower(): 31 41 help = True 32 42 … … 35 45 bootstrap.py options: 36 46 37 --noinstall skip post-install, such as creating run shortcuts 38 --noproxy do not ask for proxy information 39 --server load all binary versions 40 --allbin load all binary versions (same as --server) 41 --help this message 42 --nonet skip steps requiring internet 43 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 44 56 ''') 45 57 sys.exit() … … 47 59 now = str(datetime.datetime.now()) 48 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 49 67 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a') 50 68 fp.write('Running bootstrap from {} at {}\n\tId: {}\n'.format(path2GSAS2,now,version)) … … 68 86 dlg.Destroy() 69 87 else: 70 print("BOOTSTRAP WARNING: ",file=sys.stderr) 71 for line in msg.split('\n'): 72 print(line,file=sys.stderr) 73 print("Recreate this using command:") 88 print("Recreate error this using command:") 74 89 print(" {} {} {}".format( 75 90 os.path.abspath(sys.executable), … … 77 92 ' '.join(sys.argv[1:]), 78 93 ),file=sys.stderr) 94 print("\nBOOTSTRAP WARNING: ",file=sys.stderr) 95 for line in msg.split('\n'): 96 print(line,file=sys.stderr) 79 97 sys.exit() 80 98 … … 251 269 missing.append(pkg) 252 270 253 if missing and not skipInstall Steps:271 if missing and not skipInstallChecks: 254 272 msg = """Sorry, this version of Python cannot be used 255 273 for GSAS-II. It is missing the following package(s): … … 379 397 except Exception as err: 380 398 print('Error writing file {}:\n{}'.format(proxyinfo,err)) 399 381 400 if not skipDownloadSteps: 382 401 # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017) … … 452 471 msg += err 453 472 if os.path.exists(os.path.join(path2GSAS2,"makeBat.py")): 454 msg += '\n \nGSAS-II failed to be updated. A likely reason is a network access'455 msg += '\n problem. If your web browser works, but the update did not.'456 msg += '\n The most common reason is you need to use a network proxy. Please'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' 457 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' 458 479 else: 459 480 # this will happen only with initial installs where all files … … 465 486 print('\n'+75*'*') 466 487 488 # subsequent commands require GSASIIpath which better be here now, import it 467 489 try: 468 490 import GSASIIpath … … 473 495 BailOut(msg) 474 496 475 if allBinaries and not skipDownloadSteps: 497 if skipDownloadSteps: 498 pass 499 elif allBinaries: 476 500 print('Loading all binaries with command...') 477 501 if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True): 478 502 msg = 'Binary load failed. Subversion problem? Please seek help' 479 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) 480 509 else: 481 510 GSASIIpath.DownloadG2Binaries(g2home) … … 484 513 # test if the compiled files load correctly 485 514 #=========================================================================== 486 487 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 488 519 try: 489 520 import GSASIIpath … … 499 530 print(err) 500 531 """ 501 p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE, 502 cwd=path2GSAS2) 503 res,err = MakeByte2str(p.communicate()) 504 if '==OK==' not in str(res) or p.returncode != 0: 505 #print('\n'+75*'=') 506 msg = 'Failed when testing the GSAS-II compiled files. GSAS-II will not run' 507 msg += ' without correcting this.\n\nError message:\n' 508 if res: 509 msg += res 510 msg += '\n' 511 if err: 512 msg += err 513 #print('\nAttempting to open a web page on compiling GSAS-II...') 514 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.)' 515 BailOut(msg) 516 #import webbrowser 517 #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII') 518 #print(75*'=') 519 # if '86' in platform.machine() and (sys.platform.startswith('linux') 520 # or sys.platform == "darwin" 521 # or sys.platform.startswith('win')): 522 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported') 523 # else: 524 # print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported') 525 else: 526 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 527 559 #=========================================================================== 528 560 # import all .py files so that .pyc files get created 529 if not skipInstall Steps:561 if not skipInstallChecks: 530 562 print('Byte-compiling all .py files...') 531 563 import compileall … … 533 565 print('done') 534 566 #=========================================================================== 535 # platform-dependent stuff567 # do platform-dependent stuff 536 568 #=========================================================================== 537 569 if sys.version_info[0] > 2: … … 540 572 exec(source_file.read()) 541 573 542 if skipInstall Steps:574 if skipInstallChecks: 543 575 pass 544 576 #===========================================================================
Note: See TracChangeset
for help on using the changeset viewer.