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

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


On Monday, Apr 14, 2003, at 12:56 Europe/Amsterdam, Bob Ippolito wrote:

>
> On Monday, Apr 14, 2003, at 05:54 America/New_York, Jack Jansen wrote:
>
>> 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?
>
> # sys.executable is a /usr/local/bin/python2.3 symlink
> >>> import os, sys
> >>> 'Python.framework' in os.path.realpath(sys.executable)
> True
> >>> 'Python.framework' in sys.executable
> False

This won't work for applets (try it from within the IDE in CVS-Python, 
for instance), which have
sys.executable pointing to a symlink in their .app bundle. And this 
cannot be changed, as it is the
magic that makes the applets connect to the window manager, find their 
resources, etc.
--
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