source: install/bootstrap.py @ 4740

Last change on this file since 4740 was 4739, checked in by toby, 10 months ago

more install work

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 25.6 KB
Line 
1#!/usr/bin/env python
2# Installs GSAS-II from network using subversion and creates platform-specific shortcuts.
3# works for Mac & Linux & Windows
4from __future__ import division, print_function
5import os, stat, sys, platform, subprocess, datetime
6
7version = "$Id: bootstrap.py 4739 2021-01-07 22:28:30Z toby $"
8g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS/'
9path2GSAS2 = 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
13                           #--> True: -noinstall or -binary=
14skipDownloadSteps = False  # if False, svn is used to download GSAS-II files and binaries
15                           #--> True: -nonet
16skipProxy = False          # if False then the script creates a prompt asking for proxy info
17                           #--> True: -nonet or -noproxy or -binary=
18showWXerror = False        # if True, errors are shown in wxPython windows (used on Windows only)
19                           #--> True: -noinstall or -binary= (both on windows)
20help = False               # if True, a help message is shown
21                           #--> True: -help
22allBinaries = False        # if True, causes all binaries to be installed
23                           #--> True: -allbinaries or -server
24numpyVersion=None          # if specified, gives a specific numpy version to use (such as 1.18)
25                           # for selecting a set of binaries to use
26                           #--> Set by: -binary=
27
28for a in sys.argv[1:]:
29    if 'noinstall' in a.lower():
30        skipInstallChecks = True
31        if sys.platform.startswith('win'): showWXerror = True
32    elif 'nonet' in a.lower():
33        skipDownloadSteps = True
34        skipProxy = True
35    elif 'noproxy' in a.lower():
36        skipProxy = True
37    elif 'allbin' in a.lower() or 'server' in a.lower():
38        allBinaries = True
39    elif 'binary' in a.lower():
40        numpyVersion = a.split('=')[1]
41        skipInstallChecks = True
42        if sys.platform.startswith('win'): showWXerror = True
43        skipProxy = True
44    else:
45        help = True
46    if 'help' in a.lower():
47        help = True
48
49if help:
50    print('''
51  bootstrap.py options:
52
53    --noinstall   skip post-install, such as creating run shortcuts, turns on
54                  wxpython error display in Windows
55    --noproxy     do not ask for proxy information
56    --server      load all binary versions
57    --allbin      load all binary versions (same as --server)
58    --help        this message
59    --nonet       skip steps requiring internet
60    --binary=ver  specifies a specific numpy binary directory to use (such as
61                  --binary=1.18); turns on --noinstall and --noproxy
62''')
63    sys.exit()
64
65now = str(datetime.datetime.now())
66print('Running bootstrap from {} at {}\n\tId: {}'.format(path2GSAS2,now,version))
67print ("Python:     %s"%sys.version.split()[0])
68try:
69    import numpy as np
70    print ("numpy:      %s"%np.__version__)
71except:
72    pass
73fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a')
74fp.write('Running bootstrap from {} at {}\n\tId: {}\n'.format(path2GSAS2,now,version))
75fp.close()
76       
77################################################################################
78################################################################################
79def BailOut(msg):
80    '''Exit with an error message. Use a GUI to show the error when
81    showWXerror == True (on windows when --noinstall is specified)
82    '''
83    print(msg)
84    if showWXerror:
85        import wx
86        app = wx.App()
87        app.MainLoop()
88        dlg = wx.MessageDialog(None,msg,'GSAS-II installation error', 
89                wx.OK | wx.ICON_ERROR | wx.STAY_ON_TOP)
90        dlg.Raise()
91        dlg.ShowModal()
92        dlg.Destroy()
93    else:
94        print("Recreate error this using command:")
95        print("     {} {} {}".format(
96            os.path.abspath(sys.executable),
97            os.path.abspath(os.path.expanduser(__file__)),
98            ' '.join(sys.argv[1:]),
99        ),file=sys.stderr)
100        print("\nBOOTSTRAP WARNING: ",file=sys.stderr)
101        for line in msg.split('\n'):
102            print(line,file=sys.stderr)
103    sys.exit()
104       
105def GetConfigValue(*args): return True
106# routines copied from GSASIIpath.py
107proxycmds = []
108'Used to hold proxy information for subversion, set if needed in whichsvn'
109svnLocCache = None
110'Cached location of svn to avoid multiple searches for it'
111
112def MakeByte2str(arg):
113    '''Convert output from subprocess pipes (bytes) to str (unicode) in Python 3.
114    In Python 2: Leaves output alone (already str).
115    Leaves stuff of other types alone (including unicode in Py2)
116    Works recursively for string-like stuff in nested loops and tuples.
117
118    typical use::
119
120        out = MakeByte2str(out)
121
122    or::
123
124        out,err = MakeByte2str(s.communicate())
125   
126    '''
127    if isinstance(arg,str): return arg
128    if isinstance(arg,bytes):
129        try:
130            return arg.decode()
131        except:
132            print('Decode error')
133            return arg
134    if isinstance(arg,list):
135        return [MakeByte2str(i) for i in arg]
136    if isinstance(arg,tuple):
137        return tuple([MakeByte2str(i) for i in arg])
138    return arg
139
140def getsvnProxy():
141    '''Loads a proxy for subversion from the file created by bootstrap.py
142    '''
143    global proxycmds
144    proxycmds = []
145    proxyinfo = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt")
146    if not os.path.exists(proxyinfo):
147        proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt")
148    if not os.path.exists(proxyinfo):
149        return '','',''
150    fp = open(proxyinfo,'r')
151    host = fp.readline().strip()
152    # allow file to begin with comments
153    while host.startswith('#'):
154        host = fp.readline().strip()
155    port = fp.readline().strip()
156    etc = []
157    line = fp.readline()
158    while line:
159        etc.append(line.strip())
160        line = fp.readline()
161    fp.close()
162    setsvnProxy(host,port,etc)
163    return host,port,etc
164
165def setsvnProxy(host,port,etc=[]):
166    '''Sets the svn commands needed to use a proxy
167    '''
168    global proxycmds
169    proxycmds = []
170    host = host.strip()
171    port = port.strip()
172    if host: 
173        proxycmds.append('--config-option')
174        proxycmds.append('servers:global:http-proxy-host='+host)
175        if port:
176            proxycmds.append('--config-option')
177            proxycmds.append('servers:global:http-proxy-port='+port)
178    for item in etc:
179        proxycmds.append(item)
180       
181def whichsvn():
182    '''Returns a path to the subversion exe file, if any is found.
183    Searches the current path after adding likely places where GSAS-II
184    might install svn.
185
186    :returns: None if svn is not found or an absolute path to the subversion
187      executable file.
188    '''
189    # use a previosuly cached svn location
190    global svnLocCache
191    if svnLocCache: return svnLocCache
192    # prepare to find svn
193    is_exe = lambda fpath: os.path.isfile(fpath) and os.access(fpath, os.X_OK)
194    svnprog = 'svn'
195    if sys.platform.startswith('win'): svnprog += '.exe'
196    host,port,etc = getsvnProxy()
197    if GetConfigValue('debug') and host:
198        print('DBG_Using proxy host {} port {}'.format(host,port))
199    # add likely places to find subversion when installed with GSAS-II
200    pathlist = os.environ["PATH"].split(os.pathsep)
201    pathlist.insert(0,os.path.split(sys.executable)[0])
202    pathlist.insert(1,path2GSAS2)
203    for rpt in ('..','bin'),('..','Library','bin'),('svn','bin'),('svn',),('.'):
204        pt = os.path.normpath(os.path.join(path2GSAS2,*rpt))
205        if os.path.exists(pt):
206            pathlist.insert(0,pt)   
207    # search path for svn or svn.exe
208    for path in pathlist:
209        exe_file = os.path.join(path, svnprog)
210        if is_exe(exe_file):
211            try:
212                p = subprocess.Popen([exe_file,'help'],stdout=subprocess.PIPE)
213                res = p.stdout.read()
214                p.communicate()
215                svnLocCache = os.path.abspath(exe_file)
216                return svnLocCache
217            except:
218                pass       
219    svnLocCache = None
220
221def svnVersion(svn=None):
222    '''Get the version number of the current subversion executable
223
224    :returns: a string with a version number such as "1.6.6" or None if
225      subversion is not found.
226
227    '''
228    if not svn: svn = whichsvn()
229    if not svn: return
230
231    cmd = [svn,'--version','--quiet']
232    s = subprocess.Popen(cmd,
233                         stdout=subprocess.PIPE,stderr=subprocess.PIPE)
234    out,err = MakeByte2str(s.communicate())
235    if err:
236        print ('subversion error!\nout=%s'%out)
237        print ('err=%s'%err)
238        s = '\nsvn command:  '
239        for i in cmd: s += i + ' '
240        print(s)
241        return None
242    return out.strip()
243
244def svnVersionNumber(svn=None):
245    '''Get the version number of the current subversion executable
246
247    :returns: a fractional version number such as 1.6 or None if
248      subversion is not found.
249
250    '''
251    ver = svnVersion(svn)
252    if not ver: return 
253    M,m = ver.split('.')[:2]
254    return int(M)+int(m)/10.
255
256def showsvncmd(cmd):
257    s = '\nsvn command:  '
258    for i in cmd: s += i + ' '
259    print(s)
260
261def svncleanup(spath):
262    cmd = [svn, 'cleanup', spath]
263    s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
264    out,err = MakeByte2str(s.communicate())
265    if err:
266        print('subversion cleanup returned an error:')
267        if out: print(out)
268        if err: print(err)
269    svntmp = os.path.join(spath,'.svn','tmp')
270    if not os.path.exists(svntmp):
271        print('missing subversion tmp directory, fixing')       
272        cmd = ['mkdir',svntmp]
273        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
274        out,err = MakeByte2str(s.communicate())
275        if out: print(out)
276        if err: print(err)
277   
278def svnChecksumPatch(svn,fpath,verstr):
279    '''This performs a fix when svn cannot finish an update because of
280    a Checksum mismatch error. This seems to be happening on OS X for
281    unclear reasons.
282    '''
283    svntmp = os.path.join(fpath,'.svn','tmp')
284    if not os.path.exists(svntmp):
285        print('missing subversion tmp directory')
286    print('\nAttempting patch for svn Checksum mismatch error\n')
287    svncleanup(fpath)
288    cmd = ['svn','update','--set-depth','empty',
289               os.path.join(fpath,'bindist')]
290    showsvncmd(cmd)       
291    s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
292    out,err = MakeByte2str(s.communicate())
293    print(svntmp, os.path.exists(svntmp))
294    #if err: print('error=',err)
295    try:
296        import GSASIIpath
297        print('import of GSASIIpath completed')
298    except Exception as err:
299        msg = 'Failed with import of GSASIIpath in svnChecksumPatch. This is unexpected.'
300        msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov'
301        print(err)
302        BailOut(msg)
303    cmd = ['svn','switch',g2home+'/trunk/bindist',
304               os.path.join(fpath,'bindist'),
305               '--non-interactive', '--trust-server-cert', '--accept',
306               'theirs-conflict', '--force', '-rHEAD', '--ignore-ancestry']
307    showsvncmd(cmd)       
308    s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
309    out,err = MakeByte2str(s.communicate())
310    GSASIIpath.DownloadG2Binaries(g2home,verbose=True)
311    cmd = ['svn','update','--set-depth','infinity',
312               os.path.join(fpath,'bindist')]
313    showsvncmd(cmd)       
314    s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
315    out,err = MakeByte2str(s.communicate())
316    #if err: print('error=',err)
317    cmd = [svn,'update',fpath,verstr,
318                       '--non-interactive',
319                       '--accept','theirs-conflict','--force']
320    if svnVersionNumber() >= 1.6:
321        cmd += ['--trust-server-cert']
322    if proxycmds: cmd += proxycmds
323    #print(cmd)
324    showsvncmd(cmd)       
325    s = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
326    out,err = MakeByte2str(s.communicate())
327    #if err: print('error=',err)
328    return err
329
330################################################################################
331################################################################################
332print(70*'*')
333#testing for incorrect locale code'
334try:
335    import locale
336    locale.getdefaultlocale()
337except ValueError:
338    print('Your location is not set properly. This causes problems for matplotlib')
339    print('  (see https://github.com/matplotlib/matplotlib/issues/5420.)')
340    print('Will try to bypass problem by setting LC_ALL to en_US.UTF-8 (US English)')
341    os.environ['LC_ALL'] = 'en_US.UTF-8'
342    locale.getdefaultlocale()
343print('Preloading matplotlib to build fonts...')
344try:
345    import matplotlib
346except:
347    pass
348print('Checking python packages...')
349missing = []
350for pkg in ['numpy','scipy','matplotlib','wx','OpenGL',]:
351    try:
352        exec('import '+pkg)
353    except:
354        missing.append(pkg)
355
356if missing and not skipInstallChecks:
357    msg = """Sorry, this version of Python cannot be used
358for GSAS-II. It is missing the following package(s):
359\t"""
360    for pkg in missing: msg += " "+pkg
361    msg += "\nPlease install these package(s) and try running bootstrap.py again."
362    #print("Showing first error: ")
363    #for pkg in ['numpy','scipy','matplotlib','wx','OpenGL',]:
364    #    exec('import '+pkg)
365    BailOut(msg)
366
367if not skipDownloadSteps:
368    host = None
369    port = '80'
370    print('\nChecking for subversion...')
371    svn = whichsvn() # resets host & port if proxyinfo.txt is found
372    if not svn:
373        msg ="Sorry, subversion (svn) could not be found on your system."
374        msg += "\nPlease install this or place in path and rerun this."
375        BailOut(msg)
376    else:
377        print(' found svn image: '+svn)
378
379#if install_with_easyinstall:           
380#    print('\nInstalling PyOpenGL. Lots of warnings will follow... ')
381#    install_with_easyinstall('PyOpenGl')               
382#    print('done.')
383   
384print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2)
385proxycmds = []
386host,port,etc = getsvnProxy()
387if sys.version_info[0] == 2:
388    getinput = raw_input
389else:
390    getinput = input
391
392# get proxy setting from environment variable
393key = None
394for i in os.environ.keys():
395    if 'https_proxy' == i.lower():
396        key = i
397        break
398else:
399    for i in os.environ.keys():
400        if 'http_proxy' == i.lower():
401            key = i
402            break
403val = ''
404if key:
405    val = os.environ[key].strip()
406if val:
407    if val[-1] == '/':
408        val = val[:-1]
409    if len(val.split(':')) > 2:
410        host = ':'.join(val.split(':')[:-1])
411        port = val.split(':')[-1]
412    else:
413        host = ':'.join(val.split(':')[:-1])
414        port = val.split(':')[-1]
415
416# get proxy from user, if terminal available
417try:
418    if skipProxy:
419        host = ""
420    elif host:
421        print('\n'+75*'*')
422        ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ").strip()
423        if ans.lower() == "none": host = ""
424    else:
425        ans = getinput("Enter your proxy address [none needed]: ").strip()
426        if ans: host = ans
427    if host:
428        ans = getinput("Enter the proxy port ["+port+"]: ").strip()
429        if ans == "": ans=port
430        port = ans
431        print('If your site needs additional svn commands (such as \n\t',
432                  '--config-option servers:global:http-proxy-username=*account*','\n\t',
433                  '--config-option servers:global:http-proxy-password=*password*',
434                  '\nenter them now:')
435        if etc:
436            prevetc = ' '.join(etc)
437            print('\nDefault for next input is "{}"'.format(prevetc))
438            prompt = "Enter additional svn options (if any) [use previous]: "
439        else:
440            prompt = "Enter additional svn options (if any) [none]: "
441        ans = 'start'
442        etcstr = ''
443        while ans:
444            ans = getinput(prompt).strip()
445            prompt = "more svn options (if any): "
446            if etcstr: etcstr += ' '
447            etcstr += ans
448        if etcstr.strip():
449           etc = etcstr.split()
450except EOFError:
451    host = ""
452    port = ""
453    etc = []
454setsvnProxy(host,port,etc)
455# delete old proxy files
456localproxy = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt")
457for proxyinfo in localproxy,os.path.join(path2GSAS2,"proxyinfo.txt"):
458    if os.path.exists(proxyinfo):
459        try:
460            os.remove(proxyinfo)
461            print('Deleted file {}'.format(proxyinfo))
462        except:
463            pass
464if host:
465    try:
466        fp = open(proxyinfo,'w')
467    except:
468        fp = open(localproxy,'w')
469        proxyinfo = localproxy
470    try:
471        fp.write(host.strip()+'\n')
472        fp.write(port.strip()+'\n')
473        for i in etc:
474            if i.strip():
475                fp.write(i.strip()+'\n')
476        fp.close()
477        msg = 'Proxy info written: {} port {} etc {}\n'.format(host,port,etc)
478        print(msg)
479        fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a')
480        fp.write(msg)
481        fp.close()
482    except Exception as err:
483        print('Error writing file {}:\n{}'.format(proxyinfo,err))
484       
485if not skipDownloadSteps:
486    # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017)
487    cmd = [svn, 'info']
488    p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
489    res,err = p.communicate()
490    if '.xor.' in str(res):
491        print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')
492        cmd = [svn, 'switch','--relocate','https://subversion.xor.aps.anl.gov/pyGSAS',
493               'https://subversion.xray.aps.anl.gov/pyGSAS']
494        if proxycmds: cmd += proxycmds
495        p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
496        res,err = p.communicate()
497        if err:
498            print('Please report this error to toby@anl.gov:')
499            print(err)
500            print(res)
501    # patch: switch GSAS-II location if switched to 2frame version (removed August 2017)
502    if '2frame' in str(res):
503        print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')
504        cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2,
505               '--non-interactive','--trust-server-cert',
506               '--accept','theirs-conflict','--force','--ignore-ancestry']
507        if proxycmds: cmd += proxycmds
508        p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
509        res,err = p.communicate()
510        if err:
511            print('Please report this error to toby@anl.gov:')
512            print(err)
513            print(res)
514
515    print('\n'+75*'*')
516    print('Now preparing to install GSAS-II')
517    tryagain = True
518    err = False
519    firstPass = 0
520    while(tryagain):
521        tryagain = False
522        if err:
523            print('Retrying after a cleanup...')
524            svncleanup(path2GSAS2)
525        cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2, '--non-interactive', '--trust-server-cert']
526        if proxycmds: cmd += proxycmds
527        msg = 'svn load command: '
528        for item in cmd: msg += " "+item
529        print(msg)
530        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
531        print('\nsubversion output:')
532        out,err = MakeByte2str(s.communicate())
533        if 'Checksum' in err:  # deal with Checksum problem
534            err = svnChecksumPatch(svn,path2GSAS2,'-rHEAD')
535            if err:
536                print('error from svnChecksumPatch\n\t',err)
537        elif err:
538            print('subversion returned an error:')
539            print(out)
540            print(err)
541            if firstPass == 0: tryagain = True
542        firstPass += 1
543    if err:
544        print('Retrying with a command for older svn version...')
545        cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2]
546        if proxycmds: cmd += proxycmds
547        msg = ""
548        for item in cmd: msg += " " + item
549        print(msg)
550        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
551        out,err = MakeByte2str(s.communicate())
552        if err:
553            msg = 'subversion returned an error:\n'
554            msg += err
555            if os.path.exists(os.path.join(path2GSAS2,"makeBat.py")):
556                msg += '\nGSAS-II appears to be installed but failed to be updated. A likely reason'
557                msg += '\nis a network access problem. If your web browser works, but this update did'
558                msg += '\nnot, the most common reason is you need to use a network proxy. Please'
559                msg += '\ncheck with a network administrator or use http://www.whatismyproxy.com/'
560                msg += '\n\nIf installing from the gsas2full dist and your computer is not connected'
561                msg += '\nto the internet, this error message can be ignored.\n'
562            else:
563                # this will happen only with initial installs where all files
564                # are to be downloaded (not gsas2full or updates)
565                msg += '\n\n  *** GSAS-II failed to be installed. A likely reason is a network access'
566                msg += '\n  *** problem, most commonly because you need to use a network proxy. Please'
567                msg += '\n  *** check with a network administrator or use http://www.whatismyproxy.com/\n'
568            BailOut(msg)
569    print('\n'+75*'*')
570
571# subsequent commands require GSASIIpath which better be here now, import it
572try:
573    import GSASIIpath
574    print('import of GSASIIpath completed')
575except Exception as err:
576    msg = 'Failed with import of GSASIIpath. This is unexpected.'
577    msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov'
578    print('GSASIIpath import error\n')
579    print(err)
580    BailOut(msg)
581
582if skipDownloadSteps:
583    pass
584elif allBinaries:
585    print('Loading all binaries with command...')
586    if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True):
587        msg = 'Binary load failed. Subversion problem? Please seek help'
588        BailOut(msg)
589elif numpyVersion:
590    binaryVersion = GSASIIpath.GetBinaryPrefix()+'_n'+numpyVersion
591    print('Load binaries from '+binaryVersion)
592    if not GSASIIpath.svnSwitchDir('bindist','',g2home+ 'Binaries/'+binaryVersion,None,True):
593        msg = 'Binary load failed with '+binaryVersion+'. Subversion problem? Please seek help'
594        BailOut(msg)
595else:
596    print('Load binaries matching current python/numpy')
597    GSASIIpath.DownloadG2Binaries(g2home)
598       
599#===========================================================================
600# test if the compiled files load correctly
601#===========================================================================
602GSASIItested = False
603if not skipInstallChecks:
604    script = """ 
605# commands that test each module can at least be loaded & run something in pyspg
606try:
607    import GSASIIpath
608    GSASIIpath.SetBinaryPath(loadBinary=False)
609    import pyspg
610    import histogram2d
611    import polymask
612    import pypowder
613    import pytexture
614    pyspg.sgforpy('P -1')
615    print('==OK==')
616except Exception as err:
617    print(err)
618"""
619    p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE,
620                         cwd=path2GSAS2)
621    res,err = MakeByte2str(p.communicate())
622    if '==OK==' not in str(res) or p.returncode != 0:
623        #print('\n'+75*'=')
624        msg = 'Failed when testing the GSAS-II compiled files. GSAS-II will not run'
625        msg += ' without correcting this.\n\nError message:\n'
626        if res: 
627            msg += res
628            msg += '\n'
629        if err:
630            msg += err
631        #print('\nAttempting to open a web page on compiling GSAS-II...')
632        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.)'
633        BailOut(msg)
634        #import webbrowser
635        #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII')
636        #print(75*'=')
637    #    if '86' in platform.machine() and (sys.platform.startswith('linux')
638    #                                        or sys.platform == "darwin"
639    #                                        or sys.platform.startswith('win')):
640    #        print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported')
641    #    else:
642    #        print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported')
643    else:
644        print('Successfully tested compiled routines')
645        GSASIItested = True
646#===========================================================================
647# import all .py files so that .pyc files get created
648if not skipInstallChecks:
649    print('Byte-compiling all .py files...')
650    import compileall
651    compileall.compile_dir(path2GSAS2,quiet=True)
652    print('done')
653#===========================================================================
654# do platform-dependent stuff
655#===========================================================================
656if sys.version_info[0] > 2:
657    def execfile(file):
658        with open(file) as source_file:
659            exec(source_file.read())
660
661#===========================================================================
662# on Windows, make a batch file with Python and GSAS-II location hard-coded
663if skipInstallChecks:
664    pass
665elif sys.platform.startswith('win') and os.path.exists(
666    os.path.join(path2GSAS2,"makeBat.py")):
667    execfile(os.path.join(path2GSAS2,"makeBat.py"))
668#===========================================================================
669# on a Mac, make an applescript
670elif sys.platform.startswith('darwin') and os.path.exists(
671         os.path.join(path2GSAS2,"makeMacApp.py")):
672    sys.argv = [os.path.join(path2GSAS2,"makeMacApp.py")]
673    print(u'running '+sys.argv[0])
674    execfile(sys.argv[0])
675#===========================================================================
676# On linux, make desktop icon
677elif sys.platform.startswith('linux') and os.path.exists(
678         os.path.join(path2GSAS2,"makeLinux.py")):
679    sys.argv = [os.path.join(path2GSAS2,"makeLinux.py")]
680    print(u'running '+sys.argv[0])
681    execfile(sys.argv[0])
682
Note: See TracBrowser for help on using the repository browser.