python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.5k stars 2.26k forks source link

Resolver writes incorrect version into the lock file for packages with numbers in the name #1506

Closed kleschenko closed 4 years ago

kleschenko commented 4 years ago

Issue

I've found an issue with packages that have a hyphen followed by the number in their name. (for legacy repositories) For example, I have this line in my pyproject.toml:

mandrill-37 = ">=1.1.0"

and after the poetry lock command there will be a following entry in the poetry.lock:

[[package]]
description = "A CLI client and Python API library for the Mandrill email as a service platform. Forked fork python 3.7 support"
name = "mandrill-37"
optional = false
python-versions = "*"
version = "37-1.1.0"

The problem here is in the incorrect version being written down to the lock-file which couldn't be installed later.

Looks like an issue is with the version regex used to split filename and get a version from it:

In [1]: import re                                                                                                      

In [2]: VERSION_REGEX = re.compile(r"(?i)([a-z0-9_\-.]+?)-(?=\d)([a-z0-9_.!+-]+)")                                     

In [3]: VERSION_REGEX.match('mandrill-37-1.1.0')                                                                       
Out[3]: <re.Match object; span=(0, 17), match='mandrill-37-1.1.0'>

In [4]: VERSION_REGEX.match('mandrill-37-1.1.0').groups()                                                              
Out[4]: ('mandrill', '37-1.1.0')
finswimmer commented 4 years ago

Hello @kleschenko,

thanks a lot for reporting. It seems that this is solved in the meantime. At least with poetry 1.0.3 I get:

[[package]]
category = "main"
description = "A CLI client and Python API library for the Mandrill email as a service platform. Forked fork python 3.7 support"
name = "mandrill-37"
optional = false
python-versions = "*"
version = "1.1.0"

fin swimmer

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.