I want to compile a C++ extension for Python. The problem is that the C++ program only works in x86_64 architecture but the default compile flags include -arch i386.
The setup.py looks like:
from distutils.core import setup, Extension
integral_ext = Extension('mod._mod',
sources = ['wrap.cpp'],
extra_compile_args = ['-mmacosx-version-min=10.7', '-std=c++11', '-stdlib=libc++'])
setup(
ext_modules = [integral_ext],
)
During compiling, the terminal shows that the command is:
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c wrap.cpp -o build/temp.macosx-10.6-intel-3.6/wrap.o -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++
This would fail due to some static_assert code inside the C++ to require x86_64. I can successfully compile it by command line after removing the -arch i386 flag. However, I am writing a library for others to use and I want to make it simple so that users can install it by the standard way of running python3 setup.py install.
The bottom line is, I cannot change the C++ file and I want to do something inside this setup.py to make it compile. Thanks!
Aucun commentaire:
Enregistrer un commentaire