Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make latest version detection portable #682

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
$latest_version = join([
"${pip_install} ${legacy_resolver} ${pypi_index} ${pypi_extra_index} ${proxy_flag}",
" ${install_args} ${install_editable} ${real_pkgname}==notreallyaversion 2>&1",
' | grep -oP "\(from versions: .*\)" | sed -E "s/\(from versions: (.*?, )*(.*)\)/\2/g"',
" | sed -nE 's/.*\\(from versions: (.*, )*(.*)\\)/\\2/p'",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. -n prevent output by default (this allows us to skip grep(1) which was used to only process the line matching 'from versions';
  2. The removed ? repetition char (0 or 1) was bogus after the * repetition char (0 or any number), so drop it;
  3. the g flag is used to replace each occurrences, but we can only have a single match on a line, to remove it and add the p flag to print the result of the substitution which is not done automatically because of 1. above.

' | tr -d "[:space:]"',
])

Expand Down