Skip to content

Commit

Permalink
Replace pkg_resources.parse_version with packaging.version.parse (#693)
Browse files Browse the repository at this point in the history
* replace parse_version with packaging.version.parse

Signed-off-by: ijnek <kenjibrameld@gmail.com>

* lstrip upstream/

Signed-off-by: ijnek <kenjibrameld@gmail.com>

* prevent conflict of "version" word

Signed-off-by: ijnek <kenjibrameld@gmail.com>

* use regex to get version number

Signed-off-by: ijnek <kenjibrameld@gmail.com>

* Update bloom/logging.py

Co-authored-by: Jochen Sprickerhof <github@jochen.sprickerhof.de>

* import version.parse as parse_version

Signed-off-by: ijnek <kenjibrameld@gmail.com>

* change to use parse_version instead of version.parse, because "version" is used as variables everywhere

Signed-off-by: ijnek <kenjibrameld@gmail.com>

---------

Signed-off-by: ijnek <kenjibrameld@gmail.com>
Co-authored-by: Jochen Sprickerhof <github@jochen.sprickerhof.de>
  • Loading branch information
ijnek and jspricke authored Mar 10, 2023
1 parent 1c9b722 commit b34dad4
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install PyYAML argparse empy rosdep vcstools catkin-pkg python-dateutil
python -m pip install PyYAML argparse empy rosdep vcstools catkin-pkg python-dateutil packaging
python -m pip install nose coverage pep8
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion 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.version import parse as parse_version

try:
from urlparse import urlparse
Expand Down
2 changes: 0 additions & 2 deletions bloom/commands/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
import webbrowser
import yaml

from pkg_resources import parse_version

# python2/3 compatibility
try:
from urllib.error import HTTPError, URLError
Expand Down
2 changes: 1 addition & 1 deletion 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.version import parse as parse_version
from threading import Lock

_updater_running = False
Expand Down
2 changes: 1 addition & 1 deletion 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.version import parse as parse_version

from bloom.generators import BloomGenerator
from bloom.generators import GeneratorError
Expand Down
2 changes: 1 addition & 1 deletion bloom/generators/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

try:
import catkin_pkg
from pkg_resources import parse_version
from packaging.version import parse as parse_version
if parse_version(catkin_pkg.__version__) < parse_version('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__))
Expand Down
7 changes: 4 additions & 3 deletions bloom/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@

import os
import functools
import re
import shutil
import subprocess
import tempfile

from subprocess import PIPE
from subprocess import CalledProcessError

from pkg_resources import parse_version

from bloom.logging import debug
from bloom.logging import error
from bloom.logging import fmt
Expand Down Expand Up @@ -686,7 +685,9 @@ def get_last_tag_by_version(directory=None):
versions = []
for line in output.splitlines():
tags.append(line.strip())
versions.append(parse_version(line.strip()))
ver = re.match(r"[0-9]+\.[0-9]+\.[0-9]+", line)
if ver:
versions.append(ver)
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] != '')


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
2 changes: 1 addition & 1 deletion 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.version import parse as parse_version

# python2/3 compatibility
try:
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 b34dad4

Please sign in to comment.