[Pythonmac-SIG] making a C extension compatible across OS versions?

Bob Ippolito bob at redivi.com
Thu May 26 22:42:37 CEST 2005


On May 26, 2005, at 11:56 AM, has wrote:

> Nicholas Riley wrote:
>
>
>>> Obviously the extension needs to be built on Tiger to provide sdef
>>> support, but what should I do to ensure that, say, applications
>>> containing that binary extension will still work OK when run on
>>> earlier OSes?
>>>
>>
>> You can use weak linking if you don't need to support 10.1.x or
>> earlier,
>>
>
> Ah, thanks. nm says OSACopyScriptingDefinition is weak, so I've  
> added the appropriate 'OSACopyScriptingDefinition != NULL' check to  
> OSATerminology.c and recompiled it for Tiger's Apple-installed  
> Python. No problems using it there there, of course, but I do get  
> the following (unrelated) error when trying to import it into user- 
> installed Python 2.3.5 on 10.2.8 (I don't have a copy of Panther so  
> dunno if it works on that):
>
> ImportError: Failure linking new module: /usr/lib/libmx.A.dylib:  
> dyld: /Library/Frameworks/Python.framework/Versions/2.3/Resources/ 
> Python.app/Contents/MacOS/Python can't open library: /usr/lib/ 
> libmx.A.dylib  (No such file or directory, errno = 2)
>
> Any ideas? (Source and binary are at <http://freespace.virgin.net/ 
> hamish.sanderson/osat.dmg.gz> if it's any help.)

Well that error is solvable, but Tiger's python links extensions with  
a linker flag that Jaguar does not understand -- so, it's time to  
give up.  It's possible to compile on 10.2.8 and make it work on  
10.4, but you're opening the door to an interpreter mismatch because  
it's (a) linking directly to Python and (b) linking directly to the  
WRONG python.. it will work, by accident, unless the user has a user- 
installed Python 2.3, in which case it will explode.

It's possible but very difficult to use a user-installed Python 2.3.5  
on Tiger and compile an extension that will work on Jaguar.. I don't  
have the time to explain the gory details and I don't want to support  
doing that.

In other words, compile everything on the least common denominator,  
period.  Provide separate binaries for 10.2 and 10.3+ (if you still  
care about 10.2, which you probably shouldn't).

-bob



More information about the Pythonmac-SIG mailing list