|
7 | 7 | import os |
8 | 8 | import sys |
9 | 9 | from contextlib import contextmanager |
10 | | -from distutils.version import LooseVersion |
| 10 | +from packaging.version import Version |
11 | 11 |
|
12 | 12 | from pre_commit_hooks.util import ( |
13 | 13 | load_autopkg_recipe, |
@@ -179,17 +179,15 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename) |
179 | 179 | # Warn if using a MinimumVersion greater than or equal to 2 |
180 | 180 | # warn_on_vers = "2" |
181 | 181 | # suggest_vers = "1.4.1" |
182 | | - # if LooseVersion(min_vers) >= LooseVersion(warn_on_vers): |
| 182 | + # if Version(min_vers) >= Version(warn_on_vers): |
183 | 183 | # print( |
184 | 184 | # "{}: WARNING: Choosing MinimumVersion {} limits the potential " |
185 | 185 | # "audience for your AutoPkg recipe. Consider using MinimumVersion " |
186 | 186 | # "{} if your processors support it.".format(filename, min_vers, suggest_vers) |
187 | 187 | # ) |
188 | 188 |
|
189 | 189 | # Processors for which a minimum version of AutoPkg is required. |
190 | | - # Note: Because LooseVersion considers version 1.0 to be "less than" 1.0.0, |
191 | | - # specifying more trailing zeros than needed in the dict below may result |
192 | | - # in false positive errors for users of the check-autopkg-recipes hook. |
| 190 | + # Note: packaging.version.Version considers this True: "1.0" == "1.0.0" |
193 | 191 | proc_min_versions = { |
194 | 192 | "AppPkgCreator": "1.0", |
195 | 193 | "BrewCaskInfoProvider": "0.2.5", |
@@ -230,10 +228,10 @@ def validate_minimumversion(process, min_vers, ignore_min_vers_before, filename) |
230 | 228 | for proc in [ |
231 | 229 | x |
232 | 230 | for x in proc_min_versions |
233 | | - if LooseVersion(proc_min_versions[x]) >= LooseVersion(ignore_min_vers_before) |
| 231 | + if Version(proc_min_versions[x]) >= Version(ignore_min_vers_before) |
234 | 232 | ]: |
235 | 233 | if proc in [x.get("Processor") for x in process]: |
236 | | - if LooseVersion(min_vers) < LooseVersion(proc_min_versions[proc]): |
| 234 | + if Version(min_vers) < Version(proc_min_versions[proc]): |
237 | 235 | print( |
238 | 236 | "{}: {} processor requires minimum AutoPkg " |
239 | 237 | "version {}".format(filename, proc, proc_min_versions[proc]) |
@@ -544,7 +542,6 @@ def main(argv=None): |
544 | 542 |
|
545 | 543 | retval = 0 |
546 | 544 | for filename in args.filenames: |
547 | | - |
548 | 545 | recipe = load_autopkg_recipe(filename) |
549 | 546 | if not recipe: |
550 | 547 | retval = 1 |
|
0 commit comments