[Numpy-discussion] Distutils - way to check validity of compiler flag?

Matthew Brett matthew.brett at gmail.com
Mon May 12 15:24:07 EDT 2014


I'm sorry to ask this, I guess I should know - but is there any way in
disutils or numpy distutils to check whether a compiler flag is valid
before doing extension building?

I'm thinking of something like this, to check whether the compiler can
handle '-fopenmp':

have_openmp = check_compiler_flag('-fopenmp')
flags = ['-fopenmp'] if have_openmp else []

ext = Extension('myext', ['myext.c'],
                          extra_compile_args = flags,
                          extra_link_args = flags])

I guess this would have to go somewhere in the main setup() call in
order to pick up custom compilers on the command line and such?



More information about the NumPy-Discussion mailing list