Changeset 793
- Timestamp:
- 08/19/07 15:43:56 (1 year ago)
- Files:
-
- pyrun/trunk/ChangeLog (modified) (1 diff)
- pyrun/trunk/command_line_interface.rst (modified) (1 diff)
- pyrun/trunk/pkg-info.rst (modified) (1 diff)
- pyrun/trunk/pyrun.html (modified) (8 diffs)
- pyrun/trunk/pyrun.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pyrun/trunk/ChangeLog
r792 r793 4 4 0.1.1: 5 5 * 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 20 23 * Decided to use logging instead of print for notification, I had avoided 21 24 this previously because I did not want to polute the logging configuration pyrun/trunk/command_line_interface.rst
r783 r793 13 13 14 14 Options: 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 1 1 :License: MIT 2 2 :Name: pyrun 3 :Version: 0.1.1 dev3 :Version: 0.1.1b1 4 4 :Author: Robin Bryce 5 5 :Author-email: robinbryce@gmail.com pyrun/trunk/pyrun.html
r785 r793 300 300 </tr> 301 301 <tr><th class="docinfo-name">Version:</th> 302 <td>0.1 </td></tr>302 <td>0.1.1b1</td></tr> 303 303 <tr><th class="docinfo-name">Author:</th> 304 304 <td>Robin Bryce</td></tr> … … 454 454 <kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></td> 455 455 <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> </td><td>[default:WARNING] set the logging level, any string which 460 names a log level which is defined by the logging package 461 is allowed. For example any of CRITICAL, WARNING, INFO 462 and 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 466 when you are using speculative paths and are using -p or 467 -P to print the discoverd path.</td></tr> 456 468 <tr><td class="option-group"> 457 469 <kbd><span class="option">-p</span></kbd></td> … … 459 471 <tr><td class="option-group"> 460 472 <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 474 format</td></tr> 462 475 <tr><td class="option-group"> 463 476 <kbd><span class="option">-n</span></kbd></td> 464 <td>NORUN. Don't run any of the modules implied by module file465 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 not469 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 to473 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 478 file 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 482 not have file extension but it must contain leagal python 483 code. This option trumps -m. This option should only be 484 necessary when the launcher for the python program you 485 wish to run contains significant functionality. No 486 additions are made to the discovery path or sys.path as a 487 result of using this option. If the target script imports 488 a related package you will need to include additional non 489 option arguments to discover its path.</td></tr> 477 490 <tr><td class="option-group"> 478 491 <kbd><span class="option">-m <var>MODULE</var></span></kbd></td> … … 480 493 <tr><td class="option-group"> 481 494 <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 496 order to enter an interactive debug session at the first 497 python statement of the target module</td></tr> 484 498 <tr><td class="option-group"> 485 499 <kbd><span class="option">-D</span></kbd></td> 486 <td>POSTMORTEM debugging. If the target raises an exception, start487 a postmortem pdb debugging session.</td></tr>500 <td>POSTMORTEM debugging. If the target raises an exception, 501 start a postmortem pdb debugging session.</td></tr> 488 502 <tr><td class="option-group"> 489 503 <kbd><span class="option">-i</span></kbd></td> … … 491 505 <tr><td class="option-group"> 492 506 <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 508 in 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 ":", from 512 the 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 516 paths which <em>were</em> discovered. Specify multiple -X 517 options if you wish too prune based on more than one 518 string.</td></tr> 499 519 </tbody> 500 520 </table> … … 654 674 <h1><a class="toc-backref" href="#id5" id="changelog" name="changelog">ChangeLog</a></h1> 655 675 <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 682 directory 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 685 one of the strings specified by a prune is removed from the discovered 686 path.</li> 687 </ul> 688 </dd> 689 </dl> 690 <p>exclusion hides directories from the discovery process, prune removes 691 results after the fact. 692 exclusions are enabled by -x 693 prunes are enabled by -X 694 empty 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 696 exclusion path to be explicitly added back in: All explicitly identified 697 python 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 700 this previously because I did not want to polute the logging configuration 701 of the target app. I consider this change provisional, if it causes to 702 much 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 705 makes it possible to insert paths to directories which do not contain 706 an __init__.py or are the dirname() of an explicitly referenced module 707 file.</p> 708 </li> 709 <li><p class="first">bugfix: propagate source file name (or sensibly invented filename) to 710 the __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 715 simpler target debugging. May consider introducing an "eager" -d variant 716 that 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 719 manaully 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 726 suppreses the warnings</p> 727 </li> 728 </ul> 729 </dd> 730 <dt>0.1d:</dt> 657 731 <dd><ul class="first last simple"> 658 732 <li><cite>-S</cite> option to explicitly run a python script. uses compiler.compile to … … 670 744 </ul> 671 745 </dd> 672 <dt>0.1c </dt>746 <dt>0.1c:</dt> 673 747 <dd><ul class="first last simple"> 674 748 <li>Use the parent directory of the top package directory for each explicitly … … 679 753 </dd> 680 754 </dl> 681 <p>0.1b </p>755 <p>0.1b:</p> 682 756 <blockquote> 683 757 <ul class="simple"> pyrun/trunk/pyrun.py
r792 r793 884 884 885 885 OPTIONS_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 888 a log level which is defined by the logging package is allowed. 889 For example any of CRITICAL, WARNING, INFO and DEBUG (in 890 increasing order of verbosity)""")), 887 891 ('-q', dict(default=False, action='store_true', metavar='QUIET', help= 888 892 """Suppress all warnings about missing paths etc. Useful when you are … … 914 918 915 919 ('-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 921 an interactive debug session at the first python statement of the 922 target module""")), 918 923 919 924 ('-D', dict(default=False, action='store_true', metavar='DEBUG', help= … … 929 934 930 935 ('-x', dict(default="", metavar='EXCLUDE', help= 931 """Exclude one or more director ys, seperated by "%s", from the discovery936 """Exclude one or more directories, separated by "%s", from the discovery 932 937 path.""" % os.pathsep)), 933 938 ('-X', dict(default=[], metavar='PRUNE', action="append", type="string", help= 934 939 """Prune all paths which contain this value from the set of paths which *were* 935 discovered. Specify multiple -X options if you w hish too prune based on940 discovered. Specify multiple -X options if you wish too prune based on 936 941 more than one string.""")) 937 942