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

Contents of /trunk/pygtk/ascend.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1551 - (show annotations) (download)
Tue Jul 24 07:29:42 2007 UTC (12 years, 7 months ago) by jpye
File size: 4325 byte(s)
Adding some windows target files to ignore list.
Fixing build on Windows with Python 2.5 library.
Fixing for NSIS not present.
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 # for some reason, QueryValue doesn't work on Py 2.4, need to use QueryValueEx.
26 INSTALL_SOLVERS,t = wreg.QueryValueEx(k,"INSTALL_SOLVERS")
27 INSTALL_MODELS,t = wreg.QueryValueEx(k,"INSTALL_MODELS")
28 INSTALL_LIB,t = wreg.QueryValueEx(k,"INSTALL_LIB")
29 INSTALL_ASCDATA,t = wreg.QueryValueEx(k,"INSTALL_ASCDATA")
30 GTKLIBS,t = wreg.QueryValueEx(k,"GTKLIBS");
31 DEFAULT_ASCENDLIBRARY="%s;%s" % (INSTALL_SOLVERS,INSTALL_MODELS)
32
33 PYVERSION = "@PYVERSION@"
34
35 PYTHON=os.path.join(sys.prefix,"pythonw.exe")
36
37 print "PYTHON =",PYTHON
38 SEP=";"
39 LDPATHVAR = 'PATH'
40 else:
41 INSTALL_LIB="@INSTALL_LIB@"
42 INSTALL_ASCDATA="@INSTALL_ASCDATA@"
43 PYTHON="@PYTHON@"
44 DEFAULT_ASCENDLIBRARY="""@DEFAULT_ASCENDLIBRARY@"""
45 SEP=":"
46 LDPATHVAR = 'LD_LIBRARY_PATH'
47 GTKLIBS = None # assume the GTK will be in the standard library path
48
49 #-----------------------------------------------------------------------
50
51 if os.environ.get(LDPATHVAR):
52 LDPATH = os.environ.get(LDPATHVAR).split(SEP)
53 else:
54 LDPATH = []
55
56 if not os.environ.get('ASC_GDB'):
57 # restarting messes up GDB so don't allow it
58
59 if platform.system()=="Windows":
60 # Put INSTALL_LIB then GTK at start of path
61 if GTKLIBS in LDPATH:
62 LDPATH.remove(GTKLIBS)
63 LDPATH=[INSTALL_LIB,GTKLIBS]+LDPATH
64 os.environ[LDPATHVAR] = SEP.join(LDPATH)
65 restart = 1
66
67 elif INSTALL_LIB != "/usr/lib" and not INSTALL_LIB in LDPATH:
68 # don't worry about GTK location; just ensure that LDPATH includes INSTALL_LIB
69 LDPATH = [INSTALL_LIB] + LDPATH
70 os.environ[LDPATHVAR] = SEP.join(LDPATH)
71 restart = 1
72
73 if os.environ.get('ASCENDLIBRARY'):
74 envmodels = [os.path.abspath(i) for i in os.environ['ASCENDLIBRARY'].split(SEP)]
75 ascmodels = os.path.abspath(INSTALL_ASCDATA+"/models")
76 ascsolvers = os.path.abspath(INSTALL_ASCDATA+"/solvers")
77 if not ascmodels in envmodels:
78 envmodels.append(ascmodels)
79 os.environ['ASCENDLIBRARY'] = SEP.join(envmodels)
80 restart = 1
81 if not ascsolvers in envmodels:
82 envmodels.append(ascsolvers)
83 os.environ['ASCENDLIBRARY'] = SEP.join(envmodels)
84 restart = 1
85
86 if restart:
87 print "Restarting with corrected environment..."
88 print " %s = %s" % (LDPATHVAR,os.environ.get(LDPATHVAR))
89 print " ASCENDLIBRARY = %s" % os.environ.get('ASCENDLIBRARY')
90 script = os.path.join(sys.path[0],"ascend")
91 print "PYTHON =",PYTHON
92 print "script =",script
93 if platform.system()=="Windows":
94 print "DROPPING THROUGH"
95 else:
96 os.execve(PYTHON,[script] + sys.argv, os.environ)
97
98
99 print "Running with..."
100 print " %s = %s" % (LDPATHVAR, os.environ.get(LDPATHVAR))
101 print " sys.path = %s" % sys.path
102 print " argv = %s" % sys.argv
103
104 if os.environ.get('ASCENDLIBRARY'):
105 ASCENDLIBRARY = os.environ.get('ASCENDLIBRARY')
106 print "USING ASCENDLIBRARY=%s" % ASCENDLIBRARY
107 else:
108 ASCENDLIBRARY = DEFAULT_ASCENDLIBRARY
109 print "default ASCENDLIBRARY=%s" % ASCENDLIBRARY
110
111 print "sys.path[0] = %s" % sys.path[0]
112
113 if not INSTALL_ASCDATA in sys.path:
114 print "Adding INSTALL_ASCDATA to python path?"
115 sys.path.append(INSTALL_ASCDATA)
116
117 if os.environ.get('OSTYPE')=='cygwin':
118 print "CYGWIN..."
119 elif os.environ.get('OSTYPE')=='msys':
120 print "MSYS..."
121
122 if os.environ.get('ASC_GDB'):
123 args = sys.argv
124 args.pop(0)
125 cmd = ["gdb","--args","python",os.path.join(INSTALL_ASCDATA,"gtkbrowser.py")]+args
126 print cmd
127 os.execv("/usr/bin/gdb",cmd)
128 else:
129 import ascpy
130 olddir = os.getcwd()
131 os.chdir(INSTALL_ASCDATA)
132 from gtkbrowser import *
133 os.chdir(olddir)
134 B = Browser(librarypath=ASCENDLIBRARY,assetspath=os.path.join(INSTALL_ASCDATA,"glade"))
135 B.run()

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