nubela
nubela

Reputation: 17294

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

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?

Upvotes: 18

Views: 47541

Answers (4)

Daniel B&#246;ckenhoff
Daniel B&#246;ckenhoff

Reputation: 380

In case you directly want to edit the pyproject.toml, add like

ipython-tikzmagic = {git = "[email protected]:michakraus/ipython-tikzmagic.git"}

Upvotes: 0

Benyamin Jafari
Benyamin Jafari

Reputation: 34086

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

Upvotes: 3

Arne
Arne

Reputation: 20207

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

Upvotes: 6

finswimmer
finswimmer

Reputation: 15202

The correct syntax would be

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

More examples are in the docs

Upvotes: 27

Related Questions