Skip to content

Commit

Permalink
replace parse_version with packaging.version.parse
Browse files Browse the repository at this point in the history
Signed-off-by: ijnek <kenjibrameld@gmail.com>
  • Loading branch information
ijnek committed Feb 2, 2023
1 parent 1086547 commit 1df61b7
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 24 deletions.
4 changes: 2 additions & 2 deletions bloom/commands/git/import_upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import tarfile
import tempfile

from pkg_resources import parse_version
from packaging import version

try:
from urlparse import urlparse
Expand Down Expand Up @@ -87,7 +87,7 @@ def version_check(version):
info(fmt("The latest upstream tag in the release repository is '@!{0}@|'."
.format(last_tag.replace('@', '@@'))))
# Ensure the new version is greater than the last tag
if parse_version(version) < parse_version(last_tag_version):
if version.parse(version) < version.parse(last_tag_version):
warning("""\
Version discrepancy:
The upstream version '{0}' isn't newer than upstream version '{1}'.
Expand Down
2 changes: 1 addition & 1 deletion bloom/commands/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import webbrowser
import yaml

from pkg_resources import parse_version
from packaging import version

# python2/3 compatibility
try:
Expand Down
4 changes: 2 additions & 2 deletions bloom/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from bloom.util import add_global_arguments
from bloom.util import handle_global_arguments

from pkg_resources import parse_version
from packaging import version
from threading import Lock

_updater_running = False
Expand Down Expand Up @@ -115,7 +115,7 @@ def fetch_update(user_bloom):
newest_version = pypi_result['info']['version']
current_version = bloom.__version__
if newest_version and bloom.__version__ != 'unset':
if parse_version(bloom.__version__) < parse_version(newest_version):
if version.parse(bloom.__version__) < version.parse(newest_version):
version_dict = {
'current': str(current_version),
'newest': str(newest_version)
Expand Down
4 changes: 2 additions & 2 deletions bloom/generators/debian/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
except ImportError:
from ConfigParser import SafeConfigParser
from dateutil import tz
from pkg_resources import parse_version
from packaging import version

from bloom.generators import BloomGenerator
from bloom.generators import GeneratorError
Expand Down Expand Up @@ -449,7 +449,7 @@ def generate_substitutions_from_package(
bad_changelog = True
# Make sure that the current version is the latest in the changelog
for changelog in changelogs:
if parse_version(package.version) < parse_version(changelog[0]):
if version.parse(package.version) < version.parse(changelog[0]):
error("")
error("There is at least one changelog entry, '{0}', which has a "
"newer version than the version of package '{1}' being released, '{2}'."
Expand Down
4 changes: 2 additions & 2 deletions bloom/generators/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@

try:
import catkin_pkg
from pkg_resources import parse_version
if parse_version(catkin_pkg.__version__) < parse_version('0.3.8'):
from packaging import version
if version.parse(catkin_pkg.__version__) < version.parse('0.3.8'):
warning("This version of bloom requires catkin_pkg version >= '0.3.8',"
" the used version of catkin_pkg is '{0}'".format(catkin_pkg.__version__))
from catkin_pkg import metapackage
Expand Down
4 changes: 2 additions & 2 deletions bloom/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from subprocess import PIPE
from subprocess import CalledProcessError

from pkg_resources import parse_version
from packaging import version

from bloom.logging import debug
from bloom.logging import error
Expand Down Expand Up @@ -686,7 +686,7 @@ def get_last_tag_by_version(directory=None):
versions = []
for line in output.splitlines():
tags.append(line.strip())
versions.append(parse_version(line.strip()))
versions.append(version.parse(line.strip()))
return tags[versions.index(max(versions))] if versions else ''


Expand Down
17 changes: 6 additions & 11 deletions bloom/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
import datetime
import os
from platform import mac_ver
try:
from pkg_resources import parse_version
except OSError:
os.chdir(os.path.expanduser('~'))
from pkg_resources import parse_version
import re
import string
import sys
Expand All @@ -60,7 +55,7 @@

_emoji_check_mark = "✅ "
_emoji_cross_mark = "❌ "
_is_mac_lion_or_greater = parse_version(mac_ver()[0]) >= parse_version('10.7.0')
_is_mac = (mac_ver()[0] is not '')


def ansi(key):
Expand Down Expand Up @@ -127,17 +122,17 @@ def disable_ANSI_colors():
_ansi[key] = ''


def is_mac_lion_or_greater():
global _is_mac_lion_or_greater
return _is_mac_lion_or_greater
def _is_mac():
global _is_mac
return _is_mac


def get_success_prefix():
return _emoji_check_mark if _is_mac_lion_or_greater else "@{gf}<== @|"
return _emoji_check_mark if _is_mac else "@{gf}<== @|"


def get_error_prefix():
return _emoji_cross_mark if _is_mac_lion_or_greater else "@{rf}@!<== @|"
return _emoji_cross_mark if _is_mac else "@{rf}@!<== @|"


# Default to ansi colors on
Expand Down
4 changes: 2 additions & 2 deletions bloom/rosdistro_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import sys
import traceback

from pkg_resources import parse_version
from packaging import version

# python2/3 compatibility
try:
Expand All @@ -58,7 +58,7 @@

try:
import rosdistro
if parse_version(rosdistro.__version__) < parse_version('0.7.0'):
if version.parse(rosdistro.__version__) < version.parse('0.7.0'):
error("rosdistro version 0.7.0 or greater is required, found '{0}' from '{1}'."
.format(rosdistro.__version__, os.path.dirname(rosdistro.__file__)),
exit=True)
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'catkin_pkg >= 0.4.3',
'setuptools',
'empy',
'packaging',
'python-dateutil',
'PyYAML',
'rosdep >= 0.15.0',
Expand Down

0 comments on commit 1df61b7

Please sign in to comment.