首页 > 解决方案 > 获取诗歌脚本端点

问题描述

Poetry有一种很好的方式来使用poetry run <entrypoint>. 使用 Python 或 Bash以编程方式获取列表的最佳方法是<entrypoints>什么?pyproject.toml

例如,pyproject.toml

[tool.poetry]
name = "random-tool"
version = "1.0"

[tool.poetry.scripts]
tool = "tool.function:main"
other_tool = "other_tool.function:main"
all_the_tools = "other_tool.function:all"

输出为:

entrypoint = [ "tool", "other_tool", "all_the_tools" ]

标签: pythonpython-3.xbashpython-poetrytoml

解决方案


使用 python 这很容易,因为您可以使用tomlpyproject.toml文件解析为字典:

import toml

pyproject = toml.load("pyproject.toml")
print(pyproject["tool"]["poetry"]["scripts"].keys())

推荐阅读