473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

.pth files?

I'm unclear on how .pth files work. Some posts imply they can be
arbitrarily named, as long as they include the .pth extension, and can
exist anywhere in the current sys.path. Other documentation seems to
imply that they must be named <package>.pth, although I'm not sure what
"package" it would be named after.

I used strace to see if I could see which files it was looking for, but
the output didn't show a single attempted stat() or open() of any .pth
files.

I may be barking up the wrong tree with the .pth files, anyway. Is
there a general "best practice" for appending additional directories to
search for modules? Specifically, I frequently write utilities that
depend on a shared module or two that I don't particularly want to
stick in the "site-packages" directory. The layout I generally prefer
is a "lib" dir in the same directory as the assorted scripts. Clearly,
I could just do a 'sys.path.append["./lib"]', but that seems kludgy.

Any clarifications or recommendations?

Thanks!

-Ben

Jul 18 '05 #1
5 1655

Ben> I'm unclear on how .pth files work. Some posts imply they can be
Ben> arbitrarily named, as long as they include the .pth extension, and
Ben> can exist anywhere in the current sys.path. Other documentation
Ben> seems to imply that they must be named <package>.pth, although I'm
Ben> not sure what "package" it would be named after.

<package>.pth naming is just a convention so you can easily sort out the
association for each of multiple pth files. I have a mojam.pth file but no
"mojam" package on my server. Works just fine.

Skip
Jul 18 '05 #2
On Tue, 22 Mar 2005 12:52:28 -0600, Skip Montanaro <sk**@pobox.com> wrote:
<package>.pth naming is just a convention so you can easily sort out the
association for each of multiple pth files. I have a mojam.pth file but no
"mojam" package on my server. Works just fine.


Interesting.

Where does it call home? site-packages?

-Ben
Jul 18 '05 #3
in****@gmail.com wrote:
I'm unclear on how .pth files work. Some posts imply they can be
arbitrarily named, as long as they include the .pth extension, and can
exist anywhere in the current sys.path. Other documentation seems to
imply that they must be named <package>.pth, although I'm not sure what
"package" it would be named after
This is pretty trivial to experiment with. Two minutes
would make it clear that the name of the file is irrelevant.
So would skimming the source in site.py, though I've found
that takes more like five minutes to piece together as it's
not particular self-documenting and has, as I recall, few
helpful inline comments.
I used strace to see if I could see which files it was looking for, but
the output didn't show a single attempted stat() or open() of any .pth
files.
site.py does not look everywhere, just in a specific,
pre-defined, and platform-specific set of folders, again
defined in the source site.py (I think the written docs
on this miss a few cases). It also looks in any folders
that are added to the sys.path as a result of being
found in a .pth file (i.e. the search for .pth files is
basically recursive).
I may be barking up the wrong tree with the .pth files, anyway. Is
there a general "best practice" for appending additional directories to
search for modules? Specifically, I frequently write utilities that
depend on a shared module or two that I don't particularly want to
stick in the "site-packages" directory. The layout I generally prefer
is a "lib" dir in the same directory as the assorted scripts. Clearly,
I could just do a 'sys.path.append["./lib"]', but that seems kludgy.

Any clarifications or recommendations?


Look into sitecustomize.py perhaps? Or PYTHONPATH settings
with a wrapper shell script to set it just for the utilities
in question?

Or do the sys.path.append thing, since it works, is fairly
common practice, and is pretty explicit.

-Peter
Jul 18 '05 #4
On 22 Mar 2005 09:29:39 -0800, "in****@gmail.com" <in****@gmail.com> wrote:
I'm unclear on how .pth files work. Some posts imply they can be
arbitrarily named, as long as they include the .pth extension, and can
exist anywhere in the current sys.path. Other documentation seems to
imply that they must be named <package>.pth, although I'm not sure what
"package" it would be named after.

I used strace to see if I could see which files it was looking for, but
the output didn't show a single attempted stat() or open() of any .pth
files.

I may be barking up the wrong tree with the .pth files, anyway. Is
there a general "best practice" for appending additional directories to
search for modules? Specifically, I frequently write utilities that
depend on a shared module or two that I don't particularly want to
stick in the "site-packages" directory. The layout I generally prefer
is a "lib" dir in the same directory as the assorted scripts. Clearly,
I could just do a 'sys.path.append["./lib"]', but that seems kludgy.

Any clarifications or recommendations?

Thanks!

I haven't looked at all the ("about 23") hits, but have you tried googling for

pth site:python.org/doc

? The first hit looks promising.

(BTW, for your next python question, try some relevant words in place of "pth" before posting ;-)

Regards,
Bengt Richter
Jul 18 '05 #5
>> I have a mojam.pth file but no "mojam" package on my server. Works
just fine.


Ben> Where does it call home? site-packages?

Yup.
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
3
by: pooja | last post by:
Suppose i have created a class c1 with f1()in c1.cpp and included this c1.cpp in file1.cpp file , which is also having main() by giving the statement #include "c1.cpp". the same i can do by...
11
by: ambika | last post by:
Iam just trying to know "c". And I have a small doubt about these header files. The header files just contain the declaration part...Where is the definition for these declarations written??And how...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
0
by: wal | last post by:
How does one attach files to emails using libgmail? The following code http://pramode.net/articles/lfy/fuse/4.txt works fine when said files are simple text files, but it failes as soon as the...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.