如何在setuptools设置中添加命令挂钩?(How to add a command hook into setuptools setup?)

编程入门 行业动态 更新时间:2024-10-27 22:24:56
如何在setuptools设置中添加命令挂钩?(How to add a command hook into setuptools setup?)

我正在使用setuptools版本0.9.6,并希望按照此处或此处显示的说明添加命令挂钩到setup 。 我在同一个setup.py文件中创建了一个派生自setuptools.Command的类MyCommand ,我试图按如下方式添加这个钩子:

setup( # ... entry_points = { "distutils.commands": [ "my_command = MyCommand"]} )

但是,无法识别命令my_command ,即python setup.py my_command给出错误

error: invalid command 'my_command'

也许我需要以不同的方式参考我的命令? 或者使用版​​本工具0.9.6的版本有变化吗? 怎么做对了?

I am using setuptools Version 0.9.6 and want to add a command hook into setup, following the description shown here or here. I have created a class MyCommand derived from setuptools.Command within the same setup.py file and I am trying to add this hook as follows:

setup( # ... entry_points = { "distutils.commands": [ "my_command = MyCommand"]} )

However, the command my_command is not recognized, i.e. python setup.py my_command gives an error

error: invalid command 'my_command'

Maybe I do need to refer to my command in a different way? Or are there changes to the used version 0.9.6 of setuptools? How to do it right?

最满意答案

在cmdclass中添加命令,而不是我找到的。

setup( cmdclass = {'my_command':MyCommand}, )

类型:

>>> python setup.py --help-commands

将在Extra Commands列出您的Extra Commands

Add your command in cmdclass instead thats what i found.

setup( cmdclass = {'my_command':MyCommand}, )

Type :

>>> python setup.py --help-commands

Will list your command in Extra Commands

更多推荐

本文发布于:2023-08-06 04:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1443586.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   如何在   setuptools   add   hook

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!