Python-Markdown / markdown

A Python implementation of John Gruber’s Markdown with Extension support.
https://python-markdown.github.io/
BSD 3-Clause "New" or "Revised" License
3.79k stars 863 forks source link

"Invalid constraint" message when installing via poetry #1195

Closed chbndrhnns closed 2 years ago

chbndrhnns commented 2 years ago

When install markdown in a virtual environment via poetry 1.1.11, I see this message:

> poetry add markdown==3.3.5

Updating dependencies
Resolving dependencies... (0.0s)PackageInfo: Invalid constraint (importlib-metadata (>='4.4') ; python_version < "3.10") found in markdown-3.3.5 dependencies, skipping
Resolving dependencies... (0.1s)

Writing lock file

No dependencies to install or update
waylan commented 2 years ago

It's working with Python built-in tools. Seems like this would be a bug in Poetry to me.

Personally, I don't have the time to investigate this for some random third-party library I've never heard of. Of course, a PR is welcome and will be considered.

violuke commented 2 years ago

We're having the same problem. Is this problem not this line?

https://github.com/Python-Markdown/markdown/blob/7919bfd8cf44e4fb50a3ccbd82b725db34b66a08/setup.py#L77

I might be wrong, but is this not requiring importlib-metadata >= 4.4 and python < 3.10 but importlib-metadata 4.4 requires python 3.10+

Sorry if I'm mistaken here, but we have the same issue (we're using Python 3.9).

facelessuser commented 2 years ago

@violuke This is not an uncommon syntax. It is stating that if the Python version is less than 3.10, then we want to include importlib-meta. Otherwise, it is not required.

We can also see that the importlib-meta package that is installable via pip requires >= Python 3.6: https://github.com/python/importlib_metadata/blob/main/setup.cfg#L18.

mitya57 commented 2 years ago

FWIW, with normal pip it works fine. With Python 3.10:

$ pip install Markdown
Collecting Markdown
  Downloading Markdown-3.3.5-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 930 kB/s 
Ignoring importlib-metadata: markers 'python_version < "3.10"' don't match your environment
Installing collected packages: Markdown
Successfully installed Markdown-3.3.5

With Python 3.9:

$ pip install Markdown
Collecting Markdown
  Using cached Markdown-3.3.5-py3-none-any.whl (97 kB)
Collecting importlib-metadata>='4.4'
  Using cached importlib_metadata-4.8.2-py3-none-any.whl (17 kB)
Collecting zipp>=0.5
  Using cached zipp-3.6.0-py3-none-any.whl (5.3 kB)
Installing collected packages: zipp, importlib-metadata, Markdown
Successfully installed Markdown-3.3.5 importlib-metadata-4.8.2 zipp-3.6.0
facelessuser commented 2 years ago

I think that is the problem. There are some non-pip systems that don't know how to handle such syntax properly, but I don't think that is a Markdown or pip problem as much as it is a Poetry problem.

violuke commented 2 years ago

Ah, apologies that I misunderstood this syntax.

We also use Poetry. I must say that it's been an incredible upgrade on using pip for us. I realise if this is your first introduction to it, you might not be inspired to try it 😆 but I'd highly recommend giving it a shot.

I've opened an issue on the Poetry repo https://github.com/python-poetry/poetry/issues/4777

Thanks everyone for your comments on this. For now, we have pinned Poetry to markdown 3.3.4

waylan commented 2 years ago

I'm closing this as an upstream issue. We will reconsider if someone can provide something conclusive that we need to change.

abn commented 2 years ago

This is actually resolved by #1197.

waylan commented 2 years ago

FYI, we just released version 3.3.6 which should resolve this issue.

chbndrhnns commented 2 years ago

This was fast! Thanks much!

itdependsnetworks commented 2 years ago

Can you proactivly "Yank" 3.3.5 from pypi? This is preferred over deleting https://blog.piwheels.org/new-features-deletion-yanking-and-more/

waylan commented 2 years ago

3.3.5 has been yanked.