diff --git a/lib/modules/datasource/pypi/__fixtures__/versions-html-with-periods.html b/lib/modules/datasource/pypi/__fixtures__/versions-html-with-periods.html index 846d72d71b430b1d0fb2276db2ea818b179cc9f8..e91932715c4c10f644cf28c6c2d0df0ab6307b6f 100644 --- a/lib/modules/datasource/pypi/__fixtures__/versions-html-with-periods.html +++ b/lib/modules/datasource/pypi/__fixtures__/versions-html-with-periods.html @@ -7,6 +7,6 @@ <h1>Links for package.with.periods</h1> <a href="">package.with.periods-2.0.0.tar.gz</a><br> <a href="">package.with.periods-2.0.1-py3-none-any.whl</a><br> - <a href="">package.with.periods-2.0.2-py3-none-any.whl</a><br> + <a href="">package_with_periods-2.0.2-py3-none-any.whl</a><br> <a href="">package.with.periods-2.0.2.tar.gz</a><br> -</body></html> \ No newline at end of file +</body></html> diff --git a/lib/modules/datasource/pypi/index.ts b/lib/modules/datasource/pypi/index.ts index 03511271f5f4e0bb2db0eb5a4da9c9703050ea9d..be28036a106522016923260412eed4113947e6f0 100644 --- a/lib/modules/datasource/pypi/index.ts +++ b/lib/modules/datasource/pypi/index.ts @@ -181,11 +181,18 @@ export class PypiDatasource extends Datasource { // pep-0427 wheel packages // {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl. + // Also match the current wheel spec + // https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode + // where any of -_. characters in {distribution} are replaced with _ const wheelText = text.toLowerCase(); - const wheelPrefix = packageName.replace(regEx(/[^\w\d.]+/g), '_') + '-'; + const wheelPrefixWithPeriod = + packageName.replace(regEx(/[^\w\d.]+/g), '_') + '-'; + const wheelPrefixWithoutPeriod = + packageName.replace(regEx(/[^\w\d]+/g), '_') + '-'; const wheelSuffix = '.whl'; if ( - wheelText.startsWith(wheelPrefix) && + (wheelText.startsWith(wheelPrefixWithPeriod) || + wheelText.startsWith(wheelPrefixWithoutPeriod)) && wheelText.endsWith(wheelSuffix) && wheelText.split('-').length > 2 ) {