On Tue, 26 Feb 2008 03:01:33 -0200
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Sat, 23 Feb 2008 12:52:45 -0200, D'Arcy J.M. Cain <[EMAIL PROTECTED]>  
> escribió:
> > I have more information now.  It seems that it recurses the .pth files
> > it finds in PYTHONPATH but not for directories found in the .pth files
> > in site-packages.  Is this expected behaviour?  The documentation
> > suggests that it should pick up both.
> 
> If a .pth file contains a valid directory, it is added to sys.path but  
> it's not searched for additional .pth files. From  
> http://docs.python.org/lib/module-site.html
> 
>       "A path configuration file is a file whose name has the form 
> package.pth  
> AND EXISTS IN ONE OF THE FOUR DIRECTORIES MENTIONED ABOVE" (emphasis by me)
> 
> (the four directories being .../lib/python2.5/site-packages, site-python,  
> etc.)
> 
> (Mmm, what the 2.5 docs say is not exactly the same as the actual code in  
> site.py, and the version in http://docs.python.org/dev/library/site.html  
> is not the same as the svn version of site.py... anyway, directories added  
> by mean of .pth files are not recursively searched for more .pth files)

But that is not true.  If I add a path by setting PYTHONPATH and there
is a .pth in that directory then it is read and recursively searched
for more .pth files.  It is only when the path is added because it is
in site-packages that it doesn't load the .pth files found.

In http://www.python.org/doc/inst/search-path.html there is
more specific language:

"The most convenient way is to add a path configuration file to a
directory that's already on Python's path, usually to
the .../site-packages/ directory. Path configuration files have an
extension of .pth, and each line must contain a single path that will
be appended to sys.path. (Because the new paths are appended to
sys.path, modules in the added directories will not override standard
modules. This means you can't use this mechanism for installing fixed
versions of standard modules.)

"Paths can be absolute or relative, in which case they're relative to
the directory containing the .pth file. Any directories added to the
search path will be scanned in turn for .pth files. See site module
documentation for more information."

Directories listed in .pth files in site-packages are "added to the
search path" so they should be scanned for more .pth files.

This really smells like a bug in either the code or the docs.  I hope
it is in the code and will eventually be fixed.

-- 
D'Arcy J.M. Cain <[EMAIL PROTECTED]>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to