[Pythonmac-SIG] Link against Python Framework

Jason Foreman jason at threeve.org
Fri Sep 11 15:50:36 CEST 2009


On Sep 10, 2009, at 10:29 AM, Jason Foreman wrote:

> On Sep 10, 2009, at 5:09 AM, Georg Seifert wrote:
>>
>> How do I specify the version to link with.
>> The 10.5 SDK links against python 2.5 and the 10.6 SDK to 2.6. But  
>> what if I need the 10.6 SKD but want to link to python 2.5?
>
> I'll try to look for ways to specify a specific framework version to  
> link against and let you know if I find anything.

I did find a way to use the 10.6 SDK but still link with Python 2.5.   
However I'd classify this as a 'dirty hack' so I'm not sure I could  
recommend it.

When the linker is linking to a framework, it expects to find (a link  
to) the framework binary at Foo.framework/Foo (e.g. Python.framework/ 
Python).  In the real framework, this is just a symlink to  
Python.framework/Versions/Current/Python, which is of course the 2.6  
version of Python.

We can exploit the fact that same-named frameworks that exist in a  
user-specified framework search path will be used before the ones in  
system search paths.  What you do is create a Python.framework  
directory in your project (or some subdirectory of it) and link  
Python.framework/Python to /System/Library/Frameworks/Python.framework/ 
Version/2.5/Python.  Then you *should* be able to add this "framework"  
to your project, or do as I did and add "-framework Python" to the  
"Other linker flags" build setting.

I tried this on a little sample project and verified with otool that  
the binary was linked against Python 2.5.

Again, I'm not sure you want to do this, but if you can't find any  
other way to solve your issues this may work for you.


Jason


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20090911/14cc2e2d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2417 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20090911/14cc2e2d/attachment-0001.bin>


More information about the Pythonmac-SIG mailing list