如何从pyproject.toml安装脚本?
我的pyproject.toml
[tool.poetry.scripts]
devel = "uvicorn api:app --reload"
prod = "uvicorn api:app"
在 poetry文档中
(wowtcg-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
» poetry install
Installing dependencies from lock file
Package operations: 38 installs, 0 updates, 0 removals
• Installing idna (3.3)
...
• Installing yapf (0.32.0)
(wowtcg-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
»
但是没有从这个命令中生成的脚本。
诗歌无法运行它们
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
» poetry run prod
ModuleOrPackageNotFound
No file/folder found for package wowtcg-tracker-api
at ~/.poetry/lib/poetry/_vendor/py3.10/poetry/core/masonry/utils/module.py:63 in __init__
59│ "from": str(src.relative_to(self._path)),
60│ }
61│ ]
62│ else:
→ 63│ raise ModuleOrPackageNotFound(
64│ "No file/folder found for package {}".format(name)
65│ )
66│
67│ for package in packages:
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
»
,在Venv bin中没有
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
» ls /home/bastakka/.cache/pypoetry/virtualenvs/wowtcg-tracker-api-dIKBwUYp-py3.10/bin
activate dotenv* pip* pyreverse* watchgod*
activate.csh epylint* pip3* python@ wheel*
activate.fish get_objgraph* pip-3.10* python3@ wheel3*
activate.nu httpx* pip3.10* python3.10@ wheel-3.10*
activate.ps1 isort* prisma* symilar* wheel3.10*
activate_this.py isort-identify-imports* prisma-client-py* undill* yapf*
deactivate.nu normalizer* pylint* uvicorn* yapf-diff*
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
»
我错过了需要的东西或做错了什么?
I have this snippet in my pyproject.toml
[tool.poetry.scripts]
devel = "uvicorn api:app --reload"
prod = "uvicorn api:app"
I install it as mentioned in poetry documentation
(wowtcg-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
» poetry install
Installing dependencies from lock file
Package operations: 38 installs, 0 updates, 0 removals
• Installing idna (3.3)
...
• Installing yapf (0.32.0)
(wowtcg-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
»
But there were no scripts generated from this command.
Poetry can't run them
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
» poetry run prod
ModuleOrPackageNotFound
No file/folder found for package wowtcg-tracker-api
at ~/.poetry/lib/poetry/_vendor/py3.10/poetry/core/masonry/utils/module.py:63 in __init__
59│ "from": str(src.relative_to(self._path)),
60│ }
61│ ]
62│ else:
→ 63│ raise ModuleOrPackageNotFound(
64│ "No file/folder found for package {}".format(name)
65│ )
66│
67│ for package in packages:
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
»
And there are none in the venv bin either
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
» ls /home/bastakka/.cache/pypoetry/virtualenvs/wowtcg-tracker-api-dIKBwUYp-py3.10/bin
activate dotenv* pip* pyreverse* watchgod*
activate.csh epylint* pip3* python@ wheel*
activate.fish get_objgraph* pip-3.10* python3@ wheel3*
activate.nu httpx* pip3.10* python3.10@ wheel-3.10*
activate.ps1 isort* prisma* symilar* wheel3.10*
activate_this.py isort-identify-imports* prisma-client-py* undill* yapf*
deactivate.nu normalizer* pylint* uvicorn* yapf-diff*
…-tracker-api-dIKBwUYp-py3.10) bastakka@Karel-NTB:/m/c/U/b/D/P/I/w/wowtcg-tracker-api (main↓2|✚9…9)
»
Am I missing something needed or doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
tool.poetry.scripts
用于“ nofollow noreferrer”>“安装软件包时要安装“ 。您必须丢弃诗歌运行
前缀才能运行它们。对于开发脚本,我会推荐 taskipy 。例如
,您可以运行
诗歌运行任务DEVEL
之类的东西tool.poetry.scripts
is used for "scripts or executables that will be installed when installing the package". You'd have to drop thepoetry run
prefix to run them.For development scripts I'd recommend something like taskipy. e.g.
Then you can run something like
poetry run task devel