source: install/bootstrap.py @ 1358

Last change on this file since 1358 was 1358, checked in by toby, 8 years ago

update bootstrap: no verification, new msg

File size: 3.8 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
63cmds = (
64    ([svn, 'co', home+ 'trunk/', gsaspath, '--non-interactive', '--trust-server-cert'],'loading GSAS-II'),
65)
66
67for cmd,msg in cmds: 
68    print 70*'*'
69    print msg + ' from ' + cmd[2]
70    for item in cmd: print item,
71    print ""
72    p = subprocess.call(cmd)
73
74#===========================================================================
75# could try to load .so files here and run scons if needed.
76
77#===========================================================================
78# on a Mac, make an applescript
79if sys.platform.startswith('darwin') and os.path.exists(
80    os.path.join(gsaspath,"makeMacApp.py")):
81    execfile(os.path.join(gsaspath,"makeMacApp.py"))
82#===========================================================================
83# On linux, make desktop icon
84if sys.platform.startswith('linux'):
85    desktop_template = """
86[Desktop Entry]
87Encoding=UTF-8
88Version=1.0
89Type=Application
90Terminal=false
91Exec=xterm -hold -e %s
92Name=GSAS-II
93Icon=%s
94"""
95    loc = '~/Desktop/'
96    eloc = os.path.expanduser(loc)
97    dfile = os.path.join(eloc,'GSASII.desktop')
98    icon = os.path.join(gsaspath, 'gsas2.png')
99    script = os.path.join(gsaspath, 'GSASII.py')
100    os.chmod(script, # make the .py file executable and readable
101             stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
102    if os.path.exists(eloc):
103        open(dfile,'w').write(desktop_template % (script,icon))
104        os.chmod(
105            dfile,
106            stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
107        print("created GNOME desktop shortcut "+dfile) 
Note: See TracBrowser for help on using the repository browser.