From bc7f3658838f53c4ce689681dcda81d3778e0ec5 Mon Sep 17 00:00:00 2001 From: dcharbonnier <d.charbonnier@oxys.net> Date: Fri, 13 Dec 2019 13:52:31 +0100 Subject: [PATCH] fix(pypi): pep0427 wheel packages (#4974) --- lib/datasource/pypi/index.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/datasource/pypi/index.ts b/lib/datasource/pypi/index.ts index b6eafd7707..2e33fc9af7 100644 --- a/lib/datasource/pypi/index.ts +++ b/lib/datasource/pypi/index.ts @@ -87,10 +87,23 @@ function extractVersionFromLinkText( ): string | null { const prefix = `${depName}-`; const suffix = '.tar.gz'; - if (!(text.startsWith(prefix) && text.endsWith(suffix))) { - return null; + if (text.startsWith(prefix) && text.endsWith(suffix)) { + return text.replace(prefix, '').replace(/\.tar\.gz$/, ''); + } + + // pep-0427 wheel packages + // {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl. + const wheelPrefix = depName.replace(/[^\w\d.]+/g, '_') + '-'; + const wheelSuffix = '.whl'; + if ( + text.startsWith(wheelPrefix) && + text.endsWith(wheelSuffix) && + text.split('-').length > 2 + ) { + return text.split('-')[1]; } - return text.replace(prefix, '').replace(/\.tar\.gz$/, ''); + + return null; } async function getSimpleDependency( -- GitLab