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

Annotation of /trunk/pygtk/ascdev.in

Parent Directory Parent Directory | Revision Log Revision Log


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

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