Skip to content

Incorrect poetry export output with dependency conditional on Python version #5141

@glennmatthews

Description

@glennmatthews
  • 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: MacOS 12.2

  • Poetry version: 1.1.12

Issue

Running poetry export --format requirements.txt --without-hashes with the below pyproject.toml produces an invalid requirements file, specifically:

click==7.1.2
click==8.0.3; python_version >= "3.7"

which will fail pip for any python version of 3.7 or later. Presumably the click==7.1.2 dependency should include a python_version < "3.7", but it does not.

Minimal pyproject.toml to reproduce this issue:

[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = ""
authors = ["Glenn Matthews <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.6"
celery = [
    {version = "~5.1.0", python = "<3.7"},
    {version = "~5.2.0", python = ">=3.7"},
]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
% poetry export --format requirements.txt --without-hashes
amqp==5.0.9
billiard==3.6.4.0
cached-property==1.5.2
celery==5.1.2; python_version < "3.7"
celery==5.2.3; python_version >= "3.7"
click-didyoumean==0.0.3
click-plugins==1.1.1
click-repl==0.2.0
click==7.1.2    <------------------<< seems incorrect
click==8.0.3; python_version >= "3.7"
colorama==0.4.4; python_version >= "3.7" and python_full_version < "3.0.0" and platform_system == "Windows" or platform_system == "Windows" and python_version >= "3.7" and python_full_version >= "3.5.0"
importlib-metadata==4.10.1
kombu==5.1.0; python_version >= "3.6" and python_version < "3.7"
kombu==5.2.3; python_version >= "3.7"
prompt-toolkit==3.0.3
pytz==2021.3
six==1.16.0
typing-extensions==4.0.1; python_version < "3.8" and python_version >= "3.7"
vine==5.0.0
wcwidth==0.2.5
zipp==3.7.0; python_version < "3.8" and python_version >= "3.7"

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