[Numpy-discussion] numpy.distutils, lapack, and cython

Robert Kern robert.kern at gmail.com
Fri Sep 28 13:45:56 EDT 2012

On Fri, Sep 28, 2012 at 9:45 AM, Nathaniel Smith <njs at pobox.com> wrote:
> Hi all,
> I've gotten a pull request for scikits-sparse to switch it to using
> numpy.distutils:
>   https://github.com/njsmith/scikits-sparse/pull/2
> Overall this seems fair enough, finding libraries is a pain and
> numpy.distutils has that knowledge.
> 1) What's the proper way to find lapack using numpy.distutils? The
> patch tries lapack_mkl_info and lapack_info, but this is 2 of the 6
> variants that my numpy.distutils.system_info contains. Really what I
> probably want is a way to ask numpy how it was built (including any
> custom paths the user used) and to default to doing the same? Is that
> possible?

You can get some of that information from the generated
numpy.__config__ module (see its show() and get_info() functions). I'm
not sure if that includes custom paths that were hacked in by the user
by editing the setup.py files, but I think it includes custom paths
specified in the site.cfg that the builder used. Of course, if one
installed numpy using a binary built on another machine, it is
possible for that information to be not applicable to the current

I believe that you want to use 'lapack_opt' as the most generic
optimized LAPACK build information. That should dispatch to the
vendor-specific ones if they are present, I think. It's what
numpy.linalg and scipy.linalg do. I have rather blissfully forgotten
such details, so you may want to do some digging of your own.

> 2) Is there a better way to build Cython files than this weird
> monkey-patching thing they propose? (It's still better than the horror
> that setuptools/distribute require, but I guess I have higher
> expectations...)

Sadly, probably not. numpy.distutils is not much less horrifying than

Robert Kern

More information about the NumPy-Discussion mailing list