Idea: PYTHONPATH_VER
Peter Hansen
peter at engcorp.com
Sat May 15 08:18:16 EDT 2004
Fernando Perez wrote:
> Peter Hansen wrote:
>>Having missed the discussion preceding, I'm probably off the mark,
>>but in my experience just about everything that can be solved with
>>PYTHONPATH can be handled with a .pth file as well, and I haven't
>>had any need to use PYTHONPATH for quite some time as a result.
>
> How do you handle the fact that .pth files are only read from certain places,
> and not others? This problem has me currently rather stuck with gross hacks:
I confess to never having had any particular troubles with it, other
than in trying to use it for adding special other directories during
unit testing, where I had to do "import site; site.addsitedir('.')"
or something close to that at the top of my xxx_test.py file.
> packages like Numeric, which rely on a .pth file instead of being a 'true'
> python package (with __init__.py), are very problematic.
Sorry, haven't used it.
> --home=/usr/local'. The problem is that python does NOT scan this directory
> for .pth files, even if it is listed in PYTHONPATH. .pth files only have an
> effect for directories in sys.prefix, I think.
Actually, I believe it's recursive, in that any directories added during
.pth processing are themselves scanned for .pth files and the new ones
added, and so on.
> I have actually come to HATE with a vengeance packages which rely on .pth files,
> because of this behavior of python of not including them for anything in
> PYTHONPATH. So I would really appreciate pointers from someone who has
> successfully solved this, since it's quite likely that I'm just misusing the
> system.
I'm not sure I've seen a package which *relied* on it, except for
pywin32, and it seems to work very nicely and the .pth file (which
I just had to verify is still there) is pretty much invisible.
I might have some better idea how to deal with it if I'd ever had
trouble with it. One thing to note: I do most development on Windows.
Perhaps, for some reason, the problems are lesser there. (Which would
be a little surprising, but given Linux' issues with installing
software, perhaps not entirely unlikely.)
-Peter
More information about the Python-list
mailing list