当您运行 poetry install 时,诗歌应该已经为您运行 python setup.py install。
Poetry 基本上只是运行pip install package,它会下载包,基本上只是在包上运行python setup.py install!
在后台,[pip] 将运行 python setup.py install
来源:https://stackoverflow.com/a/15732821/10149169
但是,poetry 仅将软件包安装在隔离的虚拟环境中,以避免污染您计算机的其余部分。
要运行带有诗歌的东西,您需要使用poetry run YOUR_COMMAND 运行它
为了在虚拟环境中运行脚本,你必须运行poetry shell进入虚拟环境,或者poetry run YOUR_COMMAND。例如。要运行 Python 脚本,您应该执行 poetry run python your_python_script.py
示例
如果您有一个包含以下pyproject.toml 文件的文件夹:
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.6"
pycrate = {git = "https://github.com/P1sec/pycrate.git"}
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
运行poetry install后,你可以通过运行poetry run SCRIPT_NAME访问所有的pyrcrate脚本:
# works because pycrate_showmedia.py was installed with poetry install
me@computer:~/example-project$ poetry run poetry run pycrate_showmedia.py
usage: pycrate_showmedia.py [-h] [-bl BL] [-wt] input
pycrate_showmedia.py: error: the following arguments are required: input
如果你有导入pycrate库的Python文件,也需要使用poetry run运行:
me@computer:~/example-project$ cat test.py
import pycrate_core
print(pycrate_core.__version__)
me@computer:~/example-project$ poetry run python test.py