Skip to content

Commit 62370e3

Browse files
committed
refactor(python): replace deprecated pkg_resources (#302)
Replace `pkg_resources` with the modern `importlib.metadata` API to resolve deprecation warnings. Closes reanahub/reana-commons#502
1 parent 4b6dbb7 commit 62370e3

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

reana_workflow_engine_cwl/main.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import os
1616
import sys
1717
from io import StringIO
18+
from importlib.metadata import version, PackageNotFoundError
1819

1920
import cwltool.main
20-
import pkg_resources
2121
from cwltool.context import LoadingContext
2222
from reana_commons.config import REANA_LOG_FORMAT, REANA_LOG_LEVEL, REANA_WORKFLOW_UMASK
2323

@@ -35,10 +35,9 @@
3535

3636
def versionstring():
3737
"""Return string with cwltool version."""
38-
pkg = pkg_resources.require("cwltool")
39-
if pkg:
40-
cwltool_ver = pkg[0].version
41-
else:
38+
try:
39+
cwltool_ver = version("cwltool")
40+
except PackageNotFoundError:
4241
cwltool_ver = "unknown"
4342
return f"{sys.argv[0]} {__version__} with cwltool {cwltool_ver}"
4443

0 commit comments

Comments
 (0)