Skip to content

Commit

Permalink
Eliminate use of deprecated distutils.version module (#379)
Browse files Browse the repository at this point in the history
Since the recommended replacement, `packaging.version`, is not in the
standard library, this commit instead just implements a simple version
number comparison without any additional dependencies.
  • Loading branch information
jbms authored Nov 4, 2022
1 parent d1565d8 commit ff34a81
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bazelisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import base64
from contextlib import closing
from distutils.version import LooseVersion
import hashlib
import json
import netrc
Expand Down Expand Up @@ -171,15 +170,18 @@ def read_remote_text_file(url):


def get_version_history(bazelisk_directory):
ordered = sorted(
return sorted(
(
LooseVersion(release["tag_name"])
release["tag_name"]
for release in get_releases_json(bazelisk_directory)
if not release["prerelease"]
),
# This only handles versions with numeric components, but that is fine
# since prerelease versions have been excluded.
key=lambda version: tuple(int(component)
for component in version.split('.')),
reverse=True,
)
return [str(v) for v in ordered]


def resolve_latest_version(version_history, offset):
Expand Down

0 comments on commit ff34a81

Please sign in to comment.