Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12276

Re: Understanding .pth in site-packages

Subject Re: Understanding .pth in site-packages
From Philip Semanchuk <philip@semanchuk.com>
Date 2011-08-27 13:18 -0400
References <31bef8dc-d804-454d-85c7-8de1663052a8@glegroupsg2000goo.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.466.1314465528.27778.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 09:56 -0700
  Re: Understanding .pth in site-packages Philip Semanchuk <philip@semanchuk.com> - 2011-08-27 13:18 -0400
    Re: Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 10:57 -0700
      Re: Understanding .pth in site-packages "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-08-27 19:45 +0000
        Re: Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 15:39 -0700
          Re: Understanding .pth in site-packages "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-08-28 05:20 +0000
    Re: Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 10:57 -0700
      Re: Understanding .pth in site-packages Philip Semanchuk <philip@semanchuk.com> - 2011-08-27 14:07 -0400
      Re: Understanding .pth in site-packages Terry Reedy <tjreedy@udel.edu> - 2011-08-27 16:14 -0400
      Re: Understanding .pth in site-packages Philip Semanchuk <philip@semanchuk.com> - 2011-08-27 16:28 -0400
        Re: Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 15:49 -0700
        Re: Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 15:49 -0700
          Re: Understanding .pth in site-packages Philip Semanchuk <philip@semanchuk.com> - 2011-08-27 23:01 -0400
      Re: Understanding .pth in site-packages Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-08-27 13:53 -0700
        Re: Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 15:41 -0700
        Re: Understanding .pth in site-packages Josh English <Joshua.R.English@gmail.com> - 2011-08-27 15:41 -0700
          Re: Understanding .pth in site-packages Stephen Hansen <me+list/python@ixokai.io> - 2011-08-27 16:44 -0700
  Re: Understanding .pth in site-packages Peter Otten <__peter__@web.de> - 2011-08-27 19:29 +0200
  Re: Understanding .pth in site-packages Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-08-27 13:53 -0700

csiph-web