Question about adding another local project as a dependency #9886
Replies: 1 comment
|
With Poetry 2.x, you can keep a local path for development while putting a normal version requirement in the built wheel. In [project]
name = "foo"
version = "1.0.0"
requires-python = ">=3.12"
dependencies = ["bar>=1.0.0,<2.0.0"]
[tool.poetry.dependencies]
bar = { path = "../bar", develop = true }
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"Here Build both projects on the development machine ( python -m pip install --no-index --find-links=wheelhouse "foo==1.0.0"Pip finds the matching I tested this with Poetry 2.5.1: development installation used |
Uh oh!
There was an error while loading. Please reload this page.
I'm working on a project that's going to be installed onto a computer that doesn't have network access. Right now I've created two libraries, foo and bar. I thought I could just create a .whl for each, copy them from my development workstation to removable media, and install them on the destination computer with pip. But the foo library has the bar library as a dependency, and I'm not sure how to do this in poetry.
Running "poetry add bar ../bar" in the foo project (../bar is the path to where I'm developing the bar library) seemed to do the trick, but it looks like this results in a foo.whl that always wants to satisfy it's dependency on bar by building it with poetry in /home/mark13/foo instead of using of using the. I can create a directory like that in the destination computer, but installing poetry would be pretty difficult without network access.
As far as I can tell, the proper thing to do is add a source (https://python-poetry.org/docs/cli/#source-add) where poetry can find the bar library, then just do "poetry add bar". But as far as I can tell from the poetry docs, poetry doesn't support sources that aren't web servers. I did hope "poetry source add --priority=supplemental /home/mark13/foo" or "poetry source add --priority=supplemental file:///home/mark13/foo" would work, but both give the error: "A custom source cannot be added without a URL."
I can't upload to pypi as it's proprietary code, and I don't have access to a web server I can upload the packages to. I think I could figure out how to set up a python-based simple repository (https://peps.python.org/pep-0503/), but I was hoping I wouldn't have to go that far.
Is there a way for me to get poetry to create a .whl for the foo library that simply has the foo library as a dependency? Such that installing foo.whl via pip doesn't trigger trying to build bar via poetry?
All reactions