Changeset 4771 for install/g2pkg
- Timestamp:
- Jan 16, 2021 10:17:50 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
install/g2pkg/src/bootstrap.py
r4732 r4771 11 11 skipInstallChecks = False # if set to True, continue installation even if current Python lacks packages and 12 12 # skips platform-dependent installation steps 13 #--> True: -noinstall or -binary= 13 14 skipDownloadSteps = False # if False, svn is used to download GSAS-II files and binaries 15 #--> True: -nonet 14 16 skipProxy = False # if False then the script creates a prompt asking for proxy info 17 #--> True: -nonet or -noproxy or -binary= 15 18 showWXerror = False # if True, errors are shown in wxPython windows (used on Windows only) 19 #--> True: -noinstall or -binary= (both on windows) 16 20 help = False # if True, a help message is shown 21 #--> True: -help 17 22 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) 23 #--> True: -allbinaries or -server 24 25 npVersion=None # when set, gives a specific numpy version to use (such as 1.18) 19 26 # for selecting a set of binaries to use 20 numpyVersion=None 27 #--> Set by: -binary= 28 29 pyVersion=None # when set, gives a specific Python version to use (such as 3.7) 30 # for selecting a set of binaries to use 31 #--> Set by: -binary= 32 21 33 22 34 for a in sys.argv[1:]: … … 32 44 allBinaries = True 33 45 elif 'binary' in a.lower(): 34 numpyVersion = a.split('=')[1] 46 vers = a.split('=')[1].split(',') 47 npVersion = vers[0] 48 if len(vers) > 1: 49 pyVersion = vers[1] 50 print('Selecting Python binary',pyVersion) 51 print('Selecting numpy binary',npVersion) 35 52 skipInstallChecks = True 36 53 if sys.platform.startswith('win'): showWXerror = True … … 52 69 --help this message 53 70 --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 71 72 --binary=npver specifies a specific numpy/python version to use in selecting 73 --binary=npver,pyver a binary directory to use ; turns on --noinstall and --noproxy 74 (example --binary=1.18 or --binary=1.18,3.7) 75 turns on --noinstall and --noproxy 56 76 ''') 57 77 sys.exit() … … 253 273 print(s) 254 274 255 def svncleanup(spath): 256 cmd = [svn, 'cleanup', spath] 257 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 258 out,err = MakeByte2str(s.communicate()) 259 if err: 260 print('subversion cleanup returned an error:') 261 if out: print(out) 262 if err: print(err) 275 def svncleanup(spath,svn=None): 276 if not svn: svn = whichsvn() 277 if not svn: return 263 278 svntmp = os.path.join(spath,'.svn','tmp') 264 if not os.path.exists(svntmp):279 if os.path.exists(os.path.join(spath,'.svn')) and not os.path.exists(svntmp): 265 280 print('missing subversion tmp directory, fixing') 266 281 cmd = ['mkdir',svntmp] … … 269 284 if out: print(out) 270 285 if err: print(err) 271 286 if os.path.exists(os.path.join(spath,'.svn')): 287 cmd = [svn, 'cleanup', spath] 288 s = subprocess.Popen(cmd,stderr=subprocess.PIPE) 289 out,err = MakeByte2str(s.communicate()) 290 if err: 291 print('subversion cleanup returned an error:') 292 if out: print(out) 293 if err: print(err) 294 272 295 def svnChecksumPatch(svn,fpath,verstr): 273 296 '''This performs a fix when svn cannot finish an update because of … … 291 314 print('import of GSASIIpath completed') 292 315 except Exception as err: 293 msg = 'Failed with import of GSASIIpath . This is unexpected.'316 msg = 'Failed with import of GSASIIpath in svnChecksumPatch. This is unexpected.' 294 317 msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov' 295 318 print(err) … … 479 502 if not skipDownloadSteps: 480 503 # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017) 481 cmd = [svn, 'info' ]504 cmd = [svn, 'info',path2GSAS2] 482 505 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 483 506 res,err = p.communicate() … … 485 508 print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 486 509 cmd = [svn, 'switch','--relocate','https://subversion.xor.aps.anl.gov/pyGSAS', 487 'https://subversion.xray.aps.anl.gov/pyGSAS' ]510 'https://subversion.xray.aps.anl.gov/pyGSAS',path2GSAS2] 488 511 if proxycmds: cmd += proxycmds 489 512 p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE) … … 494 517 print(res) 495 518 # patch: switch GSAS-II location if switched to 2frame version (removed August 2017) 496 if '2frame' in str(res):519 elif '2frame' in str(res): 497 520 print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS') 498 521 cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2, … … 506 529 print(err) 507 530 print(res) 531 elif 'not a working' not in str(res): 532 svncleanup(path2GSAS2) 508 533 509 534 print('\n'+75*'*') … … 562 587 BailOut(msg) 563 588 print('\n'+75*'*') 589 else: 590 svncleanup(path2GSAS2) 564 591 565 592 # subsequent commands require GSASIIpath which better be here now, import it … … 570 597 msg = 'Failed with import of GSASIIpath. This is unexpected.' 571 598 msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov' 599 print('GSASIIpath import error\n') 600 print(err) 572 601 BailOut(msg) 573 602 … … 579 608 msg = 'Binary load failed. Subversion problem? Please seek help' 580 609 BailOut(msg) 581 elif numpyVersion: 582 binaryVersion = GSASIIpath.GetBinaryPrefix()+'_n'+numpyVersion 610 elif npVersion: 611 binaryVersion = GSASIIpath.GetBinaryPrefix(pyVersion)+'_n'+npVersion 612 print('Load binaries from '+binaryVersion) 583 613 if not GSASIIpath.svnSwitchDir('bindist','',g2home+ 'Binaries/'+binaryVersion,None,True): 584 614 msg = 'Binary load failed with '+binaryVersion+'. Subversion problem? Please seek help' 585 615 BailOut(msg) 586 616 else: 617 print('Load binaries matching current python/numpy') 587 618 GSASIIpath.DownloadG2Binaries(g2home) 588 619 … … 649 680 exec(source_file.read()) 650 681 682 #=========================================================================== 683 # on Windows, make a batch file with Python and GSAS-II location hard-coded 651 684 if skipInstallChecks: 652 685 pass 653 #===========================================================================654 # on Windows, make a batch file with Python and GSAS-II location hard-coded655 686 elif sys.platform.startswith('win') and os.path.exists( 656 687 os.path.join(path2GSAS2,"makeBat.py")): … … 659 690 # on a Mac, make an applescript 660 691 elif sys.platform.startswith('darwin') and os.path.exists( 661 os.path.join(path2GSAS2,"makeMacApp.py")):692 os.path.join(path2GSAS2,"makeMacApp.py")): 662 693 sys.argv = [os.path.join(path2GSAS2,"makeMacApp.py")] 663 694 print(u'running '+sys.argv[0]) … … 666 697 # On linux, make desktop icon 667 698 elif sys.platform.startswith('linux') and os.path.exists( 668 os.path.join(path2GSAS2,"makeLinux.py")):699 os.path.join(path2GSAS2,"makeLinux.py")): 669 700 sys.argv = [os.path.join(path2GSAS2,"makeLinux.py")] 670 701 print(u'running '+sys.argv[0])
Note: See TracChangeset
for help on using the changeset viewer.