source: install/bootstrap.py @ 1226

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

change to .xray.aps

File size: 3.5 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    print "We suggest installing the Canopy Express package (must be 32 bit for Mac) at\nhttp://www.enthought.com/store"
20    sys.exit()
21
22gsaspath = os.path.split(sys.argv[0])[0]
23gsaspath = os.path.abspath(os.path.expanduser(gsaspath))
24
25print 'Checking for subversion...',
26# add the standard location for wandisco svn to the path
27for path in os.environ['PATH'].split(':')+['/opt/subversion/bin',]:
28    svn = os.path.join(path,'svn')
29    try:
30        p = subprocess.Popen([svn,'help'],stdout=subprocess.PIPE)
31        res = p.stdout.read()
32        p.communicate()
33        break
34    except:
35        pass
36else:
37    raise Exception('Subversion (svn) not found')
38print ' found svn in',svn
39print 'OK'
40
41print 'GSAS-II is being bootstrapped from repository\n\t',home,'\nto '+gsaspath
42
43print 'Determining system type...',
44if sys.platform.startswith('linux'):
45    #if platform.processor().find('86') <= -1:
46    #    ans = raw_input("Note, GSAS requires an Intel-compatible processor and 32-bit"
47    #                    "libraries.\nAre you sure want to continue? [Yes]/no: ")
48    #    if ans.lower().find('no') > -1: sys.exit()
49    repos = 'linux'
50    print 'Linux, assuming Intel-compatible'
51elif sys.platform == "darwin" and platform.processor() == 'i386':
52    repos = 'osxi86'
53    print 'Mac OS X, Intel-compatible'
54elif sys.platform == "darwin":
55    repos = 'osxppc'
56    print 'Mac OS X, PowerPC -- you will need to run scons on fsource files'
57else:
58    print 'Unidentifed platform -- you may need to run scons on fsource files'
59
60cmds = (
61    ([svn, 'co', home+ 'trunk/', gsaspath],'loading GSAS-II'),
62)
63
64for cmd,msg in cmds: 
65    print 70*'*'
66    print msg + ' from ' + cmd[2]
67    for item in cmd: print item,
68    print ""
69    p = subprocess.call(cmd)
70
71#===========================================================================
72# could try to load .so files here and run scons if needed.
73
74#===========================================================================
75# on a Mac, make an applescript
76if sys.platform.startswith('darwin') and os.path.exists(
77    os.path.join(gsaspath,"makeMacApp.py")):
78    execfile(os.path.join(gsaspath,"makeMacApp.py"))
79#===========================================================================
80# On linux, make desktop icon
81if sys.platform.startswith('linux'):
82    desktop_template = """
83[Desktop Entry]
84Encoding=UTF-8
85Version=1.0
86Type=Application
87Terminal=false
88Exec=xterm -hold -e %s
89Name=GSAS-II
90Icon=%s
91"""
92    loc = '~/Desktop/'
93    eloc = os.path.expanduser(loc)
94    dfile = os.path.join(eloc,'GSASII.desktop')
95    icon = os.path.join(gsaspath, 'gsas2.png')
96    script = os.path.join(gsaspath, 'GSASII.py')
97    os.chmod(script, # make the .py file executable and readable
98             stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
99    if os.path.exists(eloc):
100        open(dfile,'w').write(desktop_template % (script,icon))
101        os.chmod(
102            dfile,
103            stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
104        print("created GNOME desktop shortcut "+dfile) 
Note: See TracBrowser for help on using the repository browser.