Changeset 4477 for install


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

Location:
install
Files:
3 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#===========================================================================
  • install/g2pkg/meta.yaml

    r3431 r4477  
    11package:
    22  name: gsas2pkg
    3   version: "1.0.6"  # remember to change in g2conda/construct.yaml to match this
     3  version: "1.1.0"  # remember to change in g2conda/construct.yaml to match this
    44
    55source:
     
    99  home: https://subversion.xray.aps.anl.gov/trac/pyGSAS
    1010
    11 #build:
    12 #  noarch: python
     11build:
     12  noarch: python
    1313
    1414requirements:
    1515  run:
    16     - python
     16    - python>=3.7
    1717    - conda
    18     - numpy
     18    - numpy>=1.18
    1919    - scipy
    20     - matplotlib
     20    - matplotlib=3.0,>=3.3
    2121    - pillow
    2222    - pyopengl
    23     - wxpython
     23    - wxpython>=4.0
    2424    - svn
    2525    - hdf5
  • install/g2pkg/src/bootstrap.py

    r3515 r4477  
    22# Installs GSAS-II from network using subversion and creates platform-specific shortcuts.
    33# works for Mac & Linux & Windows
     4from __future__ import division, print_function
    45import os, stat, sys, platform, subprocess, datetime
    56
     
    78g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS/'
    89path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
     10
     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
     22for 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
     43if 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
    959now = str(datetime.datetime.now())
    1060print('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
    1167fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a')
    1268fp.write('Running bootstrap from {} at {}\n\tId: {}\n'.format(path2GSAS2,now,version))
    1369fp.close()
     70       
    1471################################################################################
    1572################################################################################
     73def 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       
    1699def GetConfigValue(*args): return True
    17100# routines copied from GSASIIpath.py
     
    47130    '''Loads a proxy for subversion from the file created by bootstrap.py
    48131    '''
    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('#'):
    55143        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
     154def setsvnProxy(host,port,etc=[]):
    64155    '''Sets the svn commands needed to use a proxy
    65156    '''
     
    68159    host = host.strip()
    69160    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:
    74162        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)
    76169       
    77170def whichsvn():
     
    90183    svnprog = 'svn'
    91184    if sys.platform.startswith('win'): svnprog += '.exe'
    92     host,port = getsvnProxy()
     185    host,port,etc = getsvnProxy()
    93186    if GetConfigValue('debug') and host:
    94187        print('DBG_Using proxy host {} port {}'.format(host,port))
     
    170263print('Checking python packages...')
    171264missing = []
    172 for pkg in ['numpy','scipy','matplotlib','wx',]:
     265for pkg in ['numpy','scipy','matplotlib','wx','OpenGL',]:
    173266    try:
    174267        exec('import '+pkg)
     
    176269        missing.append(pkg)
    177270
    178 if missing:
     271if missing and not skipInstallChecks:
    179272    msg = """Sorry, this version of Python cannot be used
    180273for GSAS-II. It is missing the following package(s):
    181274\t"""
    182275    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
     282if 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.')
    234298   
    235299print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2)
    236300proxycmds = []
    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*"=")
     301host,port,etc = getsvnProxy()
    245302if sys.version_info[0] == 2:
    246303    getinput = raw_input
     
    248305    getinput = input
    249306
    250 # get proxy from environment variable
     307# get proxy setting from environment variable
    251308key = None
    252309for i in os.environ.keys():
     
    259316            key = i
    260317            break
     318val = ''
    261319if key:
    262320    val = os.environ[key].strip()
     321if val:
    263322    if val[-1] == '/':
    264323        val = val[:-1]
     
    272331# get proxy from user, if terminal available
    273332try:
    274     if host:
     333    if skipProxy:
     334        host = ""
     335    elif host:
     336        print('\n'+75*'*')
    275337        ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ").strip()
    276338        if ans.lower() == "none": host = ""
     
    282344        if ans == "": ans=port
    283345        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()
    284365except EOFError:
    285366    host = ""
    286367    port = ""
     368    etc = []
     369setsvnProxy(host,port,etc)
     370# delete old proxy files
     371localproxy = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt")
     372for 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
    287379if 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         proxycmds.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 += proxycmds
     380    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       
     400if not skipDownloadSteps:
     401    # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017)
     402    cmd = [svn, 'info']
    311403    p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    312404    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)
    341451        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    342         out,err = s.communicate()   
     452        print('\nsubversion output:')
     453        out,err = MakeByte2str(s.communicate())
    343454        if err:
    344455            print('subversion returned an error:')
    345456            print(out)
    346457            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
    355460    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
    379489try:
    380490    import GSASIIpath
    381491    print('import of GSASIIpath completed')
    382492except 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
     497if skipDownloadSteps:
     498    pass
     499elif 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)
     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)
    397509else:
    398510    GSASIIpath.DownloadG2Binaries(g2home)
     
    401513# test if the compiled files load correctly
    402514#===========================================================================
    403 
    404 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
    405519try:
    406520    import GSASIIpath
    407     GSASIIpath.SetBinaryPath()
     521    GSASIIpath.SetBinaryPath(loadBinary=False)
    408522    import pyspg
    409523    import histogram2d
     
    413527    pyspg.sgforpy('P -1')
    414528    print('==OK==')
    415 except:
    416     pass
     529except Exception as err:
     530    print(err)
    417531"""
    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
    441559#===========================================================================
    442560# 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
     561if 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
    449568#===========================================================================
    450569if sys.version_info[0] > 2:
     
    452571        with open(file) as source_file:
    453572            exec(source_file.read())
     573
     574if skipInstallChecks:
     575    pass
     576#===========================================================================
    454577# on Windows, make a batch file with Python and GSAS-II location hard-coded
    455 if sys.platform.startswith('win') and os.path.exists(
     578elif sys.platform.startswith('win') and os.path.exists(
    456579    os.path.join(path2GSAS2,"makeBat.py")):
    457580    execfile(os.path.join(path2GSAS2,"makeBat.py"))
Note: See TracChangeset for help on using the changeset viewer.