[Numpy-discussion] Supporting both NumPy and Numeric versions of amodule

Konrad Hinsen konrad.hinsen at laposte.net
Fri Jun 16 02:53:48 EDT 2006

> We are using Python's distutils, and I'm trying to figure out if
> there's a way in which I can have both distributions installed to one
> package directory, and then the __init__.py file would try to figure
> out which one to import on behalf of the user (i.e. it would try to
> figure out if the user had already imported NumPy, and if so, import
> the NumPy version of the module; otherwise, it will import the Numeric
> version of the module).
> This is turning out to be a bigger pain than I expected, so I'm
> turning to this group to see if anybody has a better idea, or should I
> just give up and release these two distributions separately?

I think that what you are aiming at can be done, but I'd rather not do it. 
Imagine a user who has both Numeric and NumPy installed, plus additional 
packages that use either one, without the user necessarily being aware of 
who imports what. For such a user, your package would appear to behave 
randomly, returning different array types depending on the order of imports 
of seemingly unrelated modules.

If you think it is useful to have both versions available at the same time, 
a better selection method would be the use of a suitable environment 


More information about the NumPy-Discussion mailing list