Changeset 4477 for install/bootstrap.py


Ignore:
Timestamp:
Jun 9, 2020 12:32:49 PM (3 years ago)
Author:
toby
Message:

update new version of g2conda: 3.7+, mpl 3.0 or 3.3; sync up bootstrap.py versions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • install/bootstrap.py

    r4376 r4477  
    99path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
    1010
    11 skipInstallSteps = False
    12 skipDownloadSteps = False
    13 skipProxy = False
    14 showWXerror = False
    15 help = False
    16 allBinaries = False
     11skipInstallChecks = False  # if set to True, continue installation even if current Python lacks packages and
     12                           # skips platform-dependent installation steps
     13skipDownloadSteps = False  # if False, svn is used to download GSAS-II files and binaries
     14skipProxy = False          # if False then the script creates a prompt asking for proxy info
     15showWXerror = False        # if True, errors are shown in wxPython windows (used on Windows only)
     16help = False               # if True, a help message is shown
     17allBinaries = False        # if True, causes all binaries to be installed
     18binaryVersion=None         # if specified, gives a specific numpy version to use (such as 1.18)
     19                           # for selecting a set of binaries to use
     20numpyVersion=None
     21
    1722for a in sys.argv[1:]:
    1823    if 'noinstall' in a.lower():
    19         skipInstallSteps = True
     24        skipInstallChecks = True
    2025        if sys.platform.startswith('win'): showWXerror = True
    2126    elif 'nonet' in a.lower():
     
    2429    elif 'noproxy' in a.lower():
    2530        skipProxy = True
    26     elif 'help' in a.lower():
    27         help = True
    2831    elif 'allbin' in a.lower() or 'server' in a.lower():
    2932        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
    3038    else:
     39        help = True
     40    if 'help' in a.lower():
    3141        help = True
    3242
     
    3545  bootstrap.py options:
    3646
    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
    4456''')
    4557    sys.exit()
     
    4759now = str(datetime.datetime.now())
    4860print('Running bootstrap from {} at {}\n\tId: {}'.format(path2GSAS2,now,version))
     61print ("Python:     %s"%sys.version.split()[0])
     62try:
     63    import numpy as np
     64    print ("numpy:      %s"%np.__version__)
     65except:
     66    pass
    4967fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a')
    5068fp.write('Running bootstrap from {} at {}\n\tId: {}\n'.format(path2GSAS2,now,version))
     
    6886        dlg.Destroy()
    6987    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:")
    7489        print("     {} {} {}".format(
    7590            os.path.abspath(sys.executable),
     
    7792            ' '.join(sys.argv[1:]),
    7893        ),file=sys.stderr)
     94        print("\nBOOTSTRAP WARNING: ",file=sys.stderr)
     95        for line in msg.split('\n'):
     96            print(line,file=sys.stderr)
    7997    sys.exit()
    8098       
     
    251269        missing.append(pkg)
    252270
    253 if missing and not skipInstallSteps:
     271if missing and not skipInstallChecks:
    254272    msg = """Sorry, this version of Python cannot be used
    255273for GSAS-II. It is missing the following package(s):
     
    379397    except Exception as err:
    380398        print('Error writing file {}:\n{}'.format(proxyinfo,err))
     399       
    381400if not skipDownloadSteps:
    382401    # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017)
     
    452471            msg += err
    453472            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 += '\nproblem. If your web browser works, but the update did not.'
    456                 msg += '\nThe 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'
    457476                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'
    458479            else:
    459480                # this will happen only with initial installs where all files
     
    465486    print('\n'+75*'*')
    466487
     488# subsequent commands require GSASIIpath which better be here now, import it
    467489try:
    468490    import GSASIIpath
     
    473495    BailOut(msg)
    474496
    475 if allBinaries and not skipDownloadSteps:
     497if skipDownloadSteps:
     498    pass
     499elif allBinaries:
    476500    print('Loading all binaries with command...')
    477501    if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True):
    478502        msg = 'Binary load failed. Subversion problem? Please seek help'
    479503        BailOut(msg)
     504elif 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)
    480509else:
    481510    GSASIIpath.DownloadG2Binaries(g2home)
     
    484513# test if the compiled files load correctly
    485514#===========================================================================
    486 
    487 script = """  # commands that test each module can at least be loaded & run something in pyspg
     515GSASIItested = False
     516if not skipInstallChecks:
     517    script = """ 
     518# commands that test each module can at least be loaded & run something in pyspg
    488519try:
    489520    import GSASIIpath
     
    499530    print(err)
    500531"""
    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
    527559#===========================================================================
    528560# import all .py files so that .pyc files get created
    529 if not skipInstallSteps:
     561if not skipInstallChecks:
    530562    print('Byte-compiling all .py files...')
    531563    import compileall
     
    533565    print('done')
    534566#===========================================================================
    535 # platform-dependent stuff
     567# do platform-dependent stuff
    536568#===========================================================================
    537569if sys.version_info[0] > 2:
     
    540572            exec(source_file.read())
    541573
    542 if skipInstallSteps:
     574if skipInstallChecks:
    543575    pass
    544576#===========================================================================
Note: See TracChangeset for help on using the changeset viewer.