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

Contents of /trunk/pygtk/ascdev.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1535 - (show annotations) (download)
Mon Jul 9 14:58:15 2007 UTC (16 years, 10 months ago) by jpye
File size: 2585 byte(s)
Little more on IPOPT. Fixed ascdev script to work with configured
solver list.
1 #!@PYTHON@
2 # to debug this program using 'gdb', invoke 'ASC_GDB=1 ascdev'.
3
4 import os.path, sys, platform;
5
6 def add_at_start(envvar,pathcomponents):
7 """ add path components at start of envvar, return 1 if changes made """
8
9 if not os.environ.get(envvar):
10 v = SEP.join(pathcomponents)
11 os.environ[envvar]=v
12 return 1
13
14 restart = 0
15 pathcomponents = [os.path.abspath(i) for i in pathcomponents]
16 envvals = [os.path.abspath(i) for i in os.environ[envvar].split(SEP)]
17 for k in range(0,len(pathcomponents)):
18 p = pathcomponents[k]
19 if p in envvals[k+1:]:
20 envvals.remove(p)
21 restart = 1
22 for p in [pathcomponents[i] for i in range(len(pathcomponents))[::-1]]:
23 if p not in envvals:
24 envvals.insert(0,p)
25 restart = 1
26 os.environ[envvar]=SEP.join(envvals)
27 return restart
28
29 if __name__=='__main__':
30 sourceroot="@SOURCE_ROOT@"
31 script=os.path.join(sys.argv[0])
32
33 if platform.system()=="Windows":
34 LD_LIBRARY_PATH="PATH"
35 SEP = ";"
36 else:
37 LD_LIBRARY_PATH="LD_LIBRARY_PATH"
38 SEP = ":"
39
40 restart = []
41
42 # ensure that we have our 'models' dir in the ASCENDLIBRARY path
43 modeldirs = [os.path.join(sourceroot,"models")]
44 if add_at_start('ASCENDLIBRARY',modeldirs):
45 restart.append('ASCENDLIBRARY')
46
47 solverdir = os.path.join(sourceroot,"solvers")
48 solverdirs = [os.path.join(solverdir,d.lower()) for d in "@WITH_SOLVERS@".split(",")]
49 if add_at_start('ASCENDSOLVERS',solverdirs):
50 restart.append('ASCENDSOLVERS')
51
52 # ensure that we have our shared libraries in the LD_LIBRARY_PATH
53 libdirs = [sourceroot,os.path.join(sourceroot,"pygtk")]
54 if add_at_start(LD_LIBRARY_PATH,libdirs):
55 restart.append(LD_LIBRARY_PATH)
56
57 # ensure our pygtk dir is in the PYTHONPATH
58 pypath = [os.path.join(sourceroot,"pygtk")]
59 if add_at_start('PYTHONPATH',pypath):
60 restart.append('PYTHONPATH')
61
62 if restart:
63 print "\nRestarting with..."
64 for v in restart:
65 print " export %s=%s" % (v,os.environ[v])
66 if os.environ.get('ASC_GDB'):
67 print " via GDB..."
68 os.execvp("gdb",['--symbols=../@SHLIBPREFIX@ascend@SHLIBSUFFIX@','--args','python',script]+sys.argv[1:])
69 else:
70 print "PYTHON... ",script
71 sys.stdout.flush() # needed for rxvt on Windows
72 os.execvp("python",[script,script]+sys.argv[1:])
73 # the above calls don't return so we can forget about line of enqiry
74
75
76 print "\nRunning with..."
77 for v in [LD_LIBRARY_PATH,'ASCENDLIBRARY','PYTHONPATH']:
78 print " %s = %s" % (v,os.environ[v])
79
80 import ascpy
81 from gtkbrowser import *
82 assetspath =os.path.join(sourceroot,"pygtk","glade")
83 print "ASSETS PATH = %s" % assetspath
84 B = Browser(assetspath=assetspath)
85 B.run()

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