Changeset 765

Show
Ignore:
Timestamp:
07/22/07 01:54:21 (1 year ago)
Author:
robin
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyrun/trunk/examples/command_line_use.rst

    r761 r765  
    11pyrun - command line usage 
    22~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3  
    4 pyrun [PYRUN-OPTIONS] [DISCOVERYPATH] [TARGET-OPTIONS] 
    5  
    6  
    7 module discovery and implicit selection 
    8 ....................................... 
    9  
    10 If you include an explicit reference to a python source file in the discovery 
    11 path you are acheiving two things: 
    12  
    13 1. You select it as the `implicit` run target 
    14 2. You `discover` the appropriate path to add to sys.path in order for the 
    15    identified module to be imported using its *fully* qualified module name. 
    16  
    17 All modules referenced on the command line like this are considered for path 
    18 discovery. The implicit `pyrun target` is *always* the *first* module 
    19 reference. 
    20  
    21 To *explicitly* select the module to run, terminate the pyrun arguments with 
    22 ``-m fully.qualified.module.name``. Replacing `fully.qualified.module.name` 
    23 with the module you wish to run. 
    24  
    25 simple examples 
    26 ............... 
    27  
    28 Given:: 
    29  
    30   ~/foo/__init__.py 
    31   ~/foo/bar/__init__.py 
    32   ~/foo/mod.py 
    33  
    34  
    35 Implicit selection of a sub module:: 
    36  
    37   pyrun ~/foo/bar/__init__.py 
    38              ^              ^ 
    39              |              | 
    40              |              . 
    41              |               ------- * module file 
    42              . 
    43               -----------------------* `sys.path` entry 
    44  
    45   pyrun ~/foo/mod.py 
    46              ^     ^ 
    47              |     | 
    48              |     . 
    49              |      ---------------- * module file 
    50              . 
    51               -----------------------* `sys.path` entry 
    52  
    53 The ``python -m`` form of the above examples would be:: 
    54  
    55   PYTHONPATH=~/foo python -m foo.bar 
    56  
    57   PYTHONPATH=~/foo python -m foo.mod 
    58  
    59 For examples as simple as this one the only potential advantage of pyrun is the 
    60 convenience of not having to work with `SHELL` environment variables. 
    61  
    62 Things get more interesting when your `discovery` path includes more elements. 
    633 
    644 
    655 
    666 
     7 
  • pyrun/trunk/pyrun.html

    r761 r765  
    337337<li><a class="reference" href="#pyrun" id="id1" name="id1">pyrun</a></li> 
    338338<li><a class="reference" href="#installation" id="id2" name="id2">Installation</a></li> 
    339 <li><a class="reference" href="#pyrun-command-line-usage" id="id3" name="id3">pyrun - command line usage</a><ul
     339<li><a class="reference" href="#command-line-interface" id="id3" name="id3">Command line interface</a></li
    340340<li><a class="reference" href="#module-discovery-and-implicit-selection" id="id4" name="id4">module discovery and implicit selection</a></li> 
    341341<li><a class="reference" href="#simple-examples" id="id5" name="id5">simple examples</a></li> 
    342 </ul> 
    343 </li> 
    344342<li><a class="reference" href="#pyrun-module-api" id="id6" name="id6">pyrun - module api</a><ul> 
    345343<li><a class="reference" href="#discover-and-run" id="id7" name="id7">discover_and_run</a></li> 
     
    412410</div> 
    413411<div class="section"> 
    414 <h1><a class="toc-backref" href="#id3" id="pyrun-command-line-usage" name="pyrun-command-line-usage">pyrun - command line usage</a></h1> 
    415 <p>pyrun [PYRUN-OPTIONS] [DISCOVERYPATH] [TARGET-OPTIONS]</p> 
    416 <div class="section"> 
    417 <h2><a class="toc-backref" href="#id4" id="module-discovery-and-implicit-selection" name="module-discovery-and-implicit-selection">module discovery and implicit selection</a></h2> 
     412<h1><a class="toc-backref" href="#id3" id="command-line-interface" name="command-line-interface">Command line interface</a></h1> 
     413<dl class="docutils"> 
     414<dt>Usage: pyrun.py  [-nidP] [BASEPATH 1] [BASEPATH 2] ... [BASEPATH n]</dt> 
     415<dd>[-m mod.name | -c STATEMENT | -C STATEMENT | '--'] [TARGET-OPTIONS]</dd> 
     416</dl> 
     417<p>In most cases the solo '--' is not required. It tends to be useful when you 
     418implicitly select the module to run AND you want to pass a non option argument 
     419as the first value in the command line for that module. It can also be 
     420necessary when the target module has short options, without long-name 
     421alternatives, which collide with those defined for pyrun.</p> 
     422<p>Discover python packages and modules under PATH. Run the first module file 
     423named in <cite>PATH</cite> <em>OR</em> explicitly nominated using the <cite>-m</cite> option.</p> 
     424<p>NOTE: Any option that is marked [NYI] is Not Yet Implemented.</p> 
     425<dl class="docutils"> 
     426<dt>Options:</dt> 
     427<dd><table class="first last docutils option-list" frame="void" rules="none"> 
     428<col class="option" /> 
     429<col class="description" /> 
     430<tbody valign="top"> 
     431<tr><td class="option-group"> 
     432<kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></td> 
     433<td>show this help message and exit</td></tr> 
     434<tr><td class="option-group"> 
     435<kbd><span class="option">-p</span></kbd></td> 
     436<td>Print the discovered path</td></tr> 
     437<tr><td class="option-group"> 
     438<kbd><span class="option">-P</span></kbd></td> 
     439<td>Print the discovered path in a PYTHONPATH compatible format</td></tr> 
     440<tr><td class="option-group"> 
     441<kbd><span class="option">-n</span></kbd></td> 
     442<td>NORUN. Don't run any of the modules implied by module file 
     443references in  the discovery path.</td></tr> 
     444<tr><td class="option-group"> 
     445<kbd><span class="option">-m <var>MODULE</var></span></kbd></td> 
     446<td>Explicitly select a module to run.</td></tr> 
     447<tr><td class="option-group"> 
     448<kbd><span class="option">-d</span></kbd></td> 
     449<td>DEBUG session. Prepare for execution, but start a pdb session 
     450using <cite>pdb.set_trace</cite>.</td></tr> 
     451<tr><td class="option-group"> 
     452<kbd><span class="option">-i</span></kbd></td> 
     453<td>INTERACTIVE session with prepared sys.argv and sys.path.</td></tr> 
     454<tr><td class="option-group"> 
     455<kbd><span class="option">-c <var>STATEMENT</var></span></kbd></td> 
     456<td>Update sys.argv and sys.path then execute statement in a new 
     457python module. [NYI]</td></tr> 
     458<tr><td class="option-group"> 
     459<kbd><span class="option">-C <var>STATEMENT</var></span></kbd></td> 
     460<td>Update sys.argv and sys.path then execute statement in the 
     461context of the selected module. [NYI]</td></tr> 
     462</tbody> 
     463</table> 
     464</dd> 
     465</dl> 
     466</div> 
     467<div class="section"> 
     468<h1><a class="toc-backref" href="#id4" id="module-discovery-and-implicit-selection" name="module-discovery-and-implicit-selection">module discovery and implicit selection</a></h1> 
    418469<p>If you include an explicit reference to a python source file in the discovery 
    419470path you are acheiving two things:</p> 
     
    431482</div> 
    432483<div class="section"> 
    433 <h2><a class="toc-backref" href="#id5" id="simple-examples" name="simple-examples">simple examples</a></h2
     484<h1><a class="toc-backref" href="#id5" id="simple-examples" name="simple-examples">simple examples</a></h1
    434485<p>Given:</p> 
    435486<pre class="literal-block"> 
     
    465516convenience of not having to work with <cite>SHELL</cite> environment variables.</p> 
    466517<p>Things get more interesting when your <cite>discovery</cite> path includes more elements.</p> 
    467 </div> 
    468518</div> 
    469519<div class="section"> 
  • pyrun/trunk/pyrun.rst

    r761 r765  
    1010.. include:: INSTALL.txt 
    1111 
    12 .. include:: examples/command_line_use.rst 
     12.. include:: command_line_interface.rst 
     13 
    1314.. include:: examples/discover_and_run.rst 
    1415