我正在将配置从setup.py
迁移到setup.cfg
,但是关键字cmdclass
有问题。我调查了setuptools文档,似乎该文档未得到记录或不受支持。因此,我尝试使用options.entry_points
。但是我一直收到无效的命令错误。
这是我所拥有的:
setup.cfg
[options.entry_points]
console_scripts =
install = CustomInstall:run
和
setup.py
from setuptools.command.install import install
from setuptools import setup
class CustomInstall(install):
def run(self):
print('overriden install command')
setup()
结果只是一个普通的安装命令。但是,我想复制我在运行时得到的行为:
# setup.py
from setuptools.command.install import install
from setuptools import setup
class CustomInstall(install):
def run(self):
print('overriden install command')
setup(cmdclass= {"install": CustomInstall})
给出覆盖的安装命令。
答案 0 :(得分:1)
我不认为有可能。将其保留在setup.py
中。
答案 1 :(得分:1)
不支持。
有关详细信息,请参阅 this PR。
答案 2 :(得分:0)
[options.entry_points]
和console_scripts
的作用是创建shell命令,这些命令在您的代码库中运行特定功能。将软件包安装到环境中后,这些命令将起作用。
因此,在您的示例中,将创建一个新的Shell命令install
,它将从名为run()
的程序包中运行CustomInstall
函数。
基于查看源代码,我会猜测正确的语法是:
[global]
commands =
install = mypackage.CustomInstall
但是我还无法使其正常工作。