Changeset 791

Show
Ignore:
Timestamp:
08/19/07 10:59:28 (1 year ago)
Author:
robin
Message:

.pth file support

Files:

Legend:

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

    r790 r791  
    33 
    440.1.1: 
     5  * Added support for including .pth files in the discovery phase. This 
     6    makes it possible to insert paths to directories which do not contain 
     7    an __init__.py or are the dirname() of an explicitly referenced module 
     8    file. 
    59  * bugfix: propagate source file name (or sensibly invented filename) to 
    610    the __file__ attribute of the code instance that becomes our __main__ 
  • pyrun/trunk/examples/examples-as-tests.txt

    r783 r791  
    66  # or 
    77  cd pyrun-trunk 
    8   python pyrun.py -S `which nosetests` lib/ -v --with-doctest --doctest-extension=.rst -w examples/ 
     8  python pyrun.py -C `which nosetests` lib/ -v --with-doctest --doctest-extension=.rst -w examples/ 
    99  
    1010 
  • pyrun/trunk/pyrun.py

    r790 r791  
    66 
    77from os.path import join, dirname, basename, isfile, isdir, exists 
     8from os.path import splitext 
    89 
    910have_runpy=False 
     
    353354        if not exists(a): 
    354355            doesnotexist.append(a) 
     356 
     357        # Support .pth files but *dont* recurse. 
     358        # - we do not treat the directory containing the .pth file as though 
     359        #   it was a python site directory. 
     360        #   (See: http://docs.python.org/inst/search-path.html) 
     361        # - we ignore any entry in the .pth file that does not identify 
     362        #   a file or directory (ie, setuptools style import tricks do not 
     363        #   get eval'd) 
     364        # Note: that any findpaths which were encountered before the .pth file 
     365        # will appread in sys.path *before* the paths in the path file.  Also 
     366        # note that using a .pth file is the only currently supported way to 
     367        # inject a directory onto the path which is not either an egg or a 
     368        # module or a toplevel package directory. 
     369        elif isfile(a) and splitext(a)[1] == '.pth': 
     370            if findpaths: 
     371                newpaths = find_package_paths(pth=pthset, 
     372                    *findpaths 
     373                    ) 
     374                pthextend.extend(newpaths) 
     375                findpaths[:] = [] 
     376            pthextend.extend(ln.strip() for ln in file(a) 
     377                    if exists(ln.strip()) 
     378                    ) 
     379            continue 
    355380 
    356381        minfo = path_pkg_moduleinfo(a)