当我更改诗歌的 pyproject.toml 时,我该做什么?

huangapple go评论37阅读模式
英文:

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 &lt;somedep&gt;, Poetry will add the entry to your pyproject.toml, update the poetry.lock and will install necessary dependencies.

huangapple
  • 本文由 发表于 2023年2月27日 12:36:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75576816.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定