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

Bob Ippolito bob@redivi.com
Mon, 14 Apr 2003 06:56:01 -0400


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

They'd have to be pretty crazy if they renamed the framework to 
something else.  Does site.py get loaded if the interpreter is embedded 
in another app?  If so, that potentially cause the os.path to miss...  
but you might not care if you're embedding python(?).

-bob