当你奔跑时,诗歌应该已经python setup.py install
为你奔跑了poetry 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
,您可以通过运行以下命令访问所有 pyrcrate 脚本poetry run SCRIPT_NAME
:
# 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