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


Groups > comp.lang.python > #12271 > unrolled thread

Understanding .pth files

Started byJosh English <Joshua.R.English@gmail.com>
First post2011-08-27 09:42 -0700
Last post2011-08-28 10:32 -0600
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Understanding .pth files Josh English <Joshua.R.English@gmail.com> - 2011-08-27 09:42 -0700
    Re: Understanding .pth files Ian Kelly <ian.g.kelly@gmail.com> - 2011-08-28 10:32 -0600

#12271 — Understanding .pth files

FromJosh English <Joshua.R.English@gmail.com>
Date2011-08-27 09:42 -0700
SubjectUnderstanding .pth files
Message-ID<5cc361da-b1e3-47eb-b4e2-b6d92b350fb2@glegroupsg2000goo.googlegroups.com>
I am developing a library for Python 2.7. I'm on Windows XP. I am also learning the "proper" way to do this (per PyPi) but not in a linear fashion: I've built  a prototype for the library, created my setup script, and run the install to make sure I had that bit working properly.

Now I'm continuing to develop the library alongside my examples and applications that use this library.

The source is at c:\Dev\XmlDB.
The installed package in in c:\Python27\lib\site-packages\xmldb\

According to the docs, I should be able to put a file in the site-packages directory called xmldb.pth pointing anywhere else on my drive to include the package. I'd like to use this to direct Python to include the version in the dev folder and not the site-packages folder.

(Otherwise I have my dev folder, but end up doing actual library development in the site-packages folder)

So my C:\Python27\lib\site-packages\xmldb.pth file has one line:

c:\dev\XmlDB\xmldb

(I've tried the slashes the other way, too, but it doesn't seem to work).

Is the only solution to delete the installed library and add the dev folder to my site.py file?

Josh

[toc] | [next] | [standalone]


#12345

FromIan Kelly <ian.g.kelly@gmail.com>
Date2011-08-28 10:32 -0600
Message-ID<mailman.508.1314549176.27778.python-list@python.org>
In reply to#12271
On Sat, Aug 27, 2011 at 10:42 AM, Josh English
<Joshua.R.English@gmail.com> wrote:
> According to the docs, I should be able to put a file in the site-packages directory called xmldb.pth pointing anywhere else on my drive to include the package. I'd like to use this to direct Python to include the version in the dev folder and not the site-packages folder.

The name of the .pth file is not important.  Python uses it to add
locations to sys.path; it doesn't care what packages might be
contained at those locations.

> So my C:\Python27\lib\site-packages\xmldb.pth file has one line:
>
> c:\dev\XmlDB\xmldb

The final xmldb is the actual package, yes?  The directory in the .pth
file should be one inside which Python can find packages, not a
package itself.  So the file should have just "c:\dev\XmlDB".  Then
when you do "import xmldb", Python will look inside the
"c:\dev\XmlDB", find the xmldb package, and import it.

>
> (I've tried the slashes the other way, too, but it doesn't seem to work).
>
> Is the only solution to delete the installed library and add the dev folder to my site.py file?

The preferred solution here is to use virtualenv to set up your
development environment without having to modify the installed version
in the system site-packages at all.

HTH,
Ian

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web