我正在CentOS 7上使用Python3。我正在尝试按照here所述构建C扩展。我编写了一个简单的程序demo.c,它位于PYTHONPATH中的目录中。 demo.c具有以下格式。
#include <stdio.h> #include <stdlib.h> int main() { printf("Hello from demo.c\n"); return 0; }
此代码运行无错误。
from distutils.core import setup, Extension module1 = Extension('demo', sources = ['demo.c'])
但是,以下代码
setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', ext_modules = [module1])
产生以下错误。
An exception has occurred, use %tb to see the full traceback.
SystemExit: usage: CInterface.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: CInterface.py --help [cmd1 cmd2 ...]
or: CInterface.py --help-commands
or: CInterface.py cmd --help
error: no commands supplied
我正在CentOS 7上使用Python3。我试图按此处所述构建C扩展。我编写了一个简单的程序demo.c,它位于PYTHONPATH中的目录中。 demo.c具有以下形式。 ...
错误是您需要传递Distutils命令,例如build
(or probably build_ext
in your case)。