PEP 440 version matching of local version identifier clause (e.g. 1.2.3+local) not implemented correctly in solver
See original GitHub issue-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: Windows 10, but also in a Linux docker container running Ubuntu 18.04
-
Poetry version: 1.0.9
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/Korijn/b88b1605221574f51ee72b75efc03dbe
Issue
In PEP 440, it says the following in the section “Version Matching”:
If the specified version identifier is a public version identifier (no local version label), then the local version label of any candidate versions MUST be ignored when matching versions.
I believe this clause is being interpreted incorrectly by Poetry. When running poetry lock
on a pyproject.toml
file (see the gist linked above) with the folowing lines, poetry incorrectly reports a conflict:
torch = "1.4.0+cpu"
torchvision = "0.5.0+cpu"
1: conflict: torchvision (0.5.0+cpu) depends on torch (1.4.0)
1: ! not torch (1.4.0) is satisfied by torch (1.4.0+cpu)
1: ! which is caused by "bla depends on torch (1.4.0+cpu)"
1: ! thus: torchvision is forbidden
1: ! torchvision (0.5.0+cpu) is satisfied by torchvision (0.5.0+cpu)
1: ! which is caused by "bla depends on torchvision (0.5.0+cpu)"
1: ! thus: version solving failed
As said in the first line of the debug output, the package torchvision (0.5.0+cpu) depends on torch (1.4.0). However, I’ve specified that I need torch (1.4.0+cpu). The PEP says that the local identifier MUST be ignored when performing the version match for the constraint coming from the torchvision (0.5.0+cpu) package. So I would say that this conflict is actually an acceptable solution, given the constraints.
Note that Pip has no problem installing this combination of packages.
This is an issue with Poetry’s solver.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:26
- Comments:27 (4 by maintainers)
Any updates? This is currently blocking us from rolling out Poetry to any of our projects that use torch.
Is there any update on this? It is a real problem for my projects where I rely on torch.