<div dir="ltr">In the Clawpack projects (specifically the Riemann solvers) we compile against LAPACK and the BLAS using f2py via the `--link-lapack_opt` flag. This does cause some problems in terms of portability though, Aron Ahmadia might be able to shed some light on this as he has looked into it most recently.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 28, 2013 at 5:08 AM, Matt Hoffman <span dir="ltr"><<a href="mailto:hoffmanm@cs.ubc.ca" target="_blank">hoffmanm@cs.ubc.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>I have some fortran code that I would like to build and make accessible from python which needs to call a few BLAS routines. Building it in a one-off manner is not a problem, but I can't seem to find a good way to distribute it in a way that just works.</div>
<div><br></div><div>So really I'm wondering if there is a "correct" way use numpy.distutils in order to link against the same BLAS libraries used by numpy. I'll paste my current approach below, but I'm not sure that this is the best/most-portable way to do it. (And it certainly breaks on MacOS due to the weird way that macs use rpath.)</div>
<div><br></div><div>Anyway my setup contains something like:</div><div><br></div><div><div> from numpy.distutils.core import setup</div><div> from numpy.distutils.system_info import get_info, NotFoundError</div><div>
from numpy.distutils.misc_util import Configuration</div></div><div><br></div><div> sources = ['foo.f']</div><div><div> extra_info = {}</div><div> extra_link_args = []</div><div><br></div><div> try:</div>
<div> extra_info = get_info('mkl', 2)<br></div><div> extra_link_args = ['-Wl,-rpath,'+path for path in extra_info['library_dirs']],</div><div><br></div><div> except NotFoundError:</div>
<div> try:</div><div> extra_info = get_info('blas', 2)<br></div><div> extra_link_args = ['-Wl,-rpath,'+path for path in extra_info['library_dirs']],</div><div><br></div>
<div> except NotFoundError:</div><div> # couldn't find anything. just fall back to building the functions we need ourselves.</div><div> sources += ['ddot.f']<br></div><div><br></div>
<div> config = Configuration()</div><div> config.add_extension(</div><div> sources=sources,<br></div><div> extra_info=extra_info,</div><div> extra_link_args=extra_link_args</div><div> )</div>
</div><div> setup(**config.todict())</div><div><br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div>-matt</div><div><br></div></font></span></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>