mirror of
https://github.com/pypiserver/pypiserver
synced 2025-02-22 19:19:37 +01:00
Fix guessing of package name and version.
The fix in commit 7f97612 for supporting the package naming used by the pytz module caused a regression if the package name contained a dash followed by a number. We fix this by splitting on all dashes followed by numbers and recreating the package name from all components but the last.
This commit is contained in:
parent
556749fcbf
commit
c3737bdf07
@ -47,7 +47,7 @@ _archive_suffix_rx = re.compile(r"(\.zip|\.tar\.gz|\.tgz|\.tar\.bz2|-py[23]\.\d-
|
|||||||
|
|
||||||
def guess_pkgname_and_version(path):
|
def guess_pkgname_and_version(path):
|
||||||
path = os.path.basename(path)
|
path = os.path.basename(path)
|
||||||
pkgname = re.split(r"-\d+", path, 1)[0]
|
pkgname = '-'.join(re.split(r'-(?=\d+)', path)[:-1])
|
||||||
version = path[len(pkgname) + 1:]
|
version = path[len(pkgname) + 1:]
|
||||||
version = _archive_suffix_rx.sub("", version)
|
version = _archive_suffix_rx.sub("", version)
|
||||||
return pkgname, version
|
return pkgname, version
|
||||||
|
@ -15,7 +15,9 @@ files = [
|
|||||||
("greenlet-0.3.4-py3.2-win32.egg", "greenlet", "0.3.4"),
|
("greenlet-0.3.4-py3.2-win32.egg", "greenlet", "0.3.4"),
|
||||||
("greenlet-0.3.4-py2.7-linux-x86_64.egg", "greenlet", "0.3.4"),
|
("greenlet-0.3.4-py2.7-linux-x86_64.egg", "greenlet", "0.3.4"),
|
||||||
("pep8-0.6.0.zip", "pep8", "0.6.0"),
|
("pep8-0.6.0.zip", "pep8", "0.6.0"),
|
||||||
("pytz-2012b.zip", "pytz", "2012b")]
|
("pytz-2012b.zip", "pytz", "2012b"),
|
||||||
|
("ABC12-34_V1X-1.2.3.zip", "ABC12-34_V1X", "1.2.3"),
|
||||||
|
("A100-200-XYZ-1.2.3.zip", "A100-200-XYZ", "1.2.3")]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(("filename", "pkgname", "version"), files)
|
@pytest.mark.parametrize(("filename", "pkgname", "version"), files)
|
||||||
|
Loading…
Reference in New Issue
Block a user