<div dir="ltr">In a couple of my projects, we check for flags by compiling little test files -- autotools style -- to check for SSE, OpenMP, etc. See e.g. <a href="https://github.com/rmcgibbo/mdtraj/blob/master/setup.py#L215">https://github.com/rmcgibbo/mdtraj/blob/master/setup.py#L215</a><div>
<br></div><div>If anyone has a better solution, I'm all ears.</div><div><br></div><div>-Robert</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 12, 2014 at 12:24 PM, Matthew Brett <span dir="ltr"><<a href="mailto:matthew.brett@gmail.com" target="_blank">matthew.brett@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm sorry to ask this, I guess I should know - but is there any way in<br>
disutils or numpy distutils to check whether a compiler flag is valid<br>
before doing extension building?<br>
<br>
I'm thinking of something like this, to check whether the compiler can<br>
handle '-fopenmp':<br>
<br>
have_openmp = check_compiler_flag('-fopenmp')<br>
flags = ['-fopenmp'] if have_openmp else []<br>
<br>
ext = Extension('myext', ['myext.c'],<br>
                          extra_compile_args = flags,<br>
                          extra_link_args = flags])<br>
<br>
I guess this would have to go somewhere in the main setup() call in<br>
order to pick up custom compilers on the command line and such?<br>
<br>
Cheers,<br>
<br>
Matthew<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>
</blockquote></div><br></div>