Stefan Behnel | 1 May 11:21 2012

Re: [Cython] [cython-users] Conditional import in pure Python mode

>>> On 29 April 2012 01:33, Ian Bell wrote:
>>>> idiom like
>>>> if cython.compiled:
>>>>     cython.import('from libc.math cimport sin')
>>>> else:
>>>>     from math import sin

Actually, in this particular case, I would even accept a solution that
special cases the "math" module internally by automatically cimporting
libc.math as an override (or rather an adapted version as plain "math.pxd").

This CEP describes a general approach:

It's partly outdated, so things may have become easier these days.