RE: [spambayes-dev] Mac OS X package
New to the list, and pretty new to spambayes. I've put together a package for easy installation of spambayes on Mac OS X. Posted it on the wiki; http://www.entrian.com/sbwiki/MacOSXPackage
Cool, thanks!
However, the utilities (such as which_db etc) still look for the libs in /System/Library/Python.framework/... and don't find them (obviously).
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 ~/.spambayes. What's the "correct" place with OS X? (Note that this includes the bayescustomize.ini file (prefs), as well as the two databases, and the cache directories (user data), so it could be quite big). Does anyone know if there's a way to get the path to this, like the win32all function that provides the "Application Data" directory?
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...?
The way it works is that all the scripts look for a bayescustomize.ini file - they look in an environment variable (BAYESCUSTOMIZE), in ~ (for .spambayesrc) and in the current working directory. If that's found, then all default file locations are relative to that. If it's not found then (unless win32 as above) the current working directory is used as a default location, and everything is relative to that. I suspect that in your testing, you had a bayescustomize.ini file in your scripts directory, and not elsewhere, which would explain the differing behaviour.
And also, am I breaching the license by leaving them out?
The license pretty much lets you do whatever you want with the code, although IANAL. =Tony Meyer --- Please always include the list (spambayes@python.org) in your replies (reply-all), and please don't send me personal mail about SpamBayes. This way, you get everyone's help, and avoid a lack of replies when I'm busy.
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 (obviously).
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 ~/.spambayes.
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. -- Kenny Pitt
>> There has been some discussion (although it's not the case yet) of >> making Linux default to creating a .spambayesrc file in ~, or maybe >> ~/.spambayes. >> >> What's the "correct" place with OS X? Kenny> OS X is a Unix-derivative, so I think "~" should refer to the Kenny> user's home directory just like on Linux. Skip would know for Kenny> sure. Yes, as long as you call os.path.expanduser() on the string. Skip
Ok, after a bit talking to the maintainer of the package list Thomas Juntunen pointed me to, and some exploration of my own I've discovered a few things. One thing to clarify, when I say package, I mean an installer pkg for Mac OS X Installer; not a python package/module (I hadn't realised there were python packages and we might be talking at cross-purposes).
Just for completeness, I thought I'd mention the MacPython PackageManager contains a spambayes package (version 1.0a7, IIRC) that will install automatically and try to satisfy any dependencies. The maintainers may be interested in what you're doing.
MacPython: http://homepages.cwi.nl/~jack/macpython/
To get the spambayes package, you need to use Bob Ippolito's extended package database: http://undefined.org/python/pimp/
HTH, Thomas Juntunen
Briefly, Mac OS X has a layout where /System/Library is for system level installs, frameworks etc, the /Library which is for global user level installs, and finally each user has ~/Library for personal installs. First off, the layout of Python on Mac OS X (10.3) seems insane to me; the framework for python is installed in /System/Library, which is fine for system level things, however instead of modifying Python's sys.path to include a user level install point in /Library (which would be the standard place) or just installing in /Library in the first place, they've symlinked site-packages in the lib directory in the /System/Library install point to /Library/Python/2.3/, so sys.path only contains references to /System/Library. I don't understand why this has been done, when a .pth could have just used to map to a user level install dir in /Library for the search path, it seems to just make a confusing file structure.
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".
Anyway, I think what I'll do is keep the spambayes install where it is (/Library/SpamBayes) and put a .pth file into the system python install so the modules are accessible by everything else (and then the utilities should work).
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 ~/.spambayes.
What's the "correct" place with OS X? (Note that this includes the bayescustomize.ini file (prefs), as well as the two databases, and the cache directories (user data), so it could be quite big). Does anyone know if there's a way to get the path to this, like the win32all function that provides the "Application Data" directory?
As for the config file, at the moment it defaults to /Library/SpamBayes, which is the install point for all user config files as well. This was a work-around for the moment as I'm not sure how to get the data files for each user to be recognised by spambayes depending on who is logged in. spambayes is running as daemon as root, so how would the different user config files be loaded? As for the actual install location, you could use ~/.spambayes or ~/.spambayesrc. But it would probably be considered 'nicer' to put them somewhere easily accessible by non-commandline users though, so ~/Library/SpamBayes would probably be a good place. (p.s. Mac OS X is _not_ case sensitive like other unices, so don't mind my odd naming too much :0) -- Sam So long, and thanks for all the fish.
participants (4)
-
Kenny Pitt -
Sam Thorne -
Skip Montanaro -
Tony Meyer