英文:
What do I do when I change poetry pyproject.toml?
问题
我已经有一个pyproject.toml
文件,我已经执行了poetry init
(显然是这样),还执行了poetry install
。
如果我手动更改toml文件,我需要做什么?
一方面,我认为我需要同步poetry.lock
文件,但是我要删除它并重新执行install吗?
我对在编辑toml文件后如何继续的步骤有一些矛盾的想法。
此外,如果我执行poetry add
而不是手动编辑toml,流程是否相同?
英文:
I have a pyproject.toml
and I already did poetry init
(obviously) and poetry install
.
If I change the toml file by hand, what exactly do I have to do?
On the one hand I think I have to synchronize the poetry.lock
file but do I erase it and do install again?
I have conflicting ideas on how to proceed after an edit of the toml file.
Also, is the procedure the same if I do a poetry add
instead of editing the toml manually?
答案1
得分: 5
每当你更改与Poetry相关的内容在你的pyproject.toml
文件中,之后运行poetry lock --no-update
以将poetry.lock
文件与这些更改同步。--no-update
标志试图保留依赖项的现有版本。一旦锁定文件更新,运行poetry install
来将你的虚拟环境与已锁定的依赖项同步。
在可能的情况下,你应该更喜欢使用Poetry的命令行界面而不是手动编辑pyproject.toml
文件。Poetry将为你处理上面描述的步骤。因此,如果你运行poetry add <somedep>
,Poetry将在你的pyproject.toml
中添加条目,更新poetry.lock
并安装必要的依赖项。
英文:
Whenever you change Poetry related stuff in your pyproject.toml
run poetry lock --no-update
afterwards to sync the poetry.lock
files with those changes. The --no-update
flag tries to preserve existing versions of dependencies. Once the lock file is updated run poetry install
to sync your venv with the locked dependencies.
Wherever possible you should prefer using Poetry's cli instead of manually edit the pyproject.toml
. Poetry will take care of the steps described above for you. So if you run poetry add <somedep>
, Poetry will add the entry to your pyproject.toml
, update the poetry.lock
and will install necessary dependencies.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论