[Pythonmac-SIG] sys.path for MacPython 2.3 - next set of questions

Jack Jansen Jack.Jansen@cwi.nl
Mon, 14 Apr 2003 11:54:43 +0200


I think I'm going to go for ~/Library/Python/2.3/site-packages, i.e. 
scream loudly
if you *really* don't agree.

There are going to be more directories in there:
~/Library/Python/2.3/IDE-scripts   - Stuff for the IDE scripts menu
~/Library/Python/2.3/packman       - Where pimp downloads and install 
dirs live

These directories are only going to be used in a framework build. If 
non-framework
grows similar functionality later it will have to use a different name 
for
the site-packages because extension modules are incompatiple.

I'm going to punt on /Library/Python for now. It doesn't offer any new 
functionality
over $prefix/lib/python2.3/site-packages, it would only be included for
completeness. Maybe we can do it with a symlink or something later on.
/Network/Library/Python can also wait.

But there are two more important questions that I don't have an answer 
to, yet.

1. Who adds ~/Library/Python/2.3/site-packages to sys.path, and when?
2. Who creates ~/Library/Python/2.3/site-packages, and when?

Neither of these is obvious. For (1) the main candidate is site.py,
but we only want to add it when we are running from a framework. Which
means we have to import MacOS. And that's a dynamically loaded module,
so it's not cheap. Should I care about this? And, if I should, any good 
ideas
for testing whether we're in a framework install, anyone?

For (2) I think either site.py or the IDE are the best choices. Note 
that this
can't be done on installation, we're catering explicitly for the 
situation where
admin user A has installed Python, and normal user B starts using it 
and wants to
install her own extension modules. Site.py has the advantage that it'll 
also
work for users only using the command line, but if creating the 
directory fails
either it has to fail silently (leading to confusion) or you get ugly 
messages
for every Python program run. For that reason I'm slightly in favor of
doing it in the IDE. Probably distutils and pimp should also create it 
when needed.

If we don't create the directory in site.py then there's an extra 
question: should
it be added if it doesn't exist? I think it shouldn't, the only 
disadvantage would
be that if you run the IDE for the first time and immediately install 
something
with the Package Manager it will have to warn you to restart the IDE. 
Or the IDE
has to add it manually when creating it.
--
Jack Jansen, <Jack.Jansen@cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman