【问题标题】:Error running custom command in setup.py在 setup.py 中运行自定义命令时出错
【发布时间】:2017-11-08 14:22:37
【问题描述】:

我正在运行 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'

【问题讨论】:

    标签: python setuptools setup.py


    【解决方案1】:

    我终于明白了。 cmdClass 中有错字。它应该是cmdclass - 即全部小写。

    setuptools.setup(
        cmdClass={'foo': FooCommand}
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-29
      • 1970-01-01
      • 2011-11-24
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多