Changeset 765
- Timestamp:
- 07/22/07 01:54:21 (1 year ago)
- Files:
-
- pyrun/trunk/README.nose.txt (deleted)
- pyrun/trunk/examples/command_line_use.rst (modified) (1 diff)
- pyrun/trunk/pyrun.html (modified) (4 diffs)
- pyrun/trunk/pyrun.rst (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyrun/trunk/examples/command_line_use.rst
r761 r765 1 1 pyrun - command line usage 2 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 4 pyrun [PYRUN-OPTIONS] [DISCOVERYPATH] [TARGET-OPTIONS]5 6 7 module discovery and implicit selection8 .......................................9 10 If you include an explicit reference to a python source file in the discovery11 path you are acheiving two things:12 13 1. You select it as the `implicit` run target14 2. You `discover` the appropriate path to add to sys.path in order for the15 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 path18 discovery. The implicit `pyrun target` is *always* the *first* module19 reference.20 21 To *explicitly* select the module to run, terminate the pyrun arguments with22 ``-m fully.qualified.module.name``. Replacing `fully.qualified.module.name`23 with the module you wish to run.24 25 simple examples26 ...............27 28 Given::29 30 ~/foo/__init__.py31 ~/foo/bar/__init__.py32 ~/foo/mod.py33 34 35 Implicit selection of a sub module::36 37 pyrun ~/foo/bar/__init__.py38 ^ ^39 | |40 | .41 | ------- * module file42 .43 -----------------------* `sys.path` entry44 45 pyrun ~/foo/mod.py46 ^ ^47 | |48 | .49 | ---------------- * module file50 .51 -----------------------* `sys.path` entry52 53 The ``python -m`` form of the above examples would be::54 55 PYTHONPATH=~/foo python -m foo.bar56 57 PYTHONPATH=~/foo python -m foo.mod58 59 For examples as simple as this one the only potential advantage of pyrun is the60 convenience of not having to work with `SHELL` environment variables.61 62 Things get more interesting when your `discovery` path includes more elements.63 3 64 4 65 5 66 6 7 pyrun/trunk/pyrun.html
r761 r765 337 337 <li><a class="reference" href="#pyrun" id="id1" name="id1">pyrun</a></li> 338 338 <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> 340 340 <li><a class="reference" href="#module-discovery-and-implicit-selection" id="id4" name="id4">module discovery and implicit selection</a></li> 341 341 <li><a class="reference" href="#simple-examples" id="id5" name="id5">simple examples</a></li> 342 </ul>343 </li>344 342 <li><a class="reference" href="#pyrun-module-api" id="id6" name="id6">pyrun - module api</a><ul> 345 343 <li><a class="reference" href="#discover-and-run" id="id7" name="id7">discover_and_run</a></li> … … 412 410 </div> 413 411 <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 418 implicitly select the module to run AND you want to pass a non option argument 419 as the first value in the command line for that module. It can also be 420 necessary when the target module has short options, without long-name 421 alternatives, which collide with those defined for pyrun.</p> 422 <p>Discover python packages and modules under PATH. Run the first module file 423 named 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 443 references 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 450 using <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 457 python 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 461 context 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> 418 469 <p>If you include an explicit reference to a python source file in the discovery 419 470 path you are acheiving two things:</p> … … 431 482 </div> 432 483 <div class="section"> 433 <h 2><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> 434 485 <p>Given:</p> 435 486 <pre class="literal-block"> … … 465 516 convenience of not having to work with <cite>SHELL</cite> environment variables.</p> 466 517 <p>Things get more interesting when your <cite>discovery</cite> path includes more elements.</p> 467 </div>468 518 </div> 469 519 <div class="section"> pyrun/trunk/pyrun.rst
r761 r765 10 10 .. include:: INSTALL.txt 11 11 12 .. include:: examples/command_line_use.rst 12 .. include:: command_line_interface.rst 13 13 14 .. include:: examples/discover_and_run.rst 14 15