Skip to content

poetry doesn't parse python constraints when markers are present #4965

@maciejskorski

Description

@maciejskorski
  • I am on the latest Poetry version.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Clarifies in-depth the common root-cause for several reported issues
#3444
#4959
#4958

  • OS version and name: Linux
  • Poetry version: 1.2.0a2
  • Python 3.8

Issue

poetry fails to parse python constraints when markers appear.

This should be supported as per the official documentation.

This also has a side effect on the performance and the lock file, as this way packages bypass early compatibility checks on versions; also wrong versions may get installed.

Reproduce
The following test confirms that poetry does not populate python constraints due to markers

[tool.poetry.dependencies]
python = "3.8"
pandas = [
    {version="1.3.2",python="3.9",markers="sys_platform=='linux'"},
    {version="1.3.1",python="3.8"}
]

then setting a breakpoint inside complete_package method gives

# [(d.name+str(d._constraint),d._python_constraint) for d in requires]
[('pandas1.3.2', <VersionRange (*)>), ('pandas1.3.1', <Version 3.8>)]

Furthermore, due to the broken constraint poetry would pick up the wrong (1.3.2) version to install.

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