Ignore:
Timestamp:
Jan 16, 2021 10:17:50 AM (9 months ago)
Author:
toby
Message:

fixes for windows g2complete

File:
1 edited

Legend:

Unmodified
Added
Removed
  • install/g2pkg/src/bootstrap.py

    r4732 r4771  
    1111skipInstallChecks = False  # if set to True, continue installation even if current Python lacks packages and
    1212                           # skips platform-dependent installation steps
     13                           #--> True: -noinstall or -binary=
    1314skipDownloadSteps = False  # if False, svn is used to download GSAS-II files and binaries
     15                           #--> True: -nonet
    1416skipProxy = False          # if False then the script creates a prompt asking for proxy info
     17                           #--> True: -nonet or -noproxy or -binary=
    1518showWXerror = False        # if True, errors are shown in wxPython windows (used on Windows only)
     19                           #--> True: -noinstall or -binary= (both on windows)
    1620help = False               # if True, a help message is shown
     21                           #--> True: -help
    1722allBinaries = 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
     25npVersion=None          # when set, gives a specific numpy version to use (such as 1.18)
    1926                           # for selecting a set of binaries to use
    20 numpyVersion=None
     27                           #--> Set by: -binary=
     28
     29pyVersion=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
    2133
    2234for a in sys.argv[1:]:
     
    3244        allBinaries = True
    3345    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)
    3552        skipInstallChecks = True
    3653        if sys.platform.startswith('win'): showWXerror = True
     
    5269    --help        this message
    5370    --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
    5676''')
    5777    sys.exit()
     
    253273    print(s)
    254274
    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)
     275def svncleanup(spath,svn=None):
     276    if not svn: svn = whichsvn()
     277    if not svn: return
    263278    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):
    265280        print('missing subversion tmp directory, fixing')       
    266281        cmd = ['mkdir',svntmp]
     
    269284        if out: print(out)
    270285        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
    272295def svnChecksumPatch(svn,fpath,verstr):
    273296    '''This performs a fix when svn cannot finish an update because of
     
    291314        print('import of GSASIIpath completed')
    292315    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.'
    294317        msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov'
    295318        print(err)
     
    479502if not skipDownloadSteps:
    480503    # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017)
    481     cmd = [svn, 'info']
     504    cmd = [svn, 'info',path2GSAS2]
    482505    p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    483506    res,err = p.communicate()
     
    485508        print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')
    486509        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]
    488511        if proxycmds: cmd += proxycmds
    489512        p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
     
    494517            print(res)
    495518    # 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):
    497520        print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')
    498521        cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2,
     
    506529            print(err)
    507530            print(res)
     531    elif 'not a working' not in str(res):
     532        svncleanup(path2GSAS2)
    508533
    509534    print('\n'+75*'*')
     
    562587            BailOut(msg)
    563588    print('\n'+75*'*')
     589else:
     590    svncleanup(path2GSAS2)
    564591
    565592# subsequent commands require GSASIIpath which better be here now, import it
     
    570597    msg = 'Failed with import of GSASIIpath. This is unexpected.'
    571598    msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov'
     599    print('GSASIIpath import error\n')
     600    print(err)
    572601    BailOut(msg)
    573602
     
    579608        msg = 'Binary load failed. Subversion problem? Please seek help'
    580609        BailOut(msg)
    581 elif numpyVersion:
    582     binaryVersion = GSASIIpath.GetBinaryPrefix()+'_n'+numpyVersion
     610elif npVersion:
     611    binaryVersion = GSASIIpath.GetBinaryPrefix(pyVersion)+'_n'+npVersion
     612    print('Load binaries from '+binaryVersion)
    583613    if not GSASIIpath.svnSwitchDir('bindist','',g2home+ 'Binaries/'+binaryVersion,None,True):
    584614        msg = 'Binary load failed with '+binaryVersion+'. Subversion problem? Please seek help'
    585615        BailOut(msg)
    586616else:
     617    print('Load binaries matching current python/numpy')
    587618    GSASIIpath.DownloadG2Binaries(g2home)
    588619       
     
    649680            exec(source_file.read())
    650681
     682#===========================================================================
     683# on Windows, make a batch file with Python and GSAS-II location hard-coded
    651684if skipInstallChecks:
    652685    pass
    653 #===========================================================================
    654 # on Windows, make a batch file with Python and GSAS-II location hard-coded
    655686elif sys.platform.startswith('win') and os.path.exists(
    656687    os.path.join(path2GSAS2,"makeBat.py")):
     
    659690# on a Mac, make an applescript
    660691elif sys.platform.startswith('darwin') and os.path.exists(
    661     os.path.join(path2GSAS2,"makeMacApp.py")):
     692         os.path.join(path2GSAS2,"makeMacApp.py")):
    662693    sys.argv = [os.path.join(path2GSAS2,"makeMacApp.py")]
    663694    print(u'running '+sys.argv[0])
     
    666697# On linux, make desktop icon
    667698elif sys.platform.startswith('linux') and os.path.exists(
    668     os.path.join(path2GSAS2,"makeLinux.py")):
     699         os.path.join(path2GSAS2,"makeLinux.py")):
    669700    sys.argv = [os.path.join(path2GSAS2,"makeLinux.py")]
    670701    print(u'running '+sys.argv[0])
Note: See TracChangeset for help on using the changeset viewer.