[spambayes-dev] Mac OS X package
kennypitt at hotmail.com
Wed Feb 25 09:30:22 EST 2004
Tony Meyer wrote:
>> However, the utilities (such as which_db etc) still look for the libs
>> in /System/Library/Python.framework/... and don't find them
> They should look for them wherever the config file says they are. A
> question is where the config file should default, to, though. On
> Windows, a bayescustomize.ini file is created in the "Application
> Data" directory, so everything defaults to being relative to that.
> There has been some discussion (although it's not the case yet) of
> making Linux default to creating a .spambayesrc file in ~, or maybe
> What's the "correct" place with OS X?
OS X is a Unix-derivative, so I think "~" should refer to the user's
home directory just like on Linux. Skip would know for sure.
>> the utilities, but I'm still wondering why everything else checks the
>> current directory first and then elsewhere for it's modules etc. when
>> the testtools and utilities don't...?
I read this issue a little differently than Tony, I think. It sounded
to me like you were having trouble with Python finding the imported
modules, so I'll respond to that since Tony has already done a great job
describing the configuration and data file stuff.
Every Python installation has a default location where it searches for
all the standard library modules that come with the Python distribution.
Sounds like for you it is "/System/Library/Python.framework/". One way
to make sure that all SpamBayes apps can find the SB library modules is
to install the "spambayes" folder and all of its contents under this
default library path. This is what the setup.py script in the root of
the SpamBayes distribution does if you run "python setup.py install".
There is also an environment variable, PYTHONPATH, that you can set to a
list of additional directories to search for library modules. This is
most often used during development so that apps can be tested from the
source tree before they are installed into the default path.
Another way that is used by some of the SpamBayes scripts is to directly
manipulate the "sys.path" variable at the start of the Python script.
Python doesn't default to looking for modules in the current directory,
but some of the scripts force this by adding the current working
directory to sys.path when they run. This method is somewhat fragile
and relies on two things: you have to maintain the exact directory
structure from the SpamBayes distribution, and you have to run the
script with your working directory set to the directory containing the
script file. You will also find that not all of the scripts handle this
the same way, especially those in the utilities and testtools
directories that are used mostly for development and testing.
More information about the spambayes-dev