实时开发 Python 外部库,但 Poetry 不起作用
我有一个项目使用存储在单独存储库中的库。这个库 my-lib
包含我的应用程序使用的一些功能。我想将该库与我的主项目链接起来以实时开发它。换句话说,我想启动我的主项目并在后台编辑库,从而导致项目根据更改进行重建。我花了一些时间试图弄清楚,但没有运气。
这就是我所做的:
- 假设我有一个
Repo
文件夹,其中包含项目和 lib:
/Repo/my-lib/
/Repo/my-app/backend/
- 在
my-app
内,我做了poetry add ../。 ./my-lib
(根据 THIS ),其中添加了依赖项里面的一个条目pypoetry.toml
文件:
my-lib = { path = "../../my-lib" }
- 我手动修改了此条目以:
my-lib = { path = "../../my-lib", develop = true }
- 启动我的项目并编辑库。
不幸的是,my-lib
中的更改并未反映在项目中。即使尝试poetry update my-lib
也无济于事。
所以我检查了 .venv/site-packages 文件夹。我想知道 my-lib 是否是该文件夹的符号链接或物理副本,它是第二个。我希望这里应该发生某种链接。我在网上搜索了许多问题和主题,对我来说它看起来应该可以工作...
我正在从事的项目(特别是 lib 部分)非常困难,并且一直需要大量调试,因此删除 .venv/site-packages/my-lib
并一遍又一遍地重新安装 my-lib
确实很烦人和耗时。
也许,我的文件夹结构有问题?我的项目文件夹中有 virtualenv,因此整个项目结构如下所示:
/Repo/my-lib/
pyproject.toml
/Repo/my-app/backend/
.venv/
lib
python3.8/
site-packages/
my-lib/
pyproject.toml
我正在使用最新版本的 [email protected]
并且它是使用他们的脚本安装的(而不是通过pip
)。
I have a project that uses a library stored in a separate repository. This library my-lib
contains some features that are used by my application. I want to link the lib with my main project to develop it in realtime. In other words, I want to start my main project and edit the lib in the background causing the project to rebuild on changes. I have spent some time trying to figure it out, but no luck.
This what I did:
- Suppose I have a
Repo
folder that contains both, the project and the lib:
/Repo/my-lib/
/Repo/my-app/backend/
- Inside
my-app
I didpoetry add ../../my-lib
(according to THIS), which added an entry in dependencies insidepypoetry.toml
file:
my-lib = { path = "../../my-lib" }
- I modified this entry manually to:
my-lib = { path = "../../my-lib", develop = true }
- Started my project and edited the lib.
Unfortunately, changes in my-lib
are not reflected in the project. Even trying poetry update my-lib
does not help.
So I checked .venv/site-packages
folder. I wanted to know if my-lib
is a symlink or physical copy of the folder and it is the 2nd one. I would expect that some kind of linking should happen here. I searched through many issues and topics in the Web and for me it looks like it should work...
The project I'm working on (especially lib part) is very hard and needs much of debugging all the time, so removing .venv/site-packages/my-lib
and reinstalling my-lib
over and over again is really annoying and time consuming.
Maybe, my folder structure is a problem here? I have virtualenv inside my project folder, so the whole project structure looks like:
/Repo/my-lib/
pyproject.toml
/Repo/my-app/backend/
.venv/
lib
python3.8/
site-packages/
my-lib/
pyproject.toml
I'm using the newest version of [email protected]
and it was installed using their script (not via pip
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终使用的解决方案是:
但我还做了一些始终有效的附加步骤:
.venv
文件夹poetry cacheclear --all .
poetry lock --no-update
poetry install
在这些步骤之后,一切都工作正常。
The solution I ended up finally is using:
But I also do some additional steps that work always:
.venv
folderpoetry cache clear --all .
poetry lock --no-update
poetry install
After these steps everything always works fine.