Tricky question about native extension packaging

Chris Rebert clp2 at
Tue Feb 10 20:46:24 CET 2009

On Tue, Feb 10, 2009 at 8:42 AM,  <olivierbourdon38 at> wrote:
> let's assume I (almost) have and extension available as a C file and
> the and I want to generate from this single c file 2 .so
> files using
> cc -DOPTION1 x.c to produce
> cc -DOPTION2 x.c to produce
> and at runtime depending of my OS version either load x_1 or x_2

I don't know about the part of your question, but as for
choosing between 2 modules at runtime:

#assuming 'foo' is the desired name of the module
from sys import platform
SUN = 'sunos5'
LINUX = 'linux2'
WIN = 'win32'

if platform == SUN:
    from x_1 import *
elif platform == LINUX:
    from x_2 import *
elif platform == WIN:
    from x_1 import *
    raise RuntimeError, "Unknown/unsupported platform"


Follow the path of the Iguana...

More information about the Python-list mailing list