Poetry: Install globally with --user

Created on 10 Jul 2019  路  9Comments  路  Source: python-poetry/poetry

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

Feature Request

I am using Poetry to install project dependencies into a Docker container where I do not have root access. Since using a virtualenv would be unnecessary (there is only ever one project in this container) and a waste of time (this is done as part of a web service aiming at speed), I configure settings.virtualenvs.create to false. However, this causes Poetry to try to install the packages system-globally, which fails because I don't have root access in the container.

I would like a way to tell Poetry to use pip install --user instead of just pip install to install packages when virtualenvs are disabled.

Feature

All 9 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Closing this issue automatically because it has not had any activity since it has been marked as stale. If you think it is still relevant and should be addressed, feel free to open a new one.

I picked up this issue and started working on an implementation

Can somebody re-open the issue please? cc: @sdispater

Hey @richin13 ,

thanks a lot for your contribution! I reopened this issue and assigned you for seeing that this is in progress.

As this is a new feature @sdispater has to decide if it gets included. But it looks like a useful thing to me :+1:

fin swimmer

Awesome, thank you @finswimmer

Shouldn't the following just work?

pip install --user /path/to/poetry-project

This should result in your project being built in an isolated environment without development requirements and pip installing the built package respecting the --user flag.

@richin13 did your submission go anywhere or was it ignored? Currently my workaround is:

pip install --user --requirement <(poetry export --format requirements.txt)

However, this doesn't give me the project itself installed into the user.

I also tried setting PIP_USER=1 hoping that it would get passed through poetry down to the underlying pip command, but no joy.

@harrybiddle why not let pip install the project itself as suggested above?

@raxod502 @richin13 I beleive this behaviour is dependent on the underlying pip version (ie. the pip provided in your container). This often times (if ensured via python -m ensure pip) tends to be older versions.I beleive since 20.0, pip defaults to installing to user site when not root. Trying a pip install --upgrade pip prior to doing poetry install might do the trick here.

Hey @abn, thanks for the help, I really appreciate it.

I just gave this a go and it worked, except for two things: (1) my dev dependencies didn't get installed, and (2) I think your command installs the dependencies in the pyproject.toml rather than the pinned dependencies in poetry.lock, is that correct?

I couldn't see an option to pip install to pick up dev dependencies from pyproject.toml, and I played around with its --constraint option, but could not get it to work. In the end I came up with this command (pip 20.2.2, poetry 1.0.10):

pip install --requirement <(poetry export --dev --format requirements.txt)
pip install --no-deps .

This works where poetry config virtualenvs.create false && poetry install fails on Ubuntu 18.04 (it fails uninstalling system packages).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mozartilize picture mozartilize  路  3Comments

ambv picture ambv  路  3Comments

alexlatchford picture alexlatchford  路  3Comments

sobolevn picture sobolevn  路  3Comments

jhrmnn picture jhrmnn  路  3Comments