Commit fc897d37 authored by Jim Fulton's avatar Jim Fulton

Bug fixed:

  The standard Python -m option didn't work for custom interpreters.
parent 125784d9
......@@ -22,6 +22,8 @@ Bugs fixed:
- 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)
==================
......
......@@ -1127,23 +1127,28 @@ sys.path[0:0] = [
_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 = """
......
......@@ -663,32 +663,38 @@ the path set:
>>> 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 @@ If invoked with a script name and arguments, it will run that script, instead.
['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 @@ We specified an interpreter and its paths are adjusted too:
<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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment