[z3-checkins] r46586 - in z3/deliverance/buildout/trunk/helpers/topp: . helpers
ltucker at codespeak.net
ltucker at codespeak.net
Fri Sep 14 18:24:37 CEST 2007
Author: ltucker
Date: Fri Sep 14 18:24:37 2007
New Revision: 46586
Added:
z3/deliverance/buildout/trunk/helpers/topp/
z3/deliverance/buildout/trunk/helpers/topp/__init__.py
z3/deliverance/buildout/trunk/helpers/topp/helpers/
z3/deliverance/buildout/trunk/helpers/topp/helpers/__init__.py
z3/deliverance/buildout/trunk/helpers/topp/helpers/addbinpath.py
z3/deliverance/buildout/trunk/helpers/topp/helpers/fixlibsearch.py
Log:
add helper lib
Added: z3/deliverance/buildout/trunk/helpers/topp/__init__.py
==============================================================================
Added: z3/deliverance/buildout/trunk/helpers/topp/helpers/__init__.py
==============================================================================
Added: z3/deliverance/buildout/trunk/helpers/topp/helpers/addbinpath.py
==============================================================================
--- (empty file)
+++ z3/deliverance/buildout/trunk/helpers/topp/helpers/addbinpath.py Fri Sep 14 18:24:37 2007
@@ -0,0 +1,25 @@
+import os
+
+class Recipe:
+
+ def __init__(self, buildout, name, options):
+ self.options = options
+ self.buildout = buildout
+ self.name = name
+
+ def install(self):
+ options = self.options
+ path = options.get('path')
+ if path is None:
+ return ()
+
+ oldpath = os.environ.get('PATH','')
+
+ newpathelts = path.split(':')
+ oldpathelts = oldpath.split(':')
+ os.environ['PATH'] = ':'.join(newpathelts + oldpathelts)
+ print "PATH =", os.environ['PATH']
+
+ return ()
+
+
Added: z3/deliverance/buildout/trunk/helpers/topp/helpers/fixlibsearch.py
==============================================================================
--- (empty file)
+++ z3/deliverance/buildout/trunk/helpers/topp/helpers/fixlibsearch.py Fri Sep 14 18:24:37 2007
@@ -0,0 +1,66 @@
+import pkg_resources
+import os
+import stat
+import sys
+
+class Recipe:
+
+ def __init__(self, buildout, name, options):
+ self.options = options
+ self.buildout = buildout
+ self.name = name
+
+ def install(self):
+
+ eggs = [
+ r.strip()
+ for r in self.options.get('eggs', self.name).split('\n')
+ if r.strip()]
+
+ libpath = self.options.get('libpath').strip()
+
+ bindir = self.buildout['buildout']['bin-directory']
+
+ local_env = pkg_resources.Environment([self.buildout['buildout']['eggs-directory'],
+ self.buildout['buildout']['develop-eggs-directory']])
+
+ for egg in eggs:
+ dists = local_env[egg]
+ if dists is None or len(dists) == 0:
+ raise pkg_resources.DistributionNotFound,egg
+ dist = dists[0] # uses the newest
+ for script in pkg_resources.get_entry_map(dist, 'console_scripts').keys():
+ self.fixscript(os.path.join(bindir,script), libpath)
+
+
+ return ()
+
+
+
+ def fixscript(self, script, libpath):
+ """
+ wraps distutils script to set LD_LIBRARY_PATH to libpath
+ """
+
+ oldscript = script + ".wrapped"
+ interpreter = sys.executable
+ os.rename(script, oldscript)
+
+ s = open(script, 'w')
+ s.write("""\
+#!%(interpreter)s
+
+import os
+import sys
+
+os.environ['LD_LIBRARY_PATH'] = %(libpath)r
+
+if __name__ == '__main__':
+ args = [sys.executable, %(oldscript)r]
+ args += sys.argv[1:]
+ os.execv(sys.executable, args)
+""" % locals())
+
+
+ os.chmod(script,
+ stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH)
More information about the z3-checkins
mailing list