Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.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与shell扩展_Python_Bash_Distutils - Fatal编程技术网

Python Distutils与shell扩展

Python Distutils与shell扩展,python,bash,distutils,Python,Bash,Distutils,我有一个Python扩展模块,它需要GTK。编译GTK程序通常需要大量的链接,因为GTK依赖于许多其他库(Glib、Cairo、Pango等)。因此,通常我只是使用shell扩展(back ticks)使用pkg config的输出进行编译,如: 但出于某种原因,当我在传递给distutils中的模块.extra\u compile\u args的参数中使用shell扩展时,我会得到一个错误,因为BASH实际上没有扩展表达式: module = Extension('mymodule',

我有一个Python扩展模块,它需要GTK。编译GTK程序通常需要大量的链接,因为GTK依赖于许多其他库(Glib、Cairo、Pango等)。因此,通常我只是使用shell扩展(back ticks)使用
pkg config
的输出进行编译,如:

但出于某种原因,当我在传递给distutils中的
模块.extra\u compile\u args
的参数中使用shell扩展时,我会得到一个错误,因为BASH实际上没有扩展表达式:

module = Extension('mymodule',
        sources = ['mymodule.c'])

module.extra_compile_args = ['`pkg-config --cflags gtk+-3.0`', 
        '`pkg-config --libs gtk+-3.0`'];
这只会导致如下错误:

gcc: error: `pkg-config --cflags gtk+-3.0`: No such file or directory
那么,有什么办法可以让这一切顺利进行吗?我是否需要手动执行shell扩展,将
pkg config
的输出作为Python字符串获取,然后将其作为元素添加到
module.extra\u compile\u args

module.extra_compile_args = [
  subprocess.check_output(["pkg-config", "--cflags", "gtk+-3.0"]),
  subprocess.check_output(["pkg-config", "--libs", "gtk+-3.0"])
];

module.extra_compile_args = [
  subprocess.check_output(["pkg-config", "--cflags", "gtk+-3.0"]),
  subprocess.check_output(["pkg-config", "--libs", "gtk+-3.0"])
];