[Pythonmac-SIG] Where to put one's own packages?
Bob Ippolito
bob at redivi.com
Thu Feb 26 18:33:56 EST 2004
On Feb 26, 2004, at 4:21 PM, Kenneth McDonald wrote:
> I've developed some packages for personal use (and maybe one day
> they'll be mature enough to release). I want to make them generally
> available on my system, so clearly they should go into one of the
> python path directories, presumably the
> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/
> python2.3/site-packages. However, I have a few things I'd like to do
> that can't properly be done with this mechanism, and I'm wondering if
> anyone could provide suggestions.
>
> 1) I prefer to keep all of my own work in my home directory, as I back
> that directory up frequently. However, I can't use a hard link from
> /System/Library/Frameworks/Python.framework/Versions/2.3/lib/
> python2.3/site-packages, and if I use a soft link, the link becomes
> fragile in the case that I move things around in my home directory.
You are correct, but you may also note that site-packages itself is a
symlink to /Library/Python/2.3
> 2) The current default paths seem to imply that every times I install
> a new version of Python, I'll have to reinstall the packages, since
> the package directory includes the python version number in its path.
That is definitely 100% true. Every major upgrade of Python (f.ex 2.2
-> 2.3) is binary incompatible.
It's even worse with current versions of MacPython, due to the
unfortunate way that extensions are linked minor versions are not even
compatible (2.3 -> 2.3.1, for example) unless the framework is located
in the exact same place... so you really just should live with the
Python 2.3.0 that Apple gives you, until OS X 10.4 when we will
hopefully have this issue resolved.
> 3) More generally, why does the python default search path not include
> '/Library/...' and '~/Library/...'. My understanding of the Mac file
> system is that /System/Library really are reserved for Apple stuff.
It does, /Library/Python/2.3 is searched (for reasons mentioned above).
~/Library/Python/2.3/site-packages is also searched.
> I'll probably end up editing the config files to add a couple of
> directories to sys.path on startup--once I remember how :-). But I am
> sorta surprised that sys.path doesn't already include the above
> mentioned dirs, and that everything is hardwired to the 2.3 directory.
there is also a mechanism called pth files that offers a clean solution
to add things to sys.path. I'll leave it as an exercise to the reader
to look up documentation for them.. a good place to start would be
http://pythonmac.org/wiki/FAQ .. if that doesn't answer your question,
there's google and mailing list archives.
-bob
More information about the Pythonmac-SIG
mailing list