Issue
I have a question regarding dependency resolution in poetry when using pip install to install a package that is managed by it. I did not find a clear answer to this in the documentation.
My understanding of dependency resolution in poetry is the following:
- In
pyproject.toml I define my dependencies for development and runtime
- These dependencies can be in caret form, which gives some leeway in the actual version that's picked. The caret form is the default when using
poetry add.
poetry install will take all these dependencies, build the tree, find a solution that satisfies all the different direct and indirect dependency requirements, installs those packages in the versions determined, and writes the chosen version numbers into poetry.lock. poetry.lock should be version controlled, so that multiple people working on the same project get the same versions of dependencies.
- Updates to dependencies require an explicit
poetry update, which will reevaluate the tree and update poetry.lock, if required.
So far this is clear to me and makes sense.
However, when a poetry managed package is installed via pip install, what seems to happen is that the pip install process runs another dependency resolution process, looking only at pyproject.toml, and not at poetry.lock. This is even though build-backend = "poetry.core.masonry.api" is present in the pyproject.toml file. This might lead to pip install picking different dependency versions than poetry install did. I would expect pip install with the poetry build backend to look at poetry.lock to make sure end users get the exact same dependency versions that the package was developed and tested with.
- Is my observation correct that
pip install does not consult poetry.lock?
- Is that intentional?
- Is there a way to change this?
Issue
I have a question regarding dependency resolution in poetry when using
pip installto install a package that is managed by it. I did not find a clear answer to this in the documentation.My understanding of dependency resolution in poetry is the following:
pyproject.tomlI define my dependencies for development and runtimepoetry add.poetry installwill take all these dependencies, build the tree, find a solution that satisfies all the different direct and indirect dependency requirements, installs those packages in the versions determined, and writes the chosen version numbers intopoetry.lock.poetry.lockshould be version controlled, so that multiple people working on the same project get the same versions of dependencies.poetry update, which will reevaluate the tree and updatepoetry.lock, if required.So far this is clear to me and makes sense.
However, when a poetry managed package is installed via
pip install, what seems to happen is that the pip install process runs another dependency resolution process, looking only atpyproject.toml, and not atpoetry.lock. This is even thoughbuild-backend = "poetry.core.masonry.api"is present in thepyproject.tomlfile. This might lead topip installpicking different dependency versions thanpoetry installdid. I would expectpip installwith the poetry build backend to look atpoetry.lockto make sure end users get the exact same dependency versions that the package was developed and tested with.pip installdoes not consultpoetry.lock?