From 03b42a6852c03fce6332560f03778adc5f254cc4 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> Date: Wed, 29 Nov 2023 19:28:37 +0100 Subject: [PATCH] remove useage of the deprecated pkg_resources (#4701) setup.py: make clear that Python 3.7 is no longer supported Co-authored-by: Lon Blauvelt --- setup.py | 2 +- src/toil/cwl/__init__.py | 11 +++-------- src/toil/utils/toilMain.py | 4 ++-- version_template.py | 4 ---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index 4a4de0594c..1278326a93 100755 --- a/setup.py +++ b/setup.py @@ -98,7 +98,7 @@ def run_setup(): 'Topic :: System :: Distributed Computing', 'Topic :: Utilities'], license="Apache License v2.0", - python_requires=">=3.7", + python_requires=">=3.8", install_requires=install_requires, extras_require=extras_require, package_dir={'': 'src'}, diff --git a/src/toil/cwl/__init__.py b/src/toil/cwl/__init__.py index 390d2fda6a..70209d5436 100644 --- a/src/toil/cwl/__init__.py +++ b/src/toil/cwl/__init__.py @@ -14,7 +14,7 @@ import sys from functools import lru_cache -from pkg_resources import DistributionNotFound, get_distribution +from importlib.metadata import version, PackageNotFoundError try: # Setuptools 66+ will raise this if any package on the system has a version that isn't PEP440. @@ -39,7 +39,7 @@ def check_cwltool_version() -> None: warning will be printed. """ try: - installed_version = get_distribution("cwltool").version + installed_version = version("cwltool") if installed_version != cwltool_version: sys.stderr.write( @@ -47,11 +47,6 @@ def check_cwltool_version() -> None: f"not the version Toil is tested against. To install the correct cwltool " f"for Toil, do:\n\n\tpip install cwltool=={cwltool_version}\n\n" ) - except DistributionNotFound: + except PackageNotFoundError: # cwltool is not installed pass - except InvalidVersion as e: - sys.stderr.write( - f"WARNING: Could not determine the installed version of cwltool because a package " - f"with an unacceptable version is installed: {e}\n" - ) diff --git a/src/toil/utils/toilMain.py b/src/toil/utils/toilMain.py index cacc149e77..895bf44ad8 100755 --- a/src/toil/utils/toilMain.py +++ b/src/toil/utils/toilMain.py @@ -5,7 +5,7 @@ import types from typing import Any, Dict -import pkg_resources +from importlib.metadata import version as metadata_version from toil.version import version @@ -78,6 +78,6 @@ def printHelp(modules: Dict[str, types.ModuleType]) -> None: def printVersion() -> None: try: - print(pkg_resources.get_distribution('toil').version) + print(metadata_version('toil')) except: print(f'Version gathered from toil.version: {version}') diff --git a/version_template.py b/version_template.py index 23f7f1ed7e..2358ce8358 100644 --- a/version_template.py +++ b/version_template.py @@ -64,10 +64,6 @@ def mainCacheTag(): def distVersion(): """The distribution version identifying a published release on PyPI.""" - from pkg_resources import parse_version - if isinstance(parse_version(baseVersion), tuple): - raise RuntimeError("Setuptools version 8.0 or newer required. Update by running " - "'pip install setuptools --upgrade'") return baseVersion