如何在Python3 setup.py脚本中删除或更改“distutils”使用的默认编译标志?
有时候,有一些我不想使用distutils的编译器标志。
对于这个问题,我正在寻找一个答案要么强制使用一组编译器标志(即我设置的那些),或删除distutils想要使用的标志。
我的代码:
#!/usr/bin/env python3
# python3 setup.py build_ext --inplace
"""Distutils setup file for building C-based modules"""
from distutils.core import Extension, setup
__author__ = 'Devyn Collier Johnson'
__email__ = 'DevynCJohnson@Gmail.com'
__url__ = 'http://dcjtech.info/'
__copyright__ = 'LGPLv3'
__version__ = '2015.11.21'
COMPILE_ARGS = [
'-std=c11',
'-O3',
'-Wl,-O3',
'-gtoggle',
'-g0',
'-funroll-loops',
'-pipe',
'-ffunction-sections',
'-fdata-sections',
'-Wall',
'-pedantic',
]
__classifiers__ = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',
'Operating System :: Android',
'Operating System :: BeOS',
'Operating System :: iOS',
'Operating System :: MacOS',
'Operating System :: Microsoft',
'Operating System :: Other OS',
'Operating System :: POSIX',
'Operating System :: Unix',
'Programming Language :: C',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development :: Libraries',
]
setup(
name='chemistry',
version=__version__,
description='Chemistry-related Functions',
author=__author__,
author_email=__email__,
maintainer=__author__,
maintainer_email=__email__,
url=__url__,
license=__copyright__,
classifiers=__classifiers__,
ext_modules=[Extension(
'chemistry',
sources=['pychemistry.c', 'chemistry.c'],
extra_compile_args=COMPILE_ARGS,
)],
)
setup.py的当前输出:
running build_ext
building 'chemistry' extension
creating build
creating build/temp.linux-x86_64-3.4
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c pychemistry.c -o build/temp.linux-x86_64-3.4/pychemistry.o -std=c11 -O3 -Wl,-O3 -gtoggle -g0 -funroll-loops -pipe -ffunction-sections -fdata-sections -Wall -pedantic
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c chemistry.c -o build/temp.linux-x86_64-3.4/chemistry.o -std=c11 -O3 -Wl,-O3 -gtoggle -g0 -funroll-loops -pipe -ffunction-sections -fdata-sections -Wall -pedantic
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/pychemistry.o build/temp.linux-x86_64-3.4/chemistry.o -o /media/collier/PROGRAMMING/pybooster/lib/chemistry.cpython-34m.so