/[ascend]/trunk/pygtk/ascend.in
ViewVC logotype

Annotation of /trunk/pygtk/ascend.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2027 - (hide annotations) (download)
Thu Apr 30 08:27:56 2009 UTC (14 years, 10 months ago) by jpye
File size: 5256 byte(s)
Bump version to 0.9.6.
Documented changes since last release in CHANGELOG.txt
1 johnpye 858 #!@PYTHON@
2 jpye 1615 # ^ python path substituted here is not depended-upon in Windows
3 johnpye 440
4 johnpye 1172 import os.path, sys, platform
5 johnpye 440
6 johnpye 1096 restart = 0
7    
8 jpye 1463 # This script handles restarting ascend if it's invoked without the full
9     # complement of env vars. You can override values used by this script
10     # by setting the appropriate env vars before this script is run.
11 johnpye 1096
12 jpye 1463 # Note that as well as env vars, ASCEND is also controllable using the
13     # .ascend.ini file in the user's home directory.
14    
15     #-----------------------------------------------------------------------
16     # Get locations of the installed files. On windows, these are defined in
17     # in the registry. On other systems, these are defined at compile time
18     # by @VARNAME@ substitution.
19    
20 johnpye 1172 if platform.system()=="Windows":
21 jpye 1463 import _winreg as wreg
22     k = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\ASCEND")
23 jpye 1551 print k
24 jpye 1463
25 jpye 2025 # on Windows, we should be able to *assume* relative paths...
26    
27 jpye 1463 # for some reason, QueryValue doesn't work on Py 2.4, need to use QueryValueEx.
28 jpye 1518 INSTALL_SOLVERS,t = wreg.QueryValueEx(k,"INSTALL_SOLVERS")
29     INSTALL_MODELS,t = wreg.QueryValueEx(k,"INSTALL_MODELS")
30 jpye 1463 INSTALL_LIB,t = wreg.QueryValueEx(k,"INSTALL_LIB")
31     INSTALL_ASCDATA,t = wreg.QueryValueEx(k,"INSTALL_ASCDATA")
32     GTKLIBS,t = wreg.QueryValueEx(k,"GTKLIBS");
33 jpye 1518 DEFAULT_ASCENDLIBRARY="%s;%s" % (INSTALL_SOLVERS,INSTALL_MODELS)
34 jpye 1463
35 jpye 2027 INSTALL_PYTHON = os.path.join(INSTALL_ASCDATA,"python")
36 jpye 1463 PYVERSION = "@PYVERSION@"
37 jpye 1551 PYTHON=os.path.join(sys.prefix,"pythonw.exe")
38 jpye 1463
39     print "PYTHON =",PYTHON
40 johnpye 1172 SEP=";"
41 jpye 1463 LDPATHVAR = 'PATH'
42 johnpye 1172 else:
43 jpye 2025
44     # FIXME for possible case of relative paths...
45    
46 jpye 1463 INSTALL_LIB="@INSTALL_LIB@"
47     INSTALL_ASCDATA="@INSTALL_ASCDATA@"
48 jpye 1614 INSTALL_MODELS = os.path.abspath(INSTALL_ASCDATA+"/models")
49     INSTALL_SOLVERS = os.path.abspath(INSTALL_ASCDATA+"/solvers")
50 jpye 2016 INSTALL_PYTHON = "@INSTALL_PYTHON@"
51 jpye 1463 PYTHON="@PYTHON@"
52     DEFAULT_ASCENDLIBRARY="""@DEFAULT_ASCENDLIBRARY@"""
53 johnpye 1172 SEP=":"
54 jpye 1463 LDPATHVAR = 'LD_LIBRARY_PATH'
55     GTKLIBS = None # assume the GTK will be in the standard library path
56 johnpye 1172
57 jpye 1463 #-----------------------------------------------------------------------
58    
59     if os.environ.get(LDPATHVAR):
60     LDPATH = os.environ.get(LDPATHVAR).split(SEP)
61 jpye 1365 else:
62 jpye 1463 LDPATH = []
63 jpye 1365
64 johnpye 1097 if not os.environ.get('ASC_GDB'):
65     # restarting messes up GDB so don't allow it
66 johnpye 1096
67 jpye 1463 if platform.system()=="Windows":
68     # Put INSTALL_LIB then GTK at start of path
69     if GTKLIBS in LDPATH:
70     LDPATH.remove(GTKLIBS)
71     LDPATH=[INSTALL_LIB,GTKLIBS]+LDPATH
72     os.environ[LDPATHVAR] = SEP.join(LDPATH)
73     restart = 1
74     elif INSTALL_LIB != "/usr/lib" and not INSTALL_LIB in LDPATH:
75     # don't worry about GTK location; just ensure that LDPATH includes INSTALL_LIB
76     LDPATH = [INSTALL_LIB] + LDPATH
77     os.environ[LDPATHVAR] = SEP.join(LDPATH)
78     restart = 1
79 johnpye 1096
80 jpye 1615 # if ASCENDLIBRARY has been specified, make sure it's including the Model Library
81 johnpye 1172 if os.environ.get('ASCENDLIBRARY'):
82     envmodels = [os.path.abspath(i) for i in os.environ['ASCENDLIBRARY'].split(SEP)]
83 jpye 1614 if not INSTALL_MODELS in envmodels:
84     envmodels.append(INSTALL_MODELS)
85 johnpye 1172 os.environ['ASCENDLIBRARY'] = SEP.join(envmodels)
86     restart = 1
87 jpye 1615
88     # if ASCENDSOLVERS has been specified, make sure it includes the standard solvers
89 jpye 1614 if os.environ.get('ASCENDSOLVERS'):
90     envsolvers = [os.path.abspath(i) for i in os.environ['ASCENDSOLVERS'].split(SEP)]
91     if not INSTALL_SOLVERS in envsolvers:
92     envsolvers.append(INSTALL_SOLVERS)
93     os.environ['ASCENDSOLVERS'] = SEP.join(envsolvers)
94 jpye 1504 restart = 1
95 johnpye 1172
96 jpye 1615 # don't need to restart process on Windows as env vars update immediately
97     if restart and platform.system()!="Windows":
98 johnpye 1097 print "Restarting with corrected environment..."
99 jpye 1616 if os.environ.get(LDPATHVAR):
100     print " %s = %s" % (LDPATHVAR,os.environ.get(LDPATHVAR))
101     if os.environ.get('ASCENDLIBRARY'):
102     print " ASCENDLIBRARY = %s" % os.environ.get('ASCENDLIBRARY')
103     if os.environ.get('ASCENDSOLVERS'):
104     print " ASCENDSOLVERS = %s" % os.environ.get('ASCENDSOLVERS')
105 johnpye 1097 script = os.path.join(sys.path[0],"ascend")
106 jpye 1463 print "PYTHON =",PYTHON
107     print "script =",script
108 jpye 1615 os.execve(PYTHON,[script] + sys.argv, os.environ)
109 johnpye 1096
110     print "Running with..."
111 jpye 1463 print " %s = %s" % (LDPATHVAR, os.environ.get(LDPATHVAR))
112 jpye 1467 print " sys.path = %s" % sys.path
113 johnpye 1097 print " argv = %s" % sys.argv
114 johnpye 1096
115 johnpye 858 if os.environ.get('ASCENDLIBRARY'):
116     ASCENDLIBRARY = os.environ.get('ASCENDLIBRARY')
117 jpye 1615 print " ASCENDLIBRARY = %s" % ASCENDLIBRARY
118 johnpye 440
119 jpye 1615 if os.environ.get('ASCENDSOLVERS'):
120     ASCENDSOLVERS = os.environ.get('ASCENDSOLVERS')
121     print " ASCENDSOLVERS = %s" % ASCENDLIBRARY
122    
123 johnpye 1096 print "sys.path[0] = %s" % sys.path[0]
124 johnpye 440
125 jpye 1463 if not INSTALL_ASCDATA in sys.path:
126 jpye 2027 print "Adding INSTALL_PYTHON to python path"
127     sys.path.append(INSTALL_PYTHON)
128 johnpye 1096
129 jpye 2016 if not INSTALL_PYTHON in sys.path:
130     print "Adding INSTALL_PYTHON=%s to python path" % INSTALL_PYTHON
131     sys.path.append(INSTALL_PYTHON)
132    
133 johnpye 858 if os.environ.get('OSTYPE')=='cygwin':
134     print "CYGWIN..."
135     elif os.environ.get('OSTYPE')=='msys':
136     print "MSYS..."
137 johnpye 440
138 jpye 1358 if os.environ.get('ASC_GDB'):
139     args = sys.argv
140     args.pop(0)
141 jpye 1463 cmd = ["gdb","--args","python",os.path.join(INSTALL_ASCDATA,"gtkbrowser.py")]+args
142 jpye 1358 print cmd
143     os.execv("/usr/bin/gdb",cmd)
144 johnpye 858 else:
145 jpye 1358 import ascpy
146 jpye 1463 olddir = os.getcwd()
147     os.chdir(INSTALL_ASCDATA)
148 jpye 1358 from gtkbrowser import *
149 jpye 1463 os.chdir(olddir)
150 jpye 1616 B = Browser(
151     librarypath=os.environ.get('ASCENDLIBRARY')
152     ,assetspath=os.path.join(INSTALL_ASCDATA,"glade")
153     )
154 jpye 1358 B.run()

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22