[Checkins] SVN: zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install. Make the interpreter script a bit more like a Python interpreter.
Gary Poster
gary.poster at canonical.com
Thu Jul 9 21:00:07 EDT 2009
Log message for revision 101779:
Make the interpreter script a bit more like a Python interpreter.
In this case, now I can use it with setup.py files that refer to their
__file__.
Also try to put in some diagnostics for when getting the site packages doesn't
work. This is hopefully only a convenience for developers of zc.buildout
itself.
Changed:
U zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.py
U zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.txt
-=-
Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.py 2009-07-10 00:55:19 UTC (rev 101778)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.py 2009-07-10 01:00:06 UTC (rev 101779)
@@ -90,11 +90,13 @@
"print repr([os.path.normpath(p) for p in sys.path])"]
if clean:
cmd.insert(1, '-S')
- _proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- _proc.wait();
- raw = _proc.stdout.read()
- _proc.stdout.close()
- res = eval(raw)
+ _proc = subprocess.Popen(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = _proc.communicate();
+ if _proc.returncode:
+ raise RuntimeError(
+ 'error trying to get system packages:\n%s' % (stderr,))
+ res = eval(stdout)
try:
res.remove('.')
except ValueError:
@@ -1249,8 +1251,10 @@
return generated
py_script_template = script_header + '''\
+
+globs = globals().copy() # get a clean copy early
+
%(relative_paths_setup)s
-
import sys
_set_path = _interactive = True
@@ -1295,11 +1299,13 @@
exec _command
elif _args:
_interactive = False
- execfile(sys.argv[0])
+ globs['__file__'] = sys.argv[0]
+ execfile(sys.argv[0], globs)
if _interactive or _force_interactive:
import code
- code.interact(banner="", local=globals())
+ del globs['__file__']
+ code.interact(banner="", local=globs)
'''
runsetup_template = """
Modified: zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.txt 2009-07-10 00:55:19 UTC (rev 101778)
+++ zc.buildout/branches/gary-support-system-python/src/zc/buildout/easy_install.txt 2009-07-10 01:00:06 UTC (rev 101779)
@@ -733,6 +733,7 @@
>>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
#!/usr/local/bin/python2.4
+ globs = globals().copy() # get a clean copy early
<BLANKLINE>
import sys
<BLANKLINE>
@@ -780,11 +781,13 @@
exec _command
elif _args:
_interactive = False
- execfile(sys.argv[0])
+ globs['__file__'] = sys.argv[0]
+ execfile(sys.argv[0], globs)
<BLANKLINE>
if _interactive or _force_interactive:
import code
- code.interact(banner="", local=globals())
+ del globs['__file__']
+ code.interact(banner="", local=globs)
If invoked with a script name and arguments, it will run that script, instead.
@@ -1008,13 +1011,15 @@
>>> cat(bo, 'bin', 'py') # doctest: +ELLIPSIS
#!/usr/local/bin/python2.4
+ globs = globals().copy() # get a clean copy early
+ <BLANKLINE>
+ <BLANKLINE>
import os
<BLANKLINE>
join = os.path.join
base = os.path.dirname(os.path.abspath(__file__))
base = os.path.dirname(base)
<BLANKLINE>
- <BLANKLINE>
import sys
<BLANKLINE>
_set_path = _interactive = True
@@ -1063,11 +1068,13 @@
exec _command
elif _args:
_interactive = False
- execfile(sys.argv[0])
+ globs['__file__'] = sys.argv[0]
+ execfile(sys.argv[0], globs)
<BLANKLINE>
if _interactive or _force_interactive:
import code
- code.interact(banner="", local=globals())
+ del globs['__file__']
+ code.interact(banner="", local=globs)
Handling custom build options for extensions provided in source distributions
-----------------------------------------------------------------------------
More information about the Checkins
mailing list