Skip to content

Pre-release ~= constrains are mis calculated #1150

@epage

Description

@epage
  • 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
  • Poetry version: 0.12.16
  • Link of a Gist with the contents of your pyproject.toml file: N/A, requires access to a proprietary pypi instance

Issue

My constraints aren't resolving.

A rough look at my dependency tree

  • A: `B = "^0.7.5" via poetry
  • B: "C~=0.2.0dev16" via setup.py

Poetry complains that it cannot resolve B's dependency on C

[SolverProblemError]
Because B (0.7.5) depends on C(>=0.2.0,<0.3.0) which doesn't match any versions, B is forbidden.
So, because no versions of B match >0.7.5,<0.8.0
 and A depends on B (^0.7.5), version solving failed.

I traced the problem down into semver/__init__.py:parse_single_constraint where the constraint

  • ~=0.2.0dev16
    gets compiled into
  • >=0.2.0,<0.3.0

In contrast, the constraint

  • ~=2.0.dev0
    correctly gets compiled into
  • >=2.0.dev0,<3.0.0

The problem seems to be

        if precision == 2:
            low = version
            high = version.stable.next_major
        else:
            low = Version(version.major, version.minor, 0)
            high = version.stable.next_minor

where if the precision is 1 or 3, then the pre-release is dropped from low, disqualifying them from resolving the constraint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions