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

Conversation

smortex
Copy link
Member

@smortex smortex commented Jan 1, 2024

This is currently broken on FreeBSD do to the usage of GNU-grep specific
grep(1) flag: -P.

We can use a single sed(1) command with an extended regular expression
to achieve the same goal, so use this instead.

This is currently broken on FreeBSD do to the usage of GNU-grep specific
grep(1) flag: `-P`.

We can use a single sed(1) command with an extended regular expression
to achieve the same goal, so use this instead.
@smortex smortex added the bug Something isn't working label Jan 1, 2024
@smortex smortex marked this pull request as ready for review January 1, 2024 22:21
@@ -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.

@smortex smortex merged commit 2f16b92 into master Jan 1, 2024
34 checks passed
@smortex smortex deleted the portable-latest-version-detection branch January 1, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants