source: install/g2pkg/src/bootstrap.py @ 4739

Last change on this file since 4739 was 4732, checked in by toby, 3 years ago

workarounds for missing files

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