On Thu, Oct 29, 2009 at 2:42 PM, Wells <we...@submute.net> wrote:
> So I have my project partitioned like so:
>
> ./setup.py
> ./pymlb/
> ./pymlb/fetcher.py
> ./demos
> ./demos/demo.py
>
> In demo.py I have:
>
> from pymlb import fetcher
>
> However, it fails b/c pymlb is up a folder. It's also NOT installed as
> a module in my module directory because it's a development effort and
> I don't want to run setup.py to install them. See what I mean?
>
> What's the work around here?


In order for "from pymlb import fetcher" no work you must make the
'./pymlb' directory into a "package" by adding a file called
__init__.py (it can be empty.)

Then make sure the "top" directory (i.e. '.' in your example) is in
the python PATH.  There are a couple of ways to do that:

1.) Hack it in demo.py before importing fetcher
  (i.e. "import sys; sys.path.append(<string absolute path of '.'>)")

2.) Use the PYTHONPATH environment variable.

3.) Use a .pth file (See http://docs.python.org/library/site.html)
You'll have to figure out what directory to put it in (on my system
'/usr/lib/python2.5/site-packages' works) Note, although it's not
mentioned in the site module docs you can include an absolute path and
it will be added to sys.path.

There is additional good information about .pth files on Bob
Ippolito's blog:
http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-development/
Be sure to read the comments too.

4.) Probably some other method(s) that someone else will tell you...  ;]

HTH,
~Simon
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to