source: install/bootstrap.py @ 1532

Last change on this file since 1532 was 1532, checked in by toby, 7 years ago

allow bootstrap to work with old svn, as in 10.5

File size: 3.9 KB
Line 
1#!/usr/bin/env python
2import os, stat, sys, platform, subprocess
3home = 'https://subversion.xray.aps.anl.gov/pyGSAS/'
4print 70*'*'
5print 'Checking python packages...',
6missing = []
7for pkg in ['numpy','scipy','matplotlib','wx']:
8    try:
9        exec('import '+pkg)
10    except:
11        missing.append(pkg)
12
13if missing:
14    print """Sorry, this version of Python cannot be used
15for GSAS-II. It is missing the following package(s):
16\t""",
17    for pkg in missing: print " ",pkg,
18    print 
19    if sys.platform.startswith('darwin'):
20        print "We suggest installing the EPD Free Python package (epd_free-7.3-2-macosx-i386.dmg)\nat https://www.enthought.com/repo/free/\nor the 64-bit Canopy Express package at http://www.enthought.com/downloads"
21    else:
22        print "We suggest installing the Canopy Express package at http://www.enthought.com/downloads"
23    sys.exit()
24
25gsaspath = os.path.split(sys.argv[0])[0]
26gsaspath = os.path.abspath(os.path.expanduser(gsaspath))
27
28print 'Checking for subversion...',
29# add the standard location for wandisco svn to the path
30for path in os.environ['PATH'].split(':')+['/opt/subversion/bin',]:
31    svn = os.path.join(path,'svn')
32    try:
33        p = subprocess.Popen([svn,'help'],stdout=subprocess.PIPE)
34        res = p.stdout.read()
35        p.communicate()
36        break
37    except:
38        pass
39else:
40    raise Exception('Subversion (svn) not found')
41print ' found svn in',svn
42print 'OK'
43
44print 'GSAS-II is being bootstrapped from repository\n\t',home,'\nto '+gsaspath
45
46print 'Determining system type...',
47if sys.platform.startswith('linux'):
48    #if platform.processor().find('86') <= -1:
49    #    ans = raw_input("Note, GSAS requires an Intel-compatible processor and 32-bit"
50    #                    "libraries.\nAre you sure want to continue? [Yes]/no: ")
51    #    if ans.lower().find('no') > -1: sys.exit()
52    repos = 'linux'
53    print 'Linux, assuming Intel-compatible'
54elif sys.platform == "darwin" and platform.processor() == 'i386':
55    repos = 'osxi86'
56    print 'Mac OS X, Intel-compatible'
57elif sys.platform == "darwin":
58    repos = 'osxppc'
59    print 'Mac OS X, PowerPC -- you will need to run scons on fsource files'
60else:
61    print 'Unidentifed platform -- you may need to run scons on fsource files'
62
63cmd = [svn, 'co', home+ 'trunk/', gsaspath, '--non-interactive', '--trust-server-cert']
64msg = 'loading GSAS-II'
65   
66print 70*'*'
67print msg + ' from ' + cmd[2]
68for item in cmd: print item,
69print ""
70p = subprocess.call(cmd)
71if p:
72    print 'subversion returned an error; Retrying...'
73    cmd = [svn, 'co', home+ 'trunk/', gsaspath]
74    p = subprocess.call(cmd)
75
76#===========================================================================
77# could try to load .so files here and run scons if needed.
78
79#===========================================================================
80# on a Mac, make an applescript
81if sys.platform.startswith('darwin') and os.path.exists(
82    os.path.join(gsaspath,"makeMacApp.py")):
83    execfile(os.path.join(gsaspath,"makeMacApp.py"))
84#===========================================================================
85# On linux, make desktop icon
86if sys.platform.startswith('linux'):
87    desktop_template = """
88[Desktop Entry]
89Encoding=UTF-8
90Version=1.0
91Type=Application
92Terminal=false
93Exec=xterm -hold -e %s
94Name=GSAS-II
95Icon=%s
96"""
97    loc = '~/Desktop/'
98    eloc = os.path.expanduser(loc)
99    dfile = os.path.join(eloc,'GSASII.desktop')
100    icon = os.path.join(gsaspath, 'gsas2.png')
101    script = os.path.join(gsaspath, 'GSASII.py')
102    os.chmod(script, # make the .py file executable and readable
103             stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
104    if os.path.exists(eloc):
105        open(dfile,'w').write(desktop_template % (script,icon))
106        os.chmod(
107            dfile,
108            stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
109        print("created GNOME desktop shortcut "+dfile) 
Note: See TracBrowser for help on using the repository browser.