I have a Python C ++ extension that requires the following compilation flags when compiling using clang on OSX:
CPPFLAGS='-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.8' LDFLAGS='-lc++'
Finding OSX in my setup.py file is quite simple. I can do it:
if sys.prefix == 'darwin': compile_args.append(['-mmacosx-version-min=10.8', '-stdlib=libc++']) link_args.append('-lc++')
(See https://github.com/honnibal/spaCy/blob/ba1d3ddd7f527d2e6e41b86da0f2887cc4dec83a/setup.py#L70 for full context)
However, in GCC, this compilation flag is invalid. Thus, compilation will fail if someone tries to use GCC on OSX, if I write setup.py in this way.
GCC and clang support different compiler flags. So, I need to know which compiler will be called so that I can send various flags. How to correctly determine the compiler in the setup.py file?
Change 1:
Note that the Python exception does not occur for compilation errors:
$ python setup.py build_ext --inplace running build_ext building 'spacy.strings' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -c spacy/strings.cpp -o build/temp.linux-x86_64-2.7/spacy/strings.o -O3 -mmacosx-version-min=10.8 -stdlib=libc++ gcc: error: unrecognized command line option '-mmacosx-version-min=10.8 gcc: error: unrecognized command line option '-stdlib=libc++ error: command 'gcc' failed with exit status 1 $
source share