How do I add a python package built by poetry to another python project with poetry?

30.1k Views Asked by At

I am working on two projects, let's call them Project A and Project B.

Project B requires some modules in Project A, so I did a poetry build on Project A. I am able to access the module when I manually perform a pip install dist/blabla.whl on the build produced by poetry on Project A.

But when I do a poetry add project-a git+ssh://[email protected]/nubela/project-a.git#develop, it says

Could not find a matching version of package project-a

Naturally, I understand because project-a is not classically packaged with setup.py and stuff. How can I then perform a poetry add <git-repo-uri> without involving self-hosted pypi instance?

I can push the .whl files to the project git repo, does that help?

3

There are 3 best solutions below

1
finswimmer On

The correct syntax would be

poetry add git+ssh://[email protected]/nubela/project-a.git#develop

More examples are in the docs

3
Arne On

I can push the .whl files to the project git repo, does that help?

While it would theoretically solve the issue, treating a repository as a file server sets you up for headaches - if your gitlab even allows uploading binaries in the first place.


Given the error message you're getting, it doesn't seem to be a poetry or setuptools issue, it is git that is complaining. Did you make sure that you have a tag or branch on your repo that is called develop? While it is not explicitly mentioned, the form of poetry add in the git-mode is

poetry add git+<protocol>://git@<repository>/<owner>/<project>.git#<git_ref>

The final #<git-ref> is optional, and if omitted poetry will install whatever is currently on the default branch (most likely "master"). What you probably want is just

poetry add git+ssh://[email protected]/nubela/project-a.git
0
Benyamin Jafari On

Here's a good article about poetry add variations.

In my case, I did the following pattern working properly:

poetry add git+https://github.com/agn-7/sqladmin.git