diff --git a/colcon_core/package_identification/python.py b/colcon_core/package_identification/python.py index 9d5e467b..0b11c8aa 100644 --- a/colcon_core/package_identification/python.py +++ b/colcon_core/package_identification/python.py @@ -90,11 +90,17 @@ def get_configuration(setup_cfg): except ImportError: from setuptools.config import read_configuration except ImportError as e: - from pkg_resources import get_distribution - from pkg_resources import parse_version - setuptools_version = get_distribution('setuptools').version + try: + from importlib.metadata import distribution + except ImportError: + from importlib_metadata import distribution + from packaging.version import Version + try: + setuptools_version = distribution('setuptools').version + except ModuleNotFoundError: + setuptools_version = '0' minimum_version = '30.3.0' - if parse_version(setuptools_version) < parse_version(minimum_version): + if Version(setuptools_version) < Version(minimum_version): e.msg += ', ' \ "'setuptools' needs to be at least version " \ f'{minimum_version}, if a newer version is not available ' \ diff --git a/colcon_core/plugin_system.py b/colcon_core/plugin_system.py index cbaf090a..dc9df955 100644 --- a/colcon_core/plugin_system.py +++ b/colcon_core/plugin_system.py @@ -6,7 +6,7 @@ from colcon_core.entry_point import load_entry_points from colcon_core.logging import colcon_logger -from pkg_resources import parse_version +from packaging.version import Version logger = colcon_logger.getChild(__name__) @@ -166,8 +166,8 @@ def satisfies_version(version, caret_range): :raises RuntimeError: if the version doesn't match the caret range """ assert caret_range.startswith('^'), 'Only supports caret ranges' - extension_point_version = parse_version(version) - extension_version = parse_version(caret_range[1:]) + extension_point_version = Version(version) + extension_version = Version(caret_range[1:]) next_extension_version = _get_upper_bound_caret_version( extension_version) @@ -192,4 +192,4 @@ def _get_upper_bound_caret_version(version): minor = 0 else: minor += 1 - return parse_version('%d.%d.0' % (major, minor)) + return Version('%d.%d.0' % (major, minor)) diff --git a/colcon_core/task/python/test/pytest.py b/colcon_core/task/python/test/pytest.py index 6b51d267..335e2140 100644 --- a/colcon_core/task/python/test/pytest.py +++ b/colcon_core/task/python/test/pytest.py @@ -13,7 +13,7 @@ from colcon_core.task.python.test import has_test_dependency from colcon_core.task.python.test import PythonTestingStepExtensionPoint from colcon_core.verb.test import logger -from pkg_resources import parse_version +from packaging.version import Version class PytestPythonTestingStep(PythonTestingStepExtensionPoint): @@ -64,7 +64,7 @@ async def step(self, context, env, setup_py_data): # noqa: D102 # use -o option only when available # https://github.com/pytest-dev/pytest/blob/3.3.0/CHANGELOG.rst from pytest import __version__ as pytest_version - if parse_version(pytest_version) >= parse_version('3.3.0'): + if Version(pytest_version) >= Version('3.3.0'): args += [ '-o', 'cache_dir=' + str(PurePosixPath( *(Path(context.args.build_base).parts)) / '.pytest_cache'), @@ -95,7 +95,7 @@ async def step(self, context, env, setup_py_data): # noqa: D102 ] # use --cov-branch option only when available # https://github.com/pytest-dev/pytest-cov/blob/v2.5.0/CHANGELOG.rst - if parse_version(pytest_cov_version) >= parse_version('2.5.0'): + if Version(pytest_cov_version) >= Version('2.5.0'): args += [ '--cov-branch', ] diff --git a/debian/patches/setup.cfg.patch b/debian/patches/setup.cfg.patch index 14d9486e..add781c2 100644 --- a/debian/patches/setup.cfg.patch +++ b/debian/patches/setup.cfg.patch @@ -5,9 +5,9 @@ Author: Dirk Thomas --- setup.cfg 2018-05-27 11:22:33.000000000 -0700 +++ setup.cfg.patched 2018-05-27 11:22:33.000000000 -0700 -@@ -31,9 +31,12 @@ - distlib - EmPy +@@ -33,9 +33,12 @@ + importlib-metadata; python_version < "3.8" + packaging pytest - pytest-cov - pytest-repeat diff --git a/setup.cfg b/setup.cfg index b4b35334..f1ce310f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,6 +30,8 @@ install_requires = coloredlogs; sys_platform == 'win32' distlib EmPy + importlib-metadata; python_version < "3.8" + packaging # the pytest dependency and its extensions are provided for convenience # even though they are only conditional pytest diff --git a/test/spell_check.words b/test/spell_check.words index 1cb76afd..4d060a0a 100644 --- a/test/spell_check.words +++ b/test/spell_check.words @@ -47,6 +47,7 @@ hardcodes hookimpl hookwrapper https +importlib isatty iterdir junit