Changeset 793

Show
Ignore:
Timestamp:
08/19/07 15:43:56 (1 year ago)
Author:
robin
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyrun/trunk/ChangeLog

    r792 r793  
    440.1.1: 
    55  * Added support for directory exclusions and path prunes. 
    6      exclusion prevents discovery descending into a directory if that 
    7       directory startswith an element in the exclusion set (see new option -x). 
    8      prune operates on the result of the discovery. Any path which 
    9       contains one of the strings specified by a prune is removed from the 
    10       discovered path. 
    11      exclusion hides directories from the discovery process, prune removes 
    12      results after the fact. 
    13      . 
    14      exclusions are enabled by -x 
    15      prunes are enabled by -X 
    16      empty strings are *always* removed from -x and -X. 
    17      . 
    18      Note that no mechanism is provided for adding a path back in *under* 
    19      and excluded directory. 
     6     * exclusion prevents discovery descending into a directory if that 
     7       directory startswith an element in the exclusion set 
     8       (see new option -x). 
     9     * prune operates on the result of the discovery. Any path which contains 
     10       one of the strings specified by a prune is removed from the discovered 
     11       path. 
     12 
     13    exclusion hides directories from the discovery process, prune removes 
     14    results after the fact. 
     15    exclusions are enabled by -x 
     16    prunes are enabled by -X 
     17    empty strings are *always* removed from -x and -X. 
     18 
     19    There is precisely one mechanism which enables packages *under* an 
     20    exclusion path to be explicitly added back in: All explicitly identified 
     21    python modules are exempted from the exclusion (but not the prune) 
     22 
    2023  * Decided to use logging instead of print for notification, I had avoided 
    2124    this previously because I did not want to polute the logging configuration 
  • pyrun/trunk/command_line_interface.rst

    r783 r793  
    1313 
    1414Options: 
    15   -h, --help    show this help message and exit 
    16   -p            Print the discovered path 
    17   -P            Print the discovered path in a PYTHONPATH compatible format 
    18   -n            NORUN. Don't run any of the modules implied by module file 
    19                 references in  the discovery path. 
    20   -S SCRIPT     Identify a *python* SCRIPT to execute. The script need not 
    21                 have file extension but it must contain leagal python code. 
    22                 This option trumps -m. This option should only be necessary 
    23                 when the launcher for the python program you wish to run 
    24                 contains significant functionality. No additions are made to 
    25                 the discovery path or sys.path as a result of using this 
    26                 option. If the target script imports a related package you 
    27                 will need to include additional non option arguments to 
    28                 discover its path. 
    29   -m MODULE     Explicitly select a module to run. (trumped by -S) 
    30   -d            DEBUG session. Prepare for execution, but start a pdb session 
    31                 using `pdb.set_trace`. 
    32   -D            POSTMORTEM debugging. If the target raises an exception, start 
    33                 a     postmortem pdb debugging session. 
    34   -i            INTERACTIVE session with prepared sys.argv and sys.path. 
    35   -c STATEMENT  Update sys.argv and sys.path then execute statement in a new 
    36                 python module. [NYI] 
    37   -C STATEMENT  Update sys.argv and sys.path then execute statement in the 
    38                 context of the selected module. [NYI] 
     15  -h, --help         show this help message and exit 
     16  --log-level=LEVEL  [default:WARNING] set the logging level, any string which 
     17                     names a log level which is defined by the logging package 
     18                     is allowed. For example any of CRITICAL, WARNING, INFO 
     19                     and DEBUG (in increasing order of verbosity) 
     20  -q                 Suppress all warnings about missing paths etc. Useful 
     21                     when you are using speculative paths and are using -p or 
     22                     -P to print the discoverd path. 
     23  -p                 Print the discovered path 
     24  -P                 Print the discovered path in a PYTHONPATH compatible 
     25                     format 
     26  -n                 NORUN. Don't run any of the modules implied by module 
     27                     file references in  the discovery path. 
     28  -C SCRIPT          Identify a *python* SCRIPT to execute. The script need 
     29                     not have file extension but it must contain leagal python 
     30                     code. This option trumps -m. This option should only be 
     31                     necessary when the launcher for the python program you 
     32                     wish to run contains significant functionality. No 
     33                     additions are made to the discovery path or sys.path as a 
     34                     result of using this option. If the target script imports 
     35                     a related package you will need to include additional non 
     36                     option arguments to discover its path. 
     37  -m MODULE          Explicitly select a module to run. (trumped by -S) 
     38  -d                 DEBUG session. Use `pdb.runeval` on the module code in 
     39                     order to enter an interactive debug session at the first 
     40                     python statement of the target module 
     41  -D                 POSTMORTEM debugging. If the target raises an exception, 
     42                     start a     postmortem pdb debugging session. 
     43  -i                 INTERACTIVE session with prepared sys.argv and sys.path. 
     44  -c STATEMENT       Update sys.argv and sys.path then execute the statement 
     45                     in a new, clean, module context. 
     46  -x EXCLUDE         Exclude one or more directories, separated by ":", from 
     47                     the discovery path. 
     48  -X PRUNE           Prune all paths which contain this value from the set of 
     49                     paths which *were* discovered. Specify multiple -X 
     50                     options if you wish too prune based on more than one 
     51                     string. 
  • pyrun/trunk/pkg-info.rst

    r788 r793  
    11:License: MIT 
    22:Name: pyrun 
    3 :Version: 0.1.1dev 
     3:Version: 0.1.1b1 
    44:Author: Robin Bryce 
    55:Author-email: robinbryce@gmail.com 
  • pyrun/trunk/pyrun.html

    r785 r793  
    300300</tr> 
    301301<tr><th class="docinfo-name">Version:</th> 
    302 <td>0.1</td></tr> 
     302<td>0.1.1b1</td></tr> 
    303303<tr><th class="docinfo-name">Author:</th> 
    304304<td>Robin Bryce</td></tr> 
     
    454454<kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></td> 
    455455<td>show this help message and exit</td></tr> 
     456<tr><td class="option-group" colspan="2"> 
     457<kbd><span class="option">--log-level=<var>LEVEL</var></span></kbd></td> 
     458</tr> 
     459<tr><td>&nbsp;</td><td>[default:WARNING] set the logging level, any string which 
     460names a log level which is defined by the logging package 
     461is allowed. For example any of CRITICAL, WARNING, INFO 
     462and DEBUG (in increasing order of verbosity)</td></tr> 
     463<tr><td class="option-group"> 
     464<kbd><span class="option">-q</span></kbd></td> 
     465<td>Suppress all warnings about missing paths etc. Useful 
     466when you are using speculative paths and are using -p or 
     467-P to print the discoverd path.</td></tr> 
    456468<tr><td class="option-group"> 
    457469<kbd><span class="option">-p</span></kbd></td> 
     
    459471<tr><td class="option-group"> 
    460472<kbd><span class="option">-P</span></kbd></td> 
    461 <td>Print the discovered path in a PYTHONPATH compatible format</td></tr> 
     473<td>Print the discovered path in a PYTHONPATH compatible 
     474format</td></tr> 
    462475<tr><td class="option-group"> 
    463476<kbd><span class="option">-n</span></kbd></td> 
    464 <td>NORUN. Don't run any of the modules implied by module file 
    465 references in  the discovery path.</td></tr> 
    466 <tr><td class="option-group"> 
    467 <kbd><span class="option">-S <var>SCRIPT</var></span></kbd></td> 
    468 <td>Identify a <em>python</em> SCRIPT to execute. The script need not 
    469 have file extension but it must contain leagal python code. 
    470 This option trumps -m. This option should only be necessary 
    471 when the launcher for the python program you wish to run 
    472 contains significant functionality. No additions are made t
    473 the discovery path or sys.path as a result of using this 
    474 option. If the target script imports a related package you 
    475 will need to include additional non option arguments to 
    476 discover its path.</td></tr> 
     477<td>NORUN. Don't run any of the modules implied by module 
     478file references in  the discovery path.</td></tr> 
     479<tr><td class="option-group"> 
     480<kbd><span class="option">-C <var>SCRIPT</var></span></kbd></td> 
     481<td>Identify a <em>python</em> SCRIPT to execute. The script need 
     482not have file extension but it must contain leagal python 
     483code. This option trumps -m. This option should only be 
     484necessary when the launcher for the python program you 
     485wish to run contains significant functionality. N
     486additions are made to the discovery path or sys.path as a 
     487result of using this option. If the target script imports 
     488a related package you will need to include additional non 
     489option arguments to discover its path.</td></tr> 
    477490<tr><td class="option-group"> 
    478491<kbd><span class="option">-m <var>MODULE</var></span></kbd></td> 
     
    480493<tr><td class="option-group"> 
    481494<kbd><span class="option">-d</span></kbd></td> 
    482 <td>DEBUG session. Prepare for execution, but start a pdb session 
    483 using <cite>pdb.set_trace</cite>.</td></tr> 
     495<td>DEBUG session. Use <cite>pdb.runeval</cite> on the module code in 
     496order to enter an interactive debug session at the first 
     497python statement of the target module</td></tr> 
    484498<tr><td class="option-group"> 
    485499<kbd><span class="option">-D</span></kbd></td> 
    486 <td>POSTMORTEM debugging. If the target raises an exception, start 
    487 a     postmortem pdb debugging session.</td></tr> 
     500<td>POSTMORTEM debugging. If the target raises an exception, 
     501start a     postmortem pdb debugging session.</td></tr> 
    488502<tr><td class="option-group"> 
    489503<kbd><span class="option">-i</span></kbd></td> 
     
    491505<tr><td class="option-group"> 
    492506<kbd><span class="option">-c <var>STATEMENT</var></span></kbd></td> 
    493 <td>Update sys.argv and sys.path then execute statement in a new 
    494 python module. [NYI]</td></tr> 
    495 <tr><td class="option-group"> 
    496 <kbd><span class="option">-C <var>STATEMENT</var></span></kbd></td> 
    497 <td>Update sys.argv and sys.path then execute statement in the 
    498 context of the selected module. [NYI]</td></tr> 
     507<td>Update sys.argv and sys.path then execute the statement 
     508in a new, clean, module context.</td></tr> 
     509<tr><td class="option-group"> 
     510<kbd><span class="option">-x <var>EXCLUDE</var></span></kbd></td> 
     511<td>Exclude one or more directories, separated by &quot;:&quot;, from 
     512the discovery path.</td></tr> 
     513<tr><td class="option-group"> 
     514<kbd><span class="option">-X <var>PRUNE</var></span></kbd></td> 
     515<td>Prune all paths which contain this value from the set of 
     516paths which <em>were</em> discovered. Specify multiple -X 
     517options if you wish too prune based on more than one 
     518string.</td></tr> 
    499519</tbody> 
    500520</table> 
     
    654674<h1><a class="toc-backref" href="#id5" id="changelog" name="changelog">ChangeLog</a></h1> 
    655675<dl class="docutils"> 
    656 <dt>0.1d</dt> 
     676<dt>0.1.1:</dt> 
     677<dd><ul class="first last"> 
     678<li><dl class="first docutils"> 
     679<dt>Added support for directory exclusions and path prunes.</dt> 
     680<dd><ul class="first last simple"> 
     681<li>exclusion prevents discovery descending into a directory if that 
     682directory startswith an element in the exclusion set 
     683(see new option -x).</li> 
     684<li>prune operates on the result of the discovery. Any path which contains 
     685one of the strings specified by a prune is removed from the discovered 
     686path.</li> 
     687</ul> 
     688</dd> 
     689</dl> 
     690<p>exclusion hides directories from the discovery process, prune removes 
     691results after the fact. 
     692exclusions are enabled by -x 
     693prunes are enabled by -X 
     694empty strings are <em>always</em> removed from -x and -X.</p> 
     695<p>There is precisely one mechanism which enables packages <em>under</em> an 
     696exclusion path to be explicitly added back in: All explicitly identified 
     697python modules are exempted from the exclusion (but not the prune)</p> 
     698</li> 
     699<li><p class="first">Decided to use logging instead of print for notification, I had avoided 
     700this previously because I did not want to polute the logging configuration 
     701of the target app. I consider this change provisional, if it causes to 
     702much trouble I will revert to print</p> 
     703</li> 
     704<li><p class="first">Added support for including .pth files in the discovery phase. This 
     705makes it possible to insert paths to directories which do not contain 
     706an __init__.py or are the dirname() of an explicitly referenced module 
     707file.</p> 
     708</li> 
     709<li><p class="first">bugfix: propagate source file name (or sensibly invented filename) to 
     710the __file__ attribute of the code instance that becomes our __main__</p> 
     711</li> 
     712<li><p class="first">-d works with -m and -c, should also work with -s but have not tried yet.</p> 
     713</li> 
     714<li><p class="first">-d option uses pdb.runeval rather than set_trace making for considerably 
     715simpler target debugging. May consider introducing an &quot;eager&quot; -d variant 
     716that behaves like 0.1 (set_trace <em>in</em> pyrun.py) later.</p> 
     717</li> 
     718<li><p class="first">Allow the target to run when -d is in effect, without requiring user to 
     719manaully do <tt class="docutils literal"><span class="pre">opts.d</span> <span class="pre">=</span> <span class="pre">False</span></tt></p> 
     720</li> 
     721<li><p class="first">By default suppress -D if -d is in effect.</p> 
     722</li> 
     723<li><p class="first">Added -c, its much like python -c</p> 
     724</li> 
     725<li><p class="first">The <cite>run script</cite> option changed from -S to -C exist on the file system. -q 
     726suppreses the warnings</p> 
     727</li> 
     728</ul> 
     729</dd> 
     730<dt>0.1d:</dt> 
    657731<dd><ul class="first last simple"> 
    658732<li><cite>-S</cite> option to explicitly run a python script. uses compiler.compile to 
     
    670744</ul> 
    671745</dd> 
    672 <dt>0.1c</dt> 
     746<dt>0.1c:</dt> 
    673747<dd><ul class="first last simple"> 
    674748<li>Use the parent directory of the top package directory for each explicitly 
     
    679753</dd> 
    680754</dl> 
    681 <p>0.1b</p> 
     755<p>0.1b:</p> 
    682756<blockquote> 
    683757<ul class="simple"> 
  • pyrun/trunk/pyrun.py

    r792 r793  
    884884 
    885885OPTIONS_runex=[ 
    886 ('--log-level', dict(default=False)), 
     886('--log-level', dict(default='WARNING', metavar='LEVEL', help= 
     887"""[default:%default] set the logging level, any string which names 
     888a log level which is defined by the logging package is allowed. 
     889For example any of CRITICAL, WARNING, INFO and DEBUG (in 
     890increasing order of verbosity)""")), 
    887891('-q', dict(default=False, action='store_true', metavar='QUIET', help= 
    888892"""Suppress all warnings about missing paths etc. Useful when you are 
     
    914918 
    915919('-d', dict(default=False, action='store_true', metavar='DEBUG', help= 
    916 """DEBUG session. Prepare for execution, but start a pdb session using 
    917 `pdb.set_trace`.""")), 
     920"""DEBUG session. Use `pdb.runeval` on the module code in order to enter 
     921an interactive debug session at the first python statement of the 
     922target module""")), 
    918923 
    919924('-D', dict(default=False, action='store_true', metavar='DEBUG', help= 
     
    929934 
    930935('-x', dict(default="", metavar='EXCLUDE', help= 
    931 """Exclude one or more directorys, seperated by "%s", from the discovery 
     936"""Exclude one or more directories, separated by "%s", from the discovery 
    932937path.""" % os.pathsep)), 
    933938('-X', dict(default=[], metavar='PRUNE', action="append", type="string", help= 
    934939"""Prune all paths which contain this value from the set of paths which *were* 
    935 discovered. Specify multiple -X options if you whish too prune based on 
     940discovered. Specify multiple -X options if you wish too prune based on 
    936941more than one string.""")) 
    937942