Changeset 3201


Ignore:
Timestamp:
Dec 22, 2017 7:11:41 PM (4 years ago)
Author:
toby
Message:

update bootstrap for Py3

Location:
install
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • install/bootstrap.py

    r3107 r3201  
    8181    out,err = s.communicate()
    8282    if err:
    83         print 'subversion error!\nout=',out
    84         print 'err=',err
     83        print('subversion error!\nout= '+out)
     84        print('err= '+err)
    8585        return None
    8686    return out.strip()
     
    100100################################################################################
    101101################################################################################
    102 print 70*'*'
     102print(70*'*')
    103103#testing for incorrect locale code'
    104104try:
     
    106106    locale.getdefaultlocale()
    107107except ValueError:
    108     print 'Your location is not set properly. This causes problems for matplotlib'
    109     print '  (see https://github.com/matplotlib/matplotlib/issues/5420.)'
    110     print 'Will try to bypass problem by setting LC_ALL to en_US.UTF-8 (US English)'
     108    print('Your location is not set properly. This causes problems for matplotlib')
     109    print('  (see https://github.com/matplotlib/matplotlib/issues/5420.)')
     110    print('Will try to bypass problem by setting LC_ALL to en_US.UTF-8 (US English)')
    111111    os.environ['LC_ALL'] = 'en_US.UTF-8'
    112112    locale.getdefaultlocale()
    113 print 'Preloading matplotlib to build fonts...'
     113print('Preloading matplotlib to build fonts...')
    114114try:
    115115    import matplotlib
    116116except:
    117117    pass
    118 print 'Checking python packages...',
     118print('Checking python packages...')
    119119missing = []
    120120for pkg in ['numpy','scipy','matplotlib','wx',]:
     
    125125
    126126if missing:
    127     print """Sorry, this version of Python cannot be used
     127    msg = """Sorry, this version of Python cannot be used
    128128for GSAS-II. It is missing the following package(s):
    129 \t""",
    130     for pkg in missing: print " ",pkg,
    131     print "\nPlease install these package(s) and try running this again."
    132     print "Showing first error: "
     129\t"""
     130    for pkg in missing: msg += " "+pkg
     131    print(msg)
     132    print("\nPlease install these package(s) and try running this again.")
     133    print("Showing first error: ")
    133134    for pkg in ['numpy','scipy','matplotlib','wx',]:
    134135        exec('import '+pkg)
     
    141142            from setuptools.command import easy_install                 
    142143    except ImportError:
    143         print 'You are missing the OpenGL Python package. This can be '
    144         print 'installed by this script if the setuptools package is installed'
    145         print 'Please install either OpenGL (pyopengl) or setuptools'
    146         print "package and try running this again."
     144        print('You are missing the OpenGL Python package. This can be ')
     145        print('installed by this script if the setuptools package is installed')
     146        print('Please install either OpenGL (pyopengl) or setuptools')
     147        print("package and try running this again.")
    147148        sys.exit()
    148     print "Missing the OpenGL Python package. Will attempt to install this later."
     149    print("Missing the OpenGL Python package. Will attempt to install this later.")
    149150    def install_with_easyinstall(package):               
    150151        try:             
    151             print "trying system-wide ",                 
     152            print("trying system-wide ")                 
    152153            easy_install.main(['-f',os.path.split(__file__)[0],package])                 
    153154            return               
     
    155156            pass                 
    156157        try:             
    157             print "trying user level ",                  
     158            print("trying user level ")                 
    158159            easy_install.main(['-f',os.path.split(__file__)[0],'--user',package])               
    159160            return               
    160161        except:                 
    161             print "\nInstall of "+package+" failed. Error traceback follows:"           
     162            print("\nInstall of "+package+" failed. Error traceback follows:")
    162163            import traceback             
    163             print traceback.format_exc()                 
     164            print(traceback.format_exc())
    164165            sys.exit()
    165166
    166 print '\nChecking for subversion...',
     167print('\nChecking for subversion...')
    167168svn = whichsvn()
    168169if not svn:
    169     print "Sorry, subversion (svn) could not be found on your system."
    170     print "Please install this or place in path and rerun this."
     170    print("Sorry, subversion (svn) could not be found on your system.")
     171    print("Please install this or place in path and rerun this.")
    171172    #raise Exception('Subversion (svn) not found')
    172173    sys.exit()
    173 print ' found svn image: '+svn
     174print(' found svn image: '+svn)
    174175
    175176if install_with_easyinstall:             
    176     print '\nInstalling PyOpenGL. Lots of warnings will follow... ',             
     177    print('\nInstalling PyOpenGL. Lots of warnings will follow... ')
    177178    install_with_easyinstall('PyOpenGl')                 
    178     print 'done.'
     179    print('done.')
    179180   
    180 print 'Ready to bootstrap GSAS-II from repository\n\t',g2home,'\nto '+path2GSAS2
     181print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2)
    181182proxycmds = []
    182183proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt")
     
    190191    os.remove(proxyinfo)
    191192print(70*"=")
     193if sys.version_info[0] == 2:
     194    getinput = raw_input
     195else:
     196    getinput = input
    192197if host:
    193     ans = raw_input("Enter the proxy address (type none to remove) ["+host+"]: ")
     198    ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ")
    194199    if ans.strip().lower() == "none": host = ans = ""
    195200else:
    196     ans = raw_input("Enter the proxy address [none needed]: ")
     201    ans = getinput("Enter the proxy address [none needed]: ")
    197202if ans.strip() != "" or host:
    198203    proxycmds.append('--config-option')
     
    201206    fp = open(proxyinfo,'w')
    202207    fp.write(ans.strip()+'\n')
    203     ans = raw_input("Enter the proxy port ["+port+"]: ")
     208    ans = getinput("Enter the proxy port ["+port+"]: ")
    204209    if ans.strip() == "": ans=port
    205210    proxycmds.append('--config-option')
     
    212217p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    213218res,err = p.communicate()
    214 if '.xor.' in res:
     219if '.xor.' in str(res):
    215220    print('Switching previous install with .xor. download location to\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')
    216221    cmd = [svn, 'switch','--relocate','https://subversion.xor.aps.anl.gov/pyGSAS',
     
    224229        print(res)
    225230# patch: switch GSAS-II location if switched to 2frame version (removed August 2017)
    226 if '2frame' in res:
     231if '2frame' in str(res):
    227232    print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')
    228233    cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2,
     
    242247print('\n'+75*'*')
    243248print(msg + u' from ' + cmd[2])
    244 print 'svn load command:'
    245 for item in cmd: print item,
    246 print ""
     249msg = 'svn load command: '
     250for item in cmd: msg += " "+item
     251print(msg)
    247252s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    248253print('\nsubversion output:')
     
    257262    cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2]
    258263    if proxycmds: cmd += proxycmds
    259     for item in cmd: print item,
    260     print ""
     264    msg = ""
     265    for item in cmd: msg += item
     266    print(msg)
    261267    s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    262268    out,err = s.communicate()
     
    313319                     cwd=path2GSAS2)
    314320res,err = p.communicate()
    315 if '==OK==' not in res or p.returncode != 0:
     321if '==OK==' not in str(res) or p.returncode != 0:
    316322    print('\n'+75*'=')
    317323    print('Failed when testing the GSAS-II compiled files. GSAS-II will not run')
    318     print('without correcting this.')
     324    print('without correcting this.\n\nError message:')
    319325    #print(res)
    320     #print(err)
     326    print(err)
    321327    #print('\nAttempting to open a web page on compiling GSAS-II...')
    322328    print('Please see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII')
     
    324330    #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII')
    325331    print(75*'=')
    326     if '86' in platform.machine() and (sys.platform.startswith('linux')
    327                                         or sys.platform == "darwin"
    328                                         or sys.platform.startswith('win')):
    329         print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported')
    330     else:
    331         print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported')
     332#    if '86' in platform.machine() and (sys.platform.startswith('linux')
     333#                                        or sys.platform == "darwin"
     334#                                        or sys.platform.startswith('win')):
     335#        print('Platform '+sys.platform+' with processor type '+platform.machine()+' is supported')
     336#    else:
     337#        print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported')
    332338    sys.exit()
    333339else:
    334     print 'Successfully tested compiled routines'
     340    print('Successfully tested compiled routines')
    335341#===========================================================================
    336342# import all .py files so that .pyc files get created
    337 print 'Byte-compiling all .py files...',
     343print('Byte-compiling all .py files...')
    338344import compileall
    339345compileall.compile_dir(path2GSAS2,quiet=True)
    340 print 'done'
     346print('done')
    341347#===========================================================================
    342348# platform-dependent stuff
    343349#===========================================================================
     350if sys.version_info[0] > 2:
     351    def execfile(file):
     352        with open(file) as source_file:
     353            exec(source_file.read())
    344354# on Windows, make a batch file with Python and GSAS-II location hard-coded
    345355if sys.platform.startswith('win') and os.path.exists(
     
    355365#===========================================================================
    356366# On linux, make desktop icon
    357 elif sys.platform.startswith('linux'):
    358     desktop_template = """
    359 [Desktop Entry]
    360 Version=1.0
    361 Type=Application
    362 Terminal=false
    363 Exec=xterm -hold -e bash -c "{} {}"
    364 Name=GSAS-II
    365 Icon={}
    366 Categories=Science;
    367 """
    368     loc = os.path.expanduser('~/Desktop/')
    369     if "XDG_DATA_HOME" in os.environ and os.path.exists(os.path.join(os.environ.get("XDG_DATA_HOME"),"applications")):
    370         loc = os.path.join(os.environ.get("XDG_DATA_HOME"),"applications")
    371     elif "HOME" in os.environ and os.path.exists(os.path.join(os.environ.get("HOME"),".local/share/applications")):
    372         loc = os.path.join(os.environ.get("HOME"),".local/share/applications")
    373     elif not os.path.exists(loc):
    374         loc = os.path.expanduser('~/')
    375     dfile = os.path.join(loc,'GSASII.desktop')
    376     icon = os.path.join(path2GSAS2, 'gsas2.png')
    377     script = os.path.join(path2GSAS2, 'GSASII.py')
    378     os.chmod(script, # make the .py file executable and readable
    379              stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
    380     try:
    381         open(dfile,'w').write(desktop_template.format(sys.executable,script,icon))
    382         os.chmod(
    383             dfile,
    384             stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
    385         print("created GNOME/KDE desktop shortcut "+dfile)
    386     except:
    387         print("creation of file failed: "+dfile)
    388 
     367elif sys.platform.startswith('linux') and os.path.exists(
     368    os.path.join(path2GSAS2,"makeLinux.py")):
     369    sys.argv = [os.path.join(path2GSAS2,"makeLinux.py")]
     370    print(u'running '+sys.argv[0])
     371    execfile(sys.argv[0])
     372
  • install/g2conda/construct.yaml

    r2855 r3201  
    11name: g2conda
    22version: 0.1.2
    3 
     3#conda install numpy scipy matplotlib pillow h5py pyopengl pywin32 svn wxpython m2w64-gcc-libgfortran
    44install_in_dependency_order: True
    55
  • install/g2pkg/meta.yaml

    r2855 r3201  
    11package:
    22  name: g2load
    3   version: 0.1.8  # remember to change in g2conda/construct.yaml to match this
     3  version: 0.2.0  # remember to change in g2conda/construct.yaml to match this
    44
    55source:
Note: See TracChangeset for help on using the changeset viewer.