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

Contents of /trunk/pygtk/ascdev.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2144 - (show annotations) (download)
Wed Dec 23 13:04:19 2009 UTC (14 years, 5 months ago) by jpye
File size: 2830 byte(s)
More on mac issues.
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 elif platform.system()=="Darwin":
37 LD_LIBRARY_PATH="DYLD_LIBRARY_PATH"
38 SEP = ":"
39 else:
40 LD_LIBRARY_PATH="LD_LIBRARY_PATH"
41 SEP = ":"
42
43 restart = []
44
45 # for Mac, add our local PyGTK libraries at start of Python path:
46 #if platform.system()=="Darwin":
47 # sys.path.insert(0,'dist/gtk.bundle/python')
48
49 # ensure that we have our 'models' dir in the ASCENDLIBRARY path
50 modeldirs = [os.path.join(sourceroot,"models")]
51 if add_at_start('ASCENDLIBRARY',modeldirs):
52 restart.append('ASCENDLIBRARY')
53
54 solverdir = os.path.join(sourceroot,"solvers")
55 solverdirs = [os.path.join(solverdir,d.lower()) for d in "@WITH_SOLVERS@".split(",")]
56 if add_at_start('ASCENDSOLVERS',solverdirs):
57 restart.append('ASCENDSOLVERS')
58
59 # ensure that we have our shared libraries in the LD_LIBRARY_PATH
60 libdirs = [sourceroot,os.path.join(sourceroot,"pygtk")]
61 if add_at_start(LD_LIBRARY_PATH,libdirs):
62 restart.append(LD_LIBRARY_PATH)
63
64 # ensure our pygtk dir is in the PYTHONPATH
65 pypath = [os.path.join(sourceroot,"pygtk")]
66 if add_at_start('PYTHONPATH',pypath):
67 restart.append('PYTHONPATH')
68
69 if restart:
70 print "\nRestarting with..."
71 for v in restart:
72 print " export %s=%s" % (v,os.environ[v])
73 if os.environ.get('ASC_GDB'):
74 print " via GDB..."
75 os.execvp("gdb",['--symbols=../@SHLIBPREFIX@ascend@SHLIBSUFFIX@','--args','@PYTHON@',script]+sys.argv[1:])
76 else:
77 print "PYTHON... ",script
78 sys.stdout.flush() # needed for rxvt on Windows
79 os.execvp('@PYTHON@',[script,script]+sys.argv[1:])
80 # the above calls don't return so we can forget about line of enqiry
81
82
83 print "\nRunning with..."
84 for v in [LD_LIBRARY_PATH,'ASCENDLIBRARY','PYTHONPATH','PATH']:
85 print " %s = %s" % (v,os.environ[v])
86
87 import ascpy
88 from gtkbrowser import *
89 assetspath =os.path.join(sourceroot,"pygtk","glade")
90 print "ASSETS PATH = %s" % assetspath
91 B = Browser(assetspath=assetspath)
92 B.run()

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