Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让Python distutils兑现$CC?_Python_Compiler Construction_Distutils - Fatal编程技术网

如何让Python distutils兑现$CC?

如何让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('

我正在尝试使用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('ascii')
这一切都很好。但是,与通过setup.py“setup()”运行distutils不同,默认编译器使用的是
gcc-pthread
,而不是环境变量
CC
中的设置。如何使此编译器使用
CC
中的设置

我尝试过但没有成功的事情:

  • cc.set\u可执行文件
    cc.set\u可执行文件
    ,尽管我无法从文档中真正了解它们的用途或使用方法
  • 手动更改
    cc.compiler
    ;无效
  • 查看
    distutils.sysconfig
    ;有很多方法可以获取配置变量,但没有方法设置任何内容