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

rpm.compare_versions: fix bugs with ~ segments #25

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

owtaylor
Copy link

@owtaylor owtaylor commented May 5, 2022

This PR fixes several bugs that I noticed when I compared the result of sorting all Fedora 35 packages between:

  1. version_utils.rpm.compare_versions()
  2. rpm.labelCompare() from the librpm Python bindings

With these fixes, the sorting of that test dataset is the same. (The ~~ test case doesn't exist in that dataset - it's artificial to show the badness from calling _get_block_result() without proceeding to the next pass of the loop. I did check that RPM handles it the same way as the test case.)

I haven't reviewed the librpm sources and make no guarantees that the order is the same for all possible inputs. :-)

<X>~<Y> should be older than <X>, not newer
There were multiple bugs when comparing two segments that both begin
with ~:

* First, map(lambda x: x.pop(0), (chars_a, chars_b)) is a no-op, since
  the iterator isn't iterated.
* Second, we need to continue to the next step of the loop, instead of
  calling _get_block_result(), since we don't know that the result of
  stripping the ~ characters are "blocks"
@mplanchard
Copy link
Contributor

mplanchard commented May 5, 2022

Hi @owtaylor! I am the original author of this repo, but I no longer have access to it, and I don't believe it's being maintained anymore (ihiji was purchased some time ago and whoever sees this if anyone seems to be mostly ignoring issues here).

Frankly I'm amazed anyone is still using the package!

I do still have access to publish a release in PyPI, and I've got a fork of this at mplanchard/version_utils, so if you could open a PR against my repo, I can try to find some time to cut a release this week.

@owtaylor
Copy link
Author

owtaylor commented May 5, 2022

Hi Matthew. Thanks for the response! - I started using your code a couple of years ago because using the RPM library bindings isn't very feasible when using a non-system Python (like Python-3.8 on top of RHEL 8). Revisting my code, and forgetting why I did that, I was wondering "should I switch this to rpm.labelCompare()", wrote a mini-benchmark using the Fedora 35 dataset, and noticed the discrepancy. But the system-python vs. newer-Python issue still exists, so an updated release would be great :-). Will open the PR against your repo.

@owtaylor
Copy link
Author

owtaylor commented May 5, 2022

mplanchard#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants