diff --git a/lib/datasource/pypi/index.ts b/lib/datasource/pypi/index.ts index b6eafd7707c8e630712567a3b0f4c4a3a5e3ed75..2e33fc9af7b3f022055eeaf70cf49bc8eb169a8d 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(