gpt4 book ai didi

python - 如何将控制台脚本/入口点添加到调用类函数 python 的 setup.py

转载 作者:行者123 更新时间:2023-12-04 10:30:50 25 4
gpt4 key购买 nike

我想在 setup.py 中添加一个入口点,它调用一个类的静态方法。这可能吗?如果可能的话怎么办?我试过并查阅了文档,但不知道该怎么做。

例子:包格式:

mypackage/
setup.py
mypackage/
test.py

test.py 包含:

class TestClass:
@staticmethod
test_func():
print("test print statement")

setup.py 包含如下所示的控制台脚本:

entry_points={
'console_scripts': [
'run_console_script = mypackage.test:TestClass.test_func'
]}

但是当我运行上面的代码时,它没有报错,但是什么也没有打印。

最佳答案

根据 setuptools' documentation on "Automatic Script Creation" 入口点只能是函数:

The way to use this feature is to define “entry points” in your setup script that indicate what function the generated script should import and run.

关于python - 如何将控制台脚本/入口点添加到调用类函数 python 的 setup.py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60420533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com