簡體   English   中英

在setup.py中運行自定義命令時出錯

[英]Error running custom command in setup.py

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

我終於明白了。 cmdClass有一個錯字。 它應該是cmdclass即所有小寫字母。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM