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:
Nick Pope 2013-07-19 11:42:36 +01:00
parent 556749fcbf
commit c3737bdf07
2 changed files with 4 additions and 2 deletions

View File

@ -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):
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 = _archive_suffix_rx.sub("", version)
return pkgname, version

View File

@ -15,7 +15,9 @@ files = [
("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"),
("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)