On Aug 27, 2011, at 12:56 PM, Josh English wrote:

> (This may be a shortened double post)
> 
> I have a development version of a library in c:\dev\XmlDB\xmldb
> 
> After testing the setup script I also have c:\python27\lib\site-packages\xmldb
> 
> Now I'm continuing to develop it and simultaneously building an application 
> with it.
> 
> I thought I could plug into my site-packages directory a file called 
> xmldb.pth with:
> 
> c:\dev\XmlDB\xmldb
> 
> which should redirect import statements to the development version of the 
> library.
> 
> This doesn't seem to work.


xmldb.pth should contain the directory that contains xmldb:
c:\dev\XmlDB

Examining sys.path at runtime probably would have helped you to debug the 
effect of your .pth file.

On another note, I don't know if the behavior of 'import xmldb' is defined when 
xmldb is present both as a directory in site-pacakges and also as a .pth file. 
You're essentially giving Python two choices from where to import xmldb, and I 
don't know which Python will choose. It may be arbitrary. I've looked for some 
sort of statement on this topic in the documentation, but haven't come across 
it yet. 


> Is there a better way to redirect import statements without messing with the 
> system path or the PYTHONPATH variable?

Personally I have never used PYTHONPATH.


Hope this helps
Philip


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to