Poetry: SolverProblemError with multiple constraints that do not intersect

Created on 23 Nov 2018  路  7Comments  路  Source: python-poetry/poetry

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: MacOSX
  • Poetry version: 0.12.8
  • Link of a Gist with the contents of your pyproject.toml file: pyproject.toml

Issue

I would like to list pylint as a dependency of my tool. pylint^1 supports Python 2 and pylint^2.0 supports Python 3. From the documentation, I assumed the following would work:

pylint = [
  { version = "^2", python = "^3" },
  { version = "^1", python = "^2" }
]

But I get a SovlerProblemError that says Because phidias depends on both pylint (^2) and pylint (^1), version solving failed.

I have the full output in the Gist. It has the following in it:

   1: fact: phidias depends on pylint (^2)
   1: fact: phidias depends on pylint (^1)

That shouldn't be true as I can't be running a Python interpreter that validates both of the Python semantic versions ^2/^3.

Bug Dependency resolution

Most helpful comment

Seems like this may have regressed? On Poetry 0.12.17 (and Python 3.7.4):

pytest = [
    {version = "^5.1", python = "^3.5"},
    {version = "~4.6", python = "~3.4"}
]

The Python versions don't overlap, but getting this same error:

[SolverProblemError]
Because package-name depends on both pytest (^5.1) and pytest (~4.6), version solving failed.

EDIT: seems like this may only be an issue in dev dependencies now? When I moved it to main dependencies, the SolverProblemError disappeared. Might be worth opening a new issue...

All 7 comments

@sdispater I'm happy to fix this up if you can point me in the correct direction. I'm just trying to find where the dependencies are loaded and when the python check occurs.

The bug comes from the method here: https://github.com/sdispater/poetry/blob/master/poetry/puzzle/provider.py#L452

Basically, for the root package we take the dependencies as is and do not perform the proper checks like for any other package.

Fixing this is actually simple: remove the return early condition.

if not package.is_root() and package.source_type not in {"directory", "file", "git"}:
    package = DependencyPackage(
        package.dependency,
        self._pool.package(
            package.name, package.version.text, extras=package.requires_extras
        ),
    )

Feel free to make a PR with a test covering this and I'd gladly review it. If you don't have time, let me know and I will do it.

I'm experiencing this same issue with poetry 1.0.0a1, but the files have been significantly refactored since the latest comment, it seems.

This is now fixed in the latest 0.12.11 release (and also in the 1.0.0a2 release)

Seems like this may have regressed? On Poetry 0.12.17 (and Python 3.7.4):

pytest = [
    {version = "^5.1", python = "^3.5"},
    {version = "~4.6", python = "~3.4"}
]

The Python versions don't overlap, but getting this same error:

[SolverProblemError]
Because package-name depends on both pytest (^5.1) and pytest (~4.6), version solving failed.

EDIT: seems like this may only be an issue in dev dependencies now? When I moved it to main dependencies, the SolverProblemError disappeared. Might be worth opening a new issue...

I can confirm what @agilgur5 is saying, this only happens in dev-dependencies. It's a bit odd that no one else raised this issue yet.

@sdispater

@peterdeme and anyone else reading here, looks like a duplicate issue of this was raised in #1480 and later resolved in #1482, which was just released yesterday in 1.0.0b3.
Not sure if this will come out in a stable release, but 1.0.0b3 does seem to fix it, as far as I can tell.

Found this out after I wrote a failing test case for this in #1509 only to find out it had a merge conflict and was just recently resolved 馃槄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

etijskens picture etijskens  路  3Comments

sobolevn picture sobolevn  路  3Comments

ulope picture ulope  路  3Comments

jeremy886 picture jeremy886  路  3Comments

nikaro picture nikaro  路  3Comments