poetry-plugin-export: 1.1.2: regression with poetry export when using python version constraints.

  • 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 10.15.5
  • Poetry version: 1.1.2
  • Link of a Gist with the contents of your pyproject.toml file: N/A

Issue

I have notice a regression compared to poetry 1.0.10 in the following case:

  • I add package dependency with a python version constraint (“typing-extensions”)
  • I add a development dependency having the same sub-dependency with no python version constraint (“black”).

The command poetry export give a wrong result with poetry 1.1.2 (it’s OK with 1.0.10)

How to reproduce:

poetry new example
cd example
sed -i '/^python = /s/3.8/3.7/' pyproject.toml
poetry add --python="<3.8" typing-extensions
poetry export -f requirements.txt | grep typing
poetry add --dev black
poetry export -f requirements.txt | grep typing

Output for Poetry 1.0.10 (Python 3.8.6):

...
typing-extensions==3.7.4.3; python_version < "3.8" \
...
typing-extensions==3.7.4.3 \

Output for Poetry 1.1.2 (Python 3.8.6):

...
typing-extensions==3.7.4.3; python_version < "3.8" \
...
typing-extensions==3.7.4.3; python_version < "3.8" \

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 11
  • Comments: 27 (9 by maintainers)

Commits related to this issue

Most upvoted comments

original bug report seems not to be a regression but a fix: adding a dev-dependency should not affect the export of non-dev packages. If we instead export --dev then the marker is relaxed as expected.

Example at https://github.com/python-poetry/poetry-plugin-export/issues/30#issuecomment-721439552 also works fine today: export gives

zipp==3.6.0 ; python_version >= "3.6" and python_version < "3.7"

and export --dev gives

zipp==3.6.0 ; python_version >= "3.6" and python_version < "3.8"

This is fixed.

@abn @finswimmer Could you have a look at this? This was a regression in Poetry 1.1.3 that is still present in 1.1.4. It affects every project that has pre-commit in its development dependencies and supports Python 3.6. Thank you!

I have narrowed the repro down a little further.

Create this pyproject.toml:

[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.6"
importlib-resources = {version = "^3.3.0", python = "<3.7"}

[tool.poetry.dev-dependencies]
pytest = "^5.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Then export the requirements:

$ poetry export --dev --format=requirements.txt | grep zipp
zipp==3.4.0; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.7" or python_full_version >= "3.6.0" and python_version < "3.7" and python_version >= "3.6" \

If you look at the output, you can see that the python constraint <3.7 on importlib-resources affects its dependency zipp, but it shouldn’t because zipp is also a dependency of pytest (via importlib-metadata), which doesn’t have a marker.

Update: This also reproduces with Poetry’s master. As a side note, reproducing it on master required running in a Python 3.7 environment. With Python 3.9 the dependency on importlib-metadata (and, by extension, on zipp) did not appear at all, even with poetry show --tree. But that seems to be an unrelated issue.

@oncleben31 I have added a fix to the same branch so that we emulate the same behaviour as 1.0.10.

$ poetry@local export --without-hashes 
typing-extensions==3.7.4.3; python_version < "3.8"
$ poetry@local export --without-hashes --dev
appdirs==1.4.4
black==20.8b1; python_version >= "3.6"
click==7.1.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
dataclasses==0.7; python_version >= "3.6" and python_version < "3.7"
mypy-extensions==0.4.3
pathspec==0.8.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
regex==2020.10.11
toml==0.10.1
typed-ast==1.4.1
typing-extensions==3.7.4.3