Poetry: `poetry install` installs the project as a dependency of itself?

Created on 15 Jan 2019  路  20Comments  路  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.

Question

TL;DR: Is it expected behaviour when doing poetry install for the project to install itself as a dependency of itself?

I have started a new project using poetry init and followed up by poetry adding all my dependencies. I then pushed, and then cloned the git repo to another PC.

After the clone, I opened the new folder and did poetry install in that folder. That created the new virtual environment, as expected, but it also seems as if it installed the project as a dependency of itself. Please see the screenshot below. This is also evident in the new egg-info folder that was created. I expected the installations to stop at the last package (requests).
screenshot

I did not expect that behaviour and would like to confirm if that is the intention of poetry install.
You can find my project files here:

Most helpful comment

@sdispater Do you know when this might be released? I am about to introduce poetry at our company and I think this behavior would hinder adoption, maybe I can wait a bit if the feature is coming soon.

All 20 comments

That is the expected behavior and I also have the same issue using Poetry as a virtualenv manager. sdispater plans to add a feature in ^1.0.0 to disable this (https://github.com/sdispater/poetry/issues/730#issuecomment-446787970)

There is an open PR to pass an option to disable installing the project pending merge: #757

Thanks, Kyle.
To make sure I use both features correctly and efficiently, why would one want to install the project package itself, and why not?

I read on your linked comment that installing itself too ensures that "new elements like entrypoints are properly installed". Does this mean that on my first PC, where I created the project from scratch, that these were already installed when I did poetry init + the first poetry add?

I'm not sure, I imagine it may be used when developing Python modules where you may want the environment to have the package for running tests rather than using relative imports from the test directory

I only linked the comment to reference that sdispater mentioned not installing the project within the project would be a supported feature.

I'm pretty sure poetry install is the only command that uses the python -e command. poetry init is just file creation and poetry add is really only a wrapper (and version lock manager) for python -m pip install

Update: this is what it's used for :sweat_smile: https://github.com/sdispater/poetry/issues/34#issuecomment-382757596

The python -e command was added in poetry develop then merged into python install to allow this type of local development. It doesn't impact poetry add or other poetry commands. It will likely become optional in the ^1.0.0

I would also like to vote for an option to not install the project. Furthermore, the documentation is currently inaccurate, as poetry list says about install: "Installs the project dependencies."

I, and I think most other people, understand this to mean that it does not install the project itself.

My use case for this is that I mainly develop Django applications, and whenever I run poetry install I only want the dependencies to be installed, and not the project itself (as that does not make sense for my use case).

Poetry is not ready for corporate environments of this time, because of this issue.

This is really required, especially if there is no internet connection available but only a PyPI mirror.

(At least it should also pass the PyPI mirror defined in the toml file to pip)

[[tool.poetry.source]]
name = "artifactory"
url = "https://some-artifactory/artifactory/api/pypi/pypi-all/simple/"
poetry install -n
Creating virtualenv inspector-py3.7 in /root/.cache/pypoetry/virtualenvs
Installing dependencies from lock file


Package operations: 17 installs, 0 updates, 0 removals

  - Installing certifi (2018.11.29)
  - Installing chardet (3.0.4)
  - Installing idna (2.8)
  - Installing urllib3 (1.24.1)
  - Installing appdirs (1.4.3)
  - Installing attrs (18.2.0)
  - Installing click (7.0)
  - Installing markupsafe (1.1.0)
  - Installing requests (2.21.0)
  - Installing six (1.12.0)
  - Installing toml (0.10.0)
  - Installing black (18.9b0)
  - Installing jinja2 (2.10)
  - Installing python-dateutil (2.8.0)
  - Installing python-gitlab (1.7.0)
  - Installing pyyaml (3.13)
  - Installing tenacity (5.0.3)
  - Installing inspector (0.1.0)
/usr/local/lib/python3.7/site-packages/poetry/vcs/__init__.py:19: RuntimeWarning: git executable could not be found
  "git executable could not be found", category=RuntimeWarning

[EnvCommandError]                                                
Command ['/root/.cache/pypoetry/virtualenvs/inspector-py3.7/bin/pip', 'insta  
ll', '-e', '/builds/code-ops/inner-source-inspector', '--no-deps'] errored w  
ith the following output:                                                     
Obtaining file:///builds/code-ops/inner-source-inspector                      
  Installing build dependencies: started                                      
  Installing build dependencies: still running...                             
  Installing build dependencies: still running...                             
  Installing build dependencies: still running...                             
  Installing build dependencies: still running...                             
  Installing build dependencies: still running...                             
  Installing build dependencies: still running...                             
  Installing build dependencies: finished with status 'error'                 
  Complete output from command /root/.cache/pypoetry/virtualenvs/inspector-p  
y3.7/bin/python -m pip install --ignore-installed --no-user --prefix /tmp/pi  
p-build-env-tfd8pos2 --no-warn-script-location --no-binary :none: --only-bin  
ary :none: -i https://pypi.org/simple -- poetry>=0.12:                        
  Collecting poetry>=0.12                                                     
    Retrying

This is also causing an issue with forked repositories. I'm currently using django-tenant-schemas, and when the setup.py file is created it is adding:

install_requires = \
['django-tenant-schemas',

This is defined in pyproject.toml as referencing a forked Github repo (which contains some bug fixes, it's not yet merged), however in setup.py it's falling back to the version that's on pypi.

My current workaround is to have an additional RUN command in my Docker container calling Pip directly...

EDIT: Another workaround is to have the dependency installed as a dev dependency, however then I can't take advantage of --no-dev.

Poetry is not ready for corporate environments of this time, because of this issue.

I will agree with this. I wanted to move our projects to Poetry but this issue is a blocker, as it creates problems with our caches (the package is already in there and the runners get confused). It's too bad, because I love Poetry otherwise, but we had to go with pip-compile in the end.

Could this please be fixed? I'd very much like to use Poetry to deploy our apps.

My corporate environment is also blocked by this issue. I patched a version based on https://github.com/sdispater/poetry/pull/757. I left a comment with the necessary modifications. Wheel version here

In my dockerfile I'm using:
pip install http://github.com/BlueOwlDev/poetry/releases/download/1.0.0a44/poetry-1.0.0a44-py2.py3-none-any.whl

I solved the issue by changing the project-name in pyproject.toml to be something different than the directory name itself.

Poetry: 0.12.11

What @jnoortheen suggested seems to work for me too, but it's not exactly clear to me why? Surely this behavior is a bug?

The option has been already merged into develop branch: https://github.com/sdispater/poetry/pull/979

But I think the name of the option should rename to something like --no-cwd because of the meaning of root is special in POSIX filesystem.

@drunkwcodes Do you know if this has been released in any version? I can't find it in 0.12.12...

@sdispater Do you know when this might be released? I am about to introduce poetry at our company and I think this behavior would hinder adoption, maybe I can wait a bit if the feature is coming soon.

This seems to be in 1.0.0a3. However, I'm not sure when that will be released and there's no word from a maintainer. Hopefully release will happen soon, but the lack of an update here is frustrating.

Hello everyone! Any news on this?

The feature is present in the 1.0.0 prereleases, so if it's important to you you can use them. It will be available officially in the 1.0.0 stable release.

Many thanks, S茅bastien. For posterity, this is currently documented in the development branch in docs > CLI > install (at bottom) and invoked via:

poetry install --no-root

Pytest has a bunch of dependencies, some of which have their own dependencies.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thmo picture thmo  路  3Comments

jbarlow83 picture jbarlow83  路  3Comments

mozartilize picture mozartilize  路  3Comments

sobolevn picture sobolevn  路  3Comments

thejohnfreeman picture thejohnfreeman  路  3Comments