[Checkins] SVN: zc.buildout/trunk/ Bug fixed:
Jim Fulton
jim at zope.com
Fri Aug 28 16:30:56 EDT 2009
Log message for revision 103354:
Bug fixed:
The standard Python -m option didn't work for custom interpreters.
Changed:
U zc.buildout/trunk/CHANGES.txt
U zc.buildout/trunk/src/zc/buildout/easy_install.py
U zc.buildout/trunk/src/zc/buildout/easy_install.txt
-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt 2009-08-28 19:46:07 UTC (rev 103353)
+++ zc.buildout/trunk/CHANGES.txt 2009-08-28 20:30:56 UTC (rev 103354)
@@ -22,6 +22,8 @@
- Scripts run using generated interpreters didn't have __file__ set correctly.
+- The standard Python -m option didn't work for custom interpreters.
+
1.4.0 (2009-08-26)
==================
Modified: zc.buildout/trunk/src/zc/buildout/easy_install.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.py 2009-08-28 19:46:07 UTC (rev 103353)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.py 2009-08-28 20:30:56 UTC (rev 103354)
@@ -1127,23 +1127,28 @@
_interactive = True
if len(sys.argv) > 1:
- import getopt
- _options, _args = getopt.getopt(sys.argv[1:], 'ic:')
+ _options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
_interactive = False
for (_opt, _val) in _options:
if _opt == '-i':
_interactive = True
elif _opt == '-c':
exec _val
+ elif _opt == '-m':
+ sys.argv[1:] = _args
+ _args = []
+ __import__("runpy").run_module(
+ _val, {}, "__main__", alter_sys=True)
if _args:
sys.argv[:] = _args
__file__ = _args[0]
+ del _options, _args
execfile(__file__)
if _interactive:
- import code
- code.interact(banner="", local=globals())
+ del _interactive
+ __import__("code").interact(banner="", local=globals())
'''
runsetup_template = """
Modified: zc.buildout/trunk/src/zc/buildout/easy_install.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/easy_install.txt 2009-08-28 19:46:07 UTC (rev 103353)
+++ zc.buildout/trunk/src/zc/buildout/easy_install.txt 2009-08-28 20:30:56 UTC (rev 103354)
@@ -663,32 +663,38 @@
>>> cat(bin, 'py') # doctest: +NORMALIZE_WHITESPACE
#!/usr/local/bin/python2.4
+ <BLANKLINE>
import sys
<BLANKLINE>
sys.path[0:0] = [
- '/sample-install/demo-0.3-py2.4.egg',
- '/sample-install/demoneeded-1.1-py2.4.egg',
+ '/sample-install/demo-0.3-pyN.N.egg',
+ '/sample-install/demoneeded-1.1-pyN.N.egg',
]
<BLANKLINE>
_interactive = True
if len(sys.argv) > 1:
- import getopt
- _options, _args = getopt.getopt(sys.argv[1:], 'ic:')
+ _options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
_interactive = False
for (_opt, _val) in _options:
if _opt == '-i':
_interactive = True
elif _opt == '-c':
exec _val
+ elif _opt == '-m':
+ sys.argv[1:] = _args
+ _args = []
+ __import__("runpy").run_module(
+ _val, {}, "__main__", alter_sys=True)
<BLANKLINE>
if _args:
sys.argv[:] = _args
__file__ = _args[0]
+ del _options, _args
execfile(__file__)
<BLANKLINE>
if _interactive:
- import code
- code.interact(banner="", local=globals())
+ del _interactive
+ __import__("code").interact(banner="", local=globals())
If invoked with a script name and arguments, it will run that script, instead.
@@ -701,6 +707,15 @@
['ascript', 'a', 'b', 'c']
('__main__', 'ascript', 'demo doc')
+For Python 2.5 and higher, you can also use the -m option to run a
+module:
+
+ >>> print system(join(bin, 'py')+' -m pdb'),
+ usage: pdb.py scriptfile [arg] ...
+
+ >>> print system(join(bin, 'py')+' -m pdb what'),
+ Error: what does not exist
+
An additional argument can be passed to define which scripts to install
and to provide script names. The argument is a dictionary mapping
original script names to new script names.
@@ -873,23 +888,28 @@
<BLANKLINE>
_interactive = True
if len(sys.argv) > 1:
- import getopt
- _options, _args = getopt.getopt(sys.argv[1:], 'ic:')
+ _options, _args = __import__("getopt").getopt(sys.argv[1:], 'ic:m:')
_interactive = False
for (_opt, _val) in _options:
if _opt == '-i':
_interactive = True
elif _opt == '-c':
exec _val
+ elif _opt == '-m':
+ sys.argv[1:] = _args
+ _args = []
+ __import__("runpy").run_module(
+ _val, {}, "__main__", alter_sys=True)
<BLANKLINE>
if _args:
sys.argv[:] = _args
__file__ = _args[0]
+ del _options, _args
execfile(__file__)
<BLANKLINE>
if _interactive:
- import code
- code.interact(banner="", local=globals())
+ del _interactive
+ __import__("code").interact(banner="", local=globals())
Handling custom build options for extensions provided in source distributions
More information about the checkins
mailing list