Python - *.pth files -- can't get it to work

Hello,

I'm build a Python application at /home/www/

I'd like to put modules that I can import into my application in /home/www/stuff/bin,
say something like /home/www/stuff/bin/myModule.py, where myModule.py is:

def myModule():
print "This is my module."

To import myModule into my application I thought that I could add a file, say, www.pth, to /usr/lib/Python2.3/site-packages with the content /home/www/stuff/bin, but it doesn't work.

1) What am I doing wrong?
2) Is there a better (more Python-like) way to accomplish my goal; e.g. keep application specific modules in the directory structure of my application, yet still be able to import them?

The books (O'Reilly's "Learning Python," and "Python in a Nutshell," among others) and the web seem rather vague on this topic. I've also read the comments in site.py, but that hasn't helped either.

I know that ultimately I need to add my module directory to PYTHONPATH. But I'm don't even understand how to do this manually, much less with the help of a *.pth file.

I suppose my deeper questions is:

3) What's the best way to set up and configure a directory structure for non-trivial Python application?

Many thanks,

Lloyd

0

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Python - *.pth files -- can't get it to work

I am not able to reproduce your problem.

Syndicate content