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

Contents of /trunk/pygtk/ascdev.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3315 - (show annotations) (download)
Sun Jan 7 08:15:26 2018 UTC (2 years, 8 months ago) by jpye
File size: 3617 byte(s)
Working on adding gradient support to bintoken.c.
Remove dead files models/pending, nothing interesting there.

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 """
8 Add path components at start of envvar, but only if they're not already in the path somewhere.
9 @return 1 if changes made, 0 otherwise
10 @TODO what about Windows path munging?
11 """
12
13 # convert pathcomponents to absolute paths
14 pathcomponents = [os.path.abspath(i) for i in pathcomponents]
15
16 if not os.environ.get(envvar):
17 # env var is not yet set; simply set it to requested value
18 v = SEP.join(pathcomponents)
19 print "CREATED %s=%s" % (envvar,v)
20 os.environ[envvar]=v
21 return 1
22
23 changed = 0
24 # convert what's in there to absolute paths for comparison
25 envvals = [os.path.abspath(i) for i in os.environ[envvar].split(SEP)]
26 oldenv = os.environ[envvar]
27 found = []
28 for p in reversed(pathcomponents):
29 if p not in envvals:
30 envvals.insert(0,p)
31 print "INSERTED into %s: %s"%(envvar,p)
32 changed = 1
33
34 # TODO if changes made, let's check for repeated path components and remove them (PyGTK All-in-one does this)
35
36 os.environ[envvar]=SEP.join(envvals)
37 if not changed:
38 print "VAR %s UNCHANGED" % envvar
39 else:
40 print "VAR %s CHANGED" % envvar
41 print "OLD %s = %s" % (envvar,oldenv)
42 print "NEW %s = %s" % (envvar,os.environ[envvar])
43
44 return changed
45
46 if __name__=='__main__':
47 sourceroot="@SOURCE_ROOT@"
48 script=os.path.join(sys.argv[0])
49
50 if platform.system()=="Windows":
51 LD_LIBRARY_PATH="PATH"
52 SEP = ";"
53 elif platform.system()=="Darwin":
54 LD_LIBRARY_PATH="DYLD_LIBRARY_PATH"
55 SEP = ":"
56 else:
57 LD_LIBRARY_PATH="LD_LIBRARY_PATH"
58 SEP = ":"
59
60 restart = []
61
62 # for Mac, add our local PyGTK libraries at start of Python path:
63 #if platform.system()=="Darwin":
64 # sys.path.insert(0,'dist/gtk.bundle/python')
65
66 # ensure that we have our 'models' dir in the ASCENDLIBRARY path
67 modeldirs = [os.path.join(sourceroot,"models")]
68 if add_at_start('ASCENDLIBRARY',modeldirs):
69 restart.append('ASCENDLIBRARY')
70
71 solverdir = os.path.join(sourceroot,"solvers")
72 solverdirs = [os.path.join(solverdir,d.lower()) for d in "@WITH_SOLVERS@".split(",")]
73 if add_at_start('ASCENDSOLVERS',solverdirs):
74 restart.append('ASCENDSOLVERS')
75
76 # ensure that we have our shared libraries in the LD_LIBRARY_PATH
77 libdirs = [sourceroot,os.path.join(sourceroot,"pygtk")]
78 if add_at_start(LD_LIBRARY_PATH,libdirs):
79 restart.append(LD_LIBRARY_PATH)
80
81 # for bintoken compilation
82 if add_at_start('ASCENDBTINC',[os.path.join(sourceroot)]):
83 restart.append('ASCENDBTINC')
84 if add_at_start('ASCENDBTLIB',[os.path.join(sourceroot)]):
85 restart.append('ASCENDBTLIB')
86
87 # ensure our pygtk dir is in the PYTHONPATH
88 pypath = [os.path.join(sourceroot,"ascxx")]
89 if add_at_start('PYTHONPATH',pypath):
90 restart.append('PYTHONPATH')
91
92 if restart:
93 print "\nRestarting with..."
94 for v in restart:
95 print " export %s=%s" % (v,os.environ[v])
96 if os.environ.get('ASC_GDB'):
97 print " via GDB..."
98 os.execvp("gdb",['--symbols=../@SHLIBPREFIX@ascend@SHLIBSUFFIX@','--args','@PYTHON@',script]+sys.argv[1:])
99 else:
100 print "PYTHON... ",script
101 sys.stdout.flush() # needed for rxvt on Windows
102 os.execvp('@PYTHON@',[script,script]+sys.argv[1:])
103 # the above calls don't return so we can forget about line of enqiry
104
105
106 print "\nRunning with..."
107 for v in [LD_LIBRARY_PATH,'ASCENDLIBRARY','ASCENDSOLVERS','PYTHONPATH','PATH']:
108 print " %s = %s" % (v,os.environ[v])
109
110 import ascpy
111 from gtkbrowser import *
112 assetspath = os.path.join(os.path.join(sourceroot,"pygtk"),"glade")
113 print "ASSETS PATH = %s" % assetspath
114 B = Browser(assetspath=assetspath)
115 B.run()

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