
On 19 Sep, 2007, at 19:23, Ian Bicking wrote:
Ronald Oussoren wrote:
On Wednesday, September 19, 2007, at 07:26AM, "Ian Bicking" <ianb@colorstudy.com
wrote:
It is in the python.org source tree: Modules/getpath.c That's the file used in the Framework build of Python? I only see some small references to __APPLE__, none of which seem related to Frameworks. Also, if you build Python from source it works fine -- it's only the python that Apple ships that has the problem. They must use some patched version of this file that they use...? Start reading at line 694 in Modules/getpath.c, that's in the head of the release25-maint branch.
It's only 695 lines long...?
Oops, I've only been using vi for a decade or so... Luckily you found the right bit anyway ;-)
At line 458 it seems like it is looking for lib/python2.5/os.py, in some Framework-specific code. It will look relative to the binary, but only after looking in the Framework first. Simply breaking the Framework lookup somehow would do it.
Here's the code to find the Framework locations:
pythonModule = NSModuleForSymbol(NSLookupAndBindSymbol("_Py_Initialize")); /* Use dylib functions to find out where the framework was loaded from */ buf = (char *)NSLibraryNameForModule(pythonModule);
I'm not sure how to do anything to that though.
I don't think you can. What you can do create the directory structure for a framework inside the virtual python environment, including a copy of the actual shared library, then copy a minimal subset of the stdlibrary into that (anything you need for your custom site.py) and have that site.py build the correct sys.path. You must then copy sys.executable into the virtual python environment as well and use macholib to rewrite the link command for the python framework from /Library/Frameworks/Python.framework/... to @executable_path/../Frameworks/Python.framework/.... This should ensure that the right shared library is loaded and your environment works as you want. You could also ship with the sources to the command-line interpreter and build that with the right LDFLAGS during installation of the virtual-python package. Ronald
-- Ian Bicking : ianb@colorstudy.com : http://blog.ianbicking.org : Write code, do good : http://topp.openplans.org/careers