Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you pip install package maintained with poetry from github? #321

Closed
2 tasks done
tkossak opened this issue Jul 20, 2018 · 16 comments
Closed
2 tasks done

How do you pip install package maintained with poetry from github? #321

tkossak opened this issue Jul 20, 2018 · 16 comments

Comments

@tkossak
Copy link

tkossak commented Jul 20, 2018

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Question

How do you pip instal package (maintained with poetry) from github? When I want people to try latest development version from github, they can't install it in their venv using pip install git+URL because repo doesn't have setup.py file. What's the best solution here - should I add ./dist/* to github, manually create setupy.py or something else?

@tkossak tkossak changed the title How do you pip install poetry package from github? How do you pip install package maintened by poetry from github? Jul 20, 2018
@tkossak tkossak changed the title How do you pip install package maintened by poetry from github? How do you pip install package maintained by poetry from github? Jul 20, 2018
@tkossak tkossak changed the title How do you pip install package maintained by poetry from github? How do you pip install package maintained with poetry from github? Jul 20, 2018
@gmacon
Copy link

gmacon commented Jul 20, 2018

Once pip's PEP-517 support is available, this ought to work provided that the project has the correct information in its pyproject.toml. This should work (but I haven't tried it):

[build-system]
requires = ["poetry"]
build-backend = "poetry.masonry.api"

Until then, I might consider publishing prerelease wheels to PyPI from an automated build system.

@jhrmnn
Copy link
Contributor

jhrmnn commented Nov 23, 2018

PEP-517 support was just merged into Pip. Can be probably expected in the 19.0 release in January.

@jhrmnn
Copy link
Contributor

jhrmnn commented Jan 28, 2019

Pip 19.0 was released on 22 January 2019, and I have just successfully Pip-installed a Poetry-managed Python package from a git repository without setup.py. So I guess this issue can be closed.

@yisraeldov
Copy link

@jhrmnn Can you tell he how you got this to work ?

I'm using pip 19.2.2 and I can't seem to install my poetry project using pip

pip install -e [email protected]:yisraeldov/gpiozero-shiftregister.git#egg=gpiozero_shiftregister

It is still trying to run setup.py


...
 FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/hardware/driver/.venv/src/gpiozero-shiftregister/setup.py'

Thanks for any help

@jhrmnn
Copy link
Contributor

jhrmnn commented Aug 18, 2019

That's because you're trying to do an editable install (-e). As far as I know, that doesn't really make sense for a package installed from a remote repository. Without -e, the installation works.

@yisraeldov
Copy link

@jhrmnn

That's because you're trying to do an editable install (-e). As far as I know, that doesn't really make sense for a package installed from a remote repository. Without -e, the installation works.

Thanks but why doesn't it make sense to do an editable install? That is exactly what I want to do. Clone the required library from git and link it to my current project? I want to be able to push back any changes I have made to the required library.

From the pip documentation

VCS projects can be installed in editable mode (using the --editable option) or not.

Also

-e, --editable <path/url>
Install a project in editable mode (i.e. setuptools “develop mode”) from a local project path or a VCS url

Thanks for any help.

@jhrmnn
Copy link
Contributor

jhrmnn commented Aug 18, 2019

Ah sure. I do that often too, but I usually clone the repository manually in my project, because I want to track it, and Pip-install it from the path (pip install -e <local path>). Anyway, what you describe cannot be done at the moment, as far as I know. PEP517 has no support for editable installs. If you manually clone your repo, and try to to Pip-install it locally, you will get the following error message from Pip:

File "setup.py" not found. Directory cannot be installed in editable mode: <path>/gpiozero-shiftregister
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)

@yisraeldov
Copy link

@jhrmnn Ok thanks! So how would one go about working on a project and a required library simultaneously ad I described above? Is there a way to do this using poetry and not pip ?

This seems like such an obvious use case.

@jhrmnn
Copy link
Contributor

jhrmnn commented Aug 18, 2019

Yes, there is. Essentially, it needs to be Poetry all the way up. In the parent project's pyproject.toml under tool.poetry.dependencies, you then have something like

<package> = { path = "<path>", develop = true }

The develop option tells Poetry to install it in editable mode. I've never tried with packages installed from a repository (git instead of path), but that should presumably work too.

@yisraeldov
Copy link

@jhrmnn Thanks, I should be migrating my project to poetry any way!

@alexmojaki
Copy link

@jhrmnn this seems to work for temporarily setting up the editable link, but I can't have a line like that permanently in pyproject.toml for a deployed package. How do I implement this in practice? Do I just have to remember to edit the toml file every time I rerun poetry lock and install so that I don't break the link?

@jhrmnn
Copy link
Contributor

jhrmnn commented Dec 19, 2019

What do you actually want to achieve? For a deployed package, I guess you don't used editable installs, and then you can install a Poetry-managed package from a Git repository with the usual

pip install git+https://...

@alexmojaki
Copy link

alexmojaki commented Dec 19, 2019

My case doesn't actually involve git or github, so I guess maybe this is the wrong place to ask. I'm just trying to understand how to work with editable installs.

I am developing two projects, call them A and B, both using poetry. A depends on B.

In A/pyproject.toml, I will typically have a line like:

B = "*"

under dependencies for a sensible deploy.

Now I want to locally make a change to B and see what effet this has on A without deploying. Basically the usual use case for pip install -e, but that command doesn't work.

I can follow these steps:

  1. Change the line above to:

    B = { path = "../A", develop = true }

  2. Run poetry lock and install to establish the link in the virtualenv.

  3. Change pyproject.toml back to the 'correct' state.

  4. Run poetry lock again to similarly fix the lock file.

But this is far from ideal. It becomes a mess if dependencies change and I have to remember to follow all these steps to preserve the link.

Is there a better option for a workflow in practice?

@Eschivo
Copy link

Eschivo commented Sep 14, 2022

Hi guys, suppose to build the package and publish it in GitHub release, is it possible to pip install a specific package from GitHub releases? I use Windows PowerShell. Thank you.

@neersighted
Copy link
Member

You can add a VCS dependency. Please see the docs at python-poetry.org, and open a Discussion or join Discord for help if you need it -- this closed issue is not a good venue for it as we are generating notifications for many users.

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants