/[ascend]/trunk/scons/installgtk.py
ViewVC logotype

Diff of /trunk/scons/installgtk.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2138 by jpye, Sat Dec 19 06:32:53 2009 UTC revision 2139 by jpye, Sat Dec 19 08:20:14 2009 UTC
# Line 38  def find_deps(binary): Line 38  def find_deps(binary):
38          deps.add(m.group(1))          deps.add(m.group(1))
39      return deps      return deps
40    
41    def reroute_deps(lib,gtksite,pysite):
42        deps = find_deps(lib)
43        for d in deps:
44            oldpath = d
45            r = os.path.commonprefix([oldpath,gtksite])
46            if r == gtksite:
47                # this dependency is pointing into the GTK installation location
48                c = os.path.commonprefix([lib,gtksite])
49                newpath = "@executable_path/gtk.bundle/gtk/" + oldpath[len(r):]
50            else:
51                r = os.path.commonprefix([oldpath,pysite])
52                if r == pysite:
53                    # this dependency is pointing to a file installed inside Python
54                    newpath = "@executable_path/gtk.bundle/python/" + oldpath[len(r):]
55                else:
56                    continue
57    
58            cmd = ['/usr/bin/install_name_tool','-change',oldpath,newpath,lib]
59            #print "RELINK %s: %s --> %s" % (lib,oldpath,newpath)
60            #print " ".join(cmd)
61            P = subprocess.Popen(cmd,stdout=subprocess.PIPE)
62            P.communicate()
63    
64  def generate(env):  def generate(env):
65      pass      pass
66    
# Line 140  if __name__ == "__main__": Line 163  if __name__ == "__main__":
163          print "Copy %s --> %s" % (f, os.path.join(pytarget,r))          print "Copy %s --> %s" % (f, os.path.join(pytarget,r))
164          shutil.copy(f,os.path.join(pytarget,r))          shutil.copy(f,os.path.join(pytarget,r))
165    
166      print "\nCopying Python shared libraries"      print "\nCopying Python shared libraries and rerouting"
167      copied = set()      copied = set()
168      for f in realimports:      for f in realimports:
169          if os.path.commonprefix([f,pysite]) == pysite:          if os.path.commonprefix([f,pysite]) == pysite:
# Line 154  if __name__ == "__main__": Line 177  if __name__ == "__main__":
177              print "Create directory '%s'"% dir              print "Create directory '%s'"% dir
178              os.makedirs(os.path.join(pytarget,dir))              os.makedirs(os.path.join(pytarget,dir))
179    
180          shutil.copy(f,os.path.join(pytarget,r))          t = os.path.join(pytarget,r)
181            shutil.copy(f,t)
182          copied.add(f)          copied.add(f)
183    
184      print "\nCopying GTK libraries"          reroute_deps(t,gtksite,pysite)
185    
186    
187        print "\nCopying GTK libraries and rerouting"
188      gtktarget = os.path.join(targetpath,"gtk")      gtktarget = os.path.join(targetpath,"gtk")
189      if not os.path.exists(gtktarget):      if not os.path.exists(gtktarget):
190          os.mkdir(gtktarget)          os.mkdir(gtktarget)
# Line 174  if __name__ == "__main__": Line 201  if __name__ == "__main__":
201              os.makedirs(os.path.join(gtktarget,dir))              os.makedirs(os.path.join(gtktarget,dir))
202    
203          print "Copy %s --> %s" % (f, os.path.join(gtktarget,r))          print "Copy %s --> %s" % (f, os.path.join(gtktarget,r))
204          shutil.copy(f,os.path.join(gtktarget,r))          t = os.path.join(gtktarget,r)
205            shutil.copy(f,t)
206          copied.add(f)          copied.add(f)
207    
208            reroute_deps(t,gtksite,pysite)
209    
210      if copied != realimports:      if copied != realimports:
211          print "\nError: some library files were not copied:"          print "\nError: some library files were not copied:"
212          for f in realimports - copied:          for f in realimports - copied:

Legend:
Removed from v.2138  
changed lines
  Added in v.2139

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