Skip to content

Commit

Permalink
fix(pypi): package name with periods (#15867)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwuck authored Jun 18, 2022
1 parent 4ee68db commit df70d37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
</body></html>
11 changes: 9 additions & 2 deletions lib/modules/datasource/pypi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down

0 comments on commit df70d37

Please sign in to comment.