Skip to content

PEP 440 version matching of local version identifier clause (e.g. 1.2.3+local) not implemented correctly in solver #2543

@Korijn

Description

@Korijn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions