-
Notifications
You must be signed in to change notification settings - Fork 181
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
Use better version string comparison #499
Conversation
Currently, this function compares raw version strings such as "7.5.2" and "9.6" to find the newer version. This worked fine until Tor Browser version 10 was released and "10.0" is no longer considered larger than "7.5.2" by this function. This commit changes the function to split the raw strings on periods and compares the corresponding tuples, such as (7, 5, 2) and (10, 0). While this does not cover all edge cases, it should work better for these purposes. It is also simple and avoids adding an extra dependency compared to other options. Fixes #498
The https://setuptools.readthedocs.io/en/latest/pkg_resources.html#parsing-utilities However, that's not necessarily a reason not to merge this first and then discuss the best long-term choice later. |
I definitely agree that would be the best solution. However, I do not think that package is part of the standard library (at least not in Debian 10), so I personally did not want to add an extra dependency to a project that I am not very familiar with unless it was completely necessary. |
@micahflee Please, consider merging this PR along with #482, then doing a new torbrowser-launcher release. The last one was more than a year ago and is outdated and broken (without patches applied) now. |
I strongly urge you NOT to use Anyway I doubt you'll ever need to fully handle every nuance of python allowed version specifiers including prereleases, postreleases, dev versions, epochs, and people's humorous jokes with alphabetic versions. You only care about the types of versions Tor Browser uses (which quite obviously would always have eventually gotten to "10"). |
I withdraw my suggestion of |
@intrigeri Could you please also merge this PR along with #482? Thanks! :-) |
I can't: I only can merge PRs about the AppArmor policy. |
FYI: https://www.python.org/dev/peps/pep-0386/#distutils Taken from the link above:
Version numbering for anarchists and software realists. Implements the standard interface for version number classes as described above. A version number consists of a series of numbers, separated by either periods or strings of letters. When comparing version numbers, the numeric components will be compared numerically, and the alphabetic components lexically. The following are all valid version numbers, in no particular order:
In fact, there is no such thing as an invalid version number under this scheme; the rules for comparison are simple and predictable, but may not always give the results you want (for some definition of "want"). |
If you crave some complex version class to do your work for you, I've pointed out the |
Fixed (a slightly different way) in #526 |
Summary: Add version comparison patch to torbrowser-launcher This adds a patch from [here](torproject/torbrowser-launcher#499) to fix the version comparison on install, which causes issues like [this one](torproject/torbrowser-launcher#498) and [this one](https://discuss.getsol.us/d/1128-how-do-i-install-and-config-the-tor/) Also updates the signing key patch to only import a 8KB key instead of the previous 4 MB monstrosity, as suggested [here](torproject/torbrowser-launcher#482) Test Plan: Succesfully download and launch TorBrowser, plus a quick test query in DuckDuckGo Reviewers: #triage_team, JoshStrobl Reviewed By: #triage_team, JoshStrobl Subscribers: JoshStrobl Differential Revision: https://dev.getsol.us/D9787
Currently, this function compares raw version strings such as "7.5.2"
and "9.6" to find the newer version. This worked fine until Tor Browser
version 10 was released and "10.0" is no longer considered larger than
"7.5.2" by this function. This commit changes the function to split the
raw strings on periods and compares the corresponding tuples, such as
(7, 5, 2) and (10, 0). While this does not cover all edge cases, it
should work better for these purposes. It is also simple and avoids
adding an extra dependency compared to other options.
Fixes #498