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

Contents of /trunk/pygtk/ascend.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2027 - (show annotations) (download)
Thu Apr 30 08:27:56 2009 UTC (14 years, 7 months ago) by jpye
File size: 5256 byte(s)
Bump version to 0.9.6.
Documented changes since last release in CHANGELOG.txt
1 #!@PYTHON@
2 # ^ python path substituted here is not depended-upon in Windows
3
4 import os.path, sys, platform
5
6 restart = 0
7
8 # 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
12 # 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 if platform.system()=="Windows":
21 import _winreg as wreg
22 k = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\ASCEND")
23 print k
24
25 # on Windows, we should be able to *assume* relative paths...
26
27 # for some reason, QueryValue doesn't work on Py 2.4, need to use QueryValueEx.
28 INSTALL_SOLVERS,t = wreg.QueryValueEx(k,"INSTALL_SOLVERS")
29 INSTALL_MODELS,t = wreg.QueryValueEx(k,"INSTALL_MODELS")
30 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 DEFAULT_ASCENDLIBRARY="%s;%s" % (INSTALL_SOLVERS,INSTALL_MODELS)
34
35 INSTALL_PYTHON = os.path.join(INSTALL_ASCDATA,"python")
36 PYVERSION = "@PYVERSION@"
37 PYTHON=os.path.join(sys.prefix,"pythonw.exe")
38
39 print "PYTHON =",PYTHON
40 SEP=";"
41 LDPATHVAR = 'PATH'
42 else:
43
44 # FIXME for possible case of relative paths...
45
46 INSTALL_LIB="@INSTALL_LIB@"
47 INSTALL_ASCDATA="@INSTALL_ASCDATA@"
48 INSTALL_MODELS = os.path.abspath(INSTALL_ASCDATA+"/models")
49 INSTALL_SOLVERS = os.path.abspath(INSTALL_ASCDATA+"/solvers")
50 INSTALL_PYTHON = "@INSTALL_PYTHON@"
51 PYTHON="@PYTHON@"
52 DEFAULT_ASCENDLIBRARY="""@DEFAULT_ASCENDLIBRARY@"""
53 SEP=":"
54 LDPATHVAR = 'LD_LIBRARY_PATH'
55 GTKLIBS = None # assume the GTK will be in the standard library path
56
57 #-----------------------------------------------------------------------
58
59 if os.environ.get(LDPATHVAR):
60 LDPATH = os.environ.get(LDPATHVAR).split(SEP)
61 else:
62 LDPATH = []
63
64 if not os.environ.get('ASC_GDB'):
65 # restarting messes up GDB so don't allow it
66
67 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
80 # if ASCENDLIBRARY has been specified, make sure it's including the Model Library
81 if os.environ.get('ASCENDLIBRARY'):
82 envmodels = [os.path.abspath(i) for i in os.environ['ASCENDLIBRARY'].split(SEP)]
83 if not INSTALL_MODELS in envmodels:
84 envmodels.append(INSTALL_MODELS)
85 os.environ['ASCENDLIBRARY'] = SEP.join(envmodels)
86 restart = 1
87
88 # if ASCENDSOLVERS has been specified, make sure it includes the standard solvers
89 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 restart = 1
95
96 # don't need to restart process on Windows as env vars update immediately
97 if restart and platform.system()!="Windows":
98 print "Restarting with corrected environment..."
99 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 script = os.path.join(sys.path[0],"ascend")
106 print "PYTHON =",PYTHON
107 print "script =",script
108 os.execve(PYTHON,[script] + sys.argv, os.environ)
109
110 print "Running with..."
111 print " %s = %s" % (LDPATHVAR, os.environ.get(LDPATHVAR))
112 print " sys.path = %s" % sys.path
113 print " argv = %s" % sys.argv
114
115 if os.environ.get('ASCENDLIBRARY'):
116 ASCENDLIBRARY = os.environ.get('ASCENDLIBRARY')
117 print " ASCENDLIBRARY = %s" % ASCENDLIBRARY
118
119 if os.environ.get('ASCENDSOLVERS'):
120 ASCENDSOLVERS = os.environ.get('ASCENDSOLVERS')
121 print " ASCENDSOLVERS = %s" % ASCENDLIBRARY
122
123 print "sys.path[0] = %s" % sys.path[0]
124
125 if not INSTALL_ASCDATA in sys.path:
126 print "Adding INSTALL_PYTHON to python path"
127 sys.path.append(INSTALL_PYTHON)
128
129 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 if os.environ.get('OSTYPE')=='cygwin':
134 print "CYGWIN..."
135 elif os.environ.get('OSTYPE')=='msys':
136 print "MSYS..."
137
138 if os.environ.get('ASC_GDB'):
139 args = sys.argv
140 args.pop(0)
141 cmd = ["gdb","--args","python",os.path.join(INSTALL_ASCDATA,"gtkbrowser.py")]+args
142 print cmd
143 os.execv("/usr/bin/gdb",cmd)
144 else:
145 import ascpy
146 olddir = os.getcwd()
147 os.chdir(INSTALL_ASCDATA)
148 from gtkbrowser import *
149 os.chdir(olddir)
150 B = Browser(
151 librarypath=os.environ.get('ASCENDLIBRARY')
152 ,assetspath=os.path.join(INSTALL_ASCDATA,"glade")
153 )
154 B.run()

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