Closed Bug 1777414 Opened 2 years ago Closed 2 years ago

Refactor `distutils.version.LooseVersion` and distutils.version.StrictVersion` to `packaging.version.Version`

Categories

(Firefox Build System :: Mach Core, task, P3)

task

Tracking

(firefox105 fixed)

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: ahochheiden, Assigned: ahochheiden)

References

(Blocks 1 open bug)

Details

Attachments

(4 files, 1 obsolete file)

As outlined in Bug 1743785, this is a "sub-bug" for the refactoring/removal of distutils, specifically for LooseVersion and StrictVersion.

All "versions" should now be Version objects and they can no longer be
compared against hard-coded strings. As such, all hard-coded are also
constructed into Version objects so that they can be compared..

I also removed the Version class that inherited from LooseVersion in
configure/util.py. The resulting difference is that 'patch' is no
longer an available attribute, it is now called 'micro'. I did this for
the sake of consistency (Everything following the same naming convention
found in packaging.version.Version).

In packaging.version there is also a LegacyVersion which is less
strict, similar to LooseVersion. I chose not to use this at all since
it is already deprecated and is slated for removal. Comparing a
LegacyVersion against a Version always results in the
LegacyVersion object being less, which is not intuitive and can
cause unexpected behavior.

I was not able to come up with a way to get esr versions to work with packaging.version.Version. As per PEP440 esr is not a valid version component. Maybe there's an obvious workaround I'm not seeing, but for now I've left mozrelease/version.py and release/update-verify-config-creator.py unchanged.

Attachment #9283573 - Attachment is obsolete: true

This will be used to replace the LooseVersion within distutils.
StrictVersion from distutils will need something else, as swapping
usages of StrictVersion with LooseVersion does not result in the
desired behavior.

Some minor tweaking to the logic in MozillaVersionCompareMixin was
necessary to get comparisons between LooseVersion and Version with
esr suffixes working as desired.

Pushed by ahochheiden@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e410f86b09a5 Vendor standalone 'looseversion' at version 1.0.1 r=firefox-build-system-reviewers,glandium
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch
Regressed by: 1782785
No longer regressed by: 1782785
Pushed by ahochheiden@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d8c248b75a5b Remove Python2 specific code from our `Version` subclass r=firefox-build-system-reviewers,glandium
Pushed by ahochheiden@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a460318b0814 Replace all uses of `distutils.version.LooseVersion` with `looseversion.LooseVersion` r=firefox-build-system-reviewers,glandium
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: