use importlib instead of pkg_resources
Description of feature
__init___.py uses _pkg_resources.get_distribution("nf_core").version but from Python 3.8 on it is recommended to use from importlib.metadata import version; version('nf_core') instead. Once support for Python 3.7 is dropped, this should be changed.
I could not find any instances of _pkg_resources in the nf-core/tools repo. Could this have been resolved already @fabianegli?
Should be here: https://github.com/nf-core/tools/blob/9ab896c140ee3fde816d250f3d8353aee5547d78/nf_core/download.py#L24
Hey @sofiahag thanks - it looks like this is a different instance to the one mentioned in the ticket. I assume that if the instances mentioned in this ticket have been removed already, we can remove this instance that you mentioned without breaking Python 3.7 compatibility (if this is still required). Are the supported Python versions documented anywhere, please?
I searched through the repo and it looks like Python > 3.8 is supported now
Yes, We dropped support for Python 3.7 at the last hackathon.
If anyone wants to take care of it, this is the warning which triggered the issue:
[...]/tools/nf_core/download.py:24: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import parse_version as VersionParser
One option to handling it would be to use the version parsing provided by packaging but it would probably need some small code changes besides just the replacement of function that parses the string, but
from packaging import version
version.parse("2.3.1").release
could be close enough for the sorting here:
https://github.com/nf-core/tools/blob/9ab896c140ee3fde816d250f3d8353aee5547d78/nf_core/download.py#L1526-L1532