如何让Python distutils兑现$CC?
我正在尝试使用Python distutils中的CCompiler功能来编译和执行测试程序。到目前为止,我已经:如何让Python distutils兑现$CC?,python,compiler-construction,distutils,Python,Compiler Construction,Distutils,我正在尝试使用Python distutils中的CCompiler功能来编译和执行测试程序。到目前为止,我已经: from distutils import ccompiler cc = ccompiler.new_compiler() outfiles = cc.compile(['detect.c']) cc.link_executable(outfiles, 'detect') output = subprocess.check_output(['./detect']).decode('
from distutils import ccompiler
cc = ccompiler.new_compiler()
outfiles = cc.compile(['detect.c'])
cc.link_executable(outfiles, 'detect')
output = subprocess.check_output(['./detect']).decode('ascii')
这一切都很好。但是,与通过setup.py“setup()”运行distutils不同,默认编译器使用的是gcc-pthread
,而不是环境变量CC
中的设置。如何使此编译器使用CC
中的设置
我尝试过但没有成功的事情:
和cc.set\u可执行文件
,尽管我无法从文档中真正了解它们的用途或使用方法cc.set\u可执行文件
- 手动更改
;无效cc.compiler
- 查看
;有很多方法可以获取配置变量,但没有方法设置任何内容李>distutils.sysconfig