问题
I am using Python 3 on CentOS 7. I am trying to build a C extension as described here. I have written a simple program, demo.c, which is in a directory in PYTHONPATH. demo.c has the following form.
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello from demo.c\n");
return 0;
}
This code runs without error.
from distutils.core import setup, Extension
module1 = Extension('demo',
sources = ['demo.c'])
However, the following code
setup (name = 'PackageName',
version = '1.0',
description = 'This is a demo package',
ext_modules = [module1])
produces the following error.
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
回答1:
The error is saying you'll need to pass in a Distutils command, such as build
(or probably build_ext in your case).
python CInterface.py build_ext
来源:https://stackoverflow.com/questions/58717898/error-no-commands-supplied-when-using-distutils-core