Customizing the python search path depending on source directory

Peter Hansen peter at engcorp.com
Fri Apr 9 10:58:53 EDT 2004


Peter Schwalm wrote:
> Peter Hansen <peter at engcorp.com> wrote in message news:<4dudnVzbRvwbyOjdRVn-sw at powergate.ca>...
> 
> I have run the programs with "python <scriptname>.py" now. For my
> purposes the results look identical - the source directory is still
> not accessible during the processing of sitecustomize.py.

Thanks for your persistence, Peter.  I've confirmed what you have
observed here: during site.py processing (including near the end
when "import sitecustomize" is tried) the directory containing the
main script is not included in sys.path.  Immediately after site.py
is imported, sys.path does contain the proper script at the start.

My guess is that recent changes to the import mechanism have broken
this behaviour.

Note that this change would also break sitecustomize processing in
some installations, since it should (I believe) be possible to
have a sitecustomize.py in the directory where the main script
resides, but in Python 2.3.3 it is not imported at all.

If anyone who knows about such things more than we do can confirm
that this should in fact be considered a bug, I will add it to
SourceForge.

-Peter



More information about the Python-list mailing list