[z3-checkins] r35319 - z3/deliverance/buildout/trunk/helpers/topp/helpers
ianb at codespeak.net
ianb at codespeak.net
Tue Dec 5 18:45:53 CET 2006
Author: ianb
Date: Tue Dec 5 18:45:50 2006
New Revision: 35319
Modified:
z3/deliverance/buildout/trunk/helpers/topp/helpers/fixlibsearch.py
Log:
Use execv to replace the process in the wrapped script, and make it a little more readable
Modified: z3/deliverance/buildout/trunk/helpers/topp/helpers/fixlibsearch.py
==============================================================================
--- z3/deliverance/buildout/trunk/helpers/topp/helpers/fixlibsearch.py (original)
+++ z3/deliverance/buildout/trunk/helpers/topp/helpers/fixlibsearch.py Tue Dec 5 18:45:50 2006
@@ -1,5 +1,7 @@
import pkg_resources
-import os,stat
+import os
+import stat
+import sys
class Recipe:
@@ -34,21 +36,23 @@
"""
oldscript = script + ".wrapped"
- interpreter = open(script).readline()[2:].strip()
-
- os.rename(script,oldscript)
+ interpreter = sys.executable
+ os.rename(script, oldscript)
s = open(script, 'w')
- s.write(''.join(["#!%s\n\n" % interpreter,
- "import os\n",
- "import sys\n",
- "import subprocess\n",
- "os.environ['LD_LIBRARY_PATH'] = '%s'\n\n" % libpath,
- "if __name__ == '__main__':\n",
- " args = ['%s', '%s']\n" % (interpreter,oldscript),
- " args += sys.argv[1:]\n",
- " subprocess.call(args)"
- ]))
+ 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,
More information about the z3-checkins
mailing list