[Pythonmac-SIG] Re: Extension module binary compatibility
Bob Ippolito
bob@redivi.com
Thu, 20 Feb 2003 17:48:31 -0500
On Thursday, Feb 20, 2003, at 16:15 America/New_York, John Ehresman
wrote:
> On Thu, 2003-02-20 at 15:39, Bob Ippolito wrote:
>> sys.executable is usually enough to tell if it 's framework or not.
>
> Do you look for the substring "Python.framework" in the path of the
> executable?
>
>> However, there is only one 2.2 non-framework interpreter around that
>> lives in /usr/bin.. so I would only do binary distributions for the
>> /usr/bin python right now. There's at least 3 other pythons around,
>> and you can pretty much let:
>> (a) the people that compiled their own python compile their own
>> modules
>> (b) let the people distributing their own framework python also
>> distribute all of the binary modules for it
>> (c) let fink maintain their own distribution.
>
> But then there are people like myself that compile stuff and put it in
> /usr/local/bin or even somewhere under my home directory (if I didn't
> have root / administrative privileges). I think it's preferable to not
> depend on python being in a particular location because then people can
> have more than one version on their machine; e.g. one with debug
> symbols, one without. Also, it allows people to ship a version of
> python with an application. We do this with Wing so a user on Linux
> who
> only has 2.2 on his/her machine can run Wing without also installing
> python version 1.5.2.
You can depend on Apple Python being at /usr/bin/python, if that's not
Apple python, whoever replaced it broke the rules and deserve to learn
not to do that :).
As I said, leave any other binary distribution of python modules to the
maintainers of the distribution... but if you MUST, you can do
something like this:
# mymodule.py
import sys
_prefix, _ver, _plat = sys.prefix, sys.version[:3], sys.platform
del sys
if sys.platform == 'darwin':
if (2,3,0) <= _ver < (2,4,0):
if _prefix.find('Python.framework') != -1:
from py23framework.mymodule import *
else:
from py23.mymodule import *
elif (2,2,0) <= _ver < (2,3,0):
if _prefix == '/usr':
from py22jaguar.mymodule import *
elif _prefix.startswith('/sw'):
from py22fink.mymodule import *
elif _prefix.find('Python.framework') != -1:
from py22framework.mymodule import *
else:
raise ImportError, "Unknown installation of Python 2.2"
else:
raise ImportError, "Python %d.%d.%d not supported" % _ver
else:
raise ImportError, "This module requires OS X"