我正在运行Python 3.6.3并且我一直在尝试向setup.py
添加自定义命令。
据我所知,我所做的似乎与我在这个主题上看到的各种教程和示例相匹配,但我无法让它发挥作用。
我已将setup.py
剥离到最低限度。这是:
import setuptools
class FooCommand(setuptools.Command):
user_options = []
"""Custom build command."""
def initialize_options(self):
"""Abstract method that is required to be overwritten"""
def finalize_options(self):
"""Abstract method that is required to be overwritten"""
def run(self):
print("Running foo command...")
setuptools.setup(
cmdClass={'foo': FooCommand}
)
当我运行python setup.py foo
我收到以下错误:
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'cmdClass'
warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'foo'
答案 0 :(得分:0)
我终于明白了。 cmdClass
中有一个拼写错误。它应该是cmdclass
- 即全部小写。
setuptools.setup(
cmdClass={'foo': FooCommand}
)