I think importlib.metadata import version; __version__ = version('<package_name>') is now the recommended way to get the version of an installed package. Except that I guess it makes things a bit slower and I don't know how stable that is. So I chose to still rely on trying first to get the version from _version.py (automatically created by hatch-vcs/setuptools-scm) and only then, if it fails like in #897, to try to get it using importlib.
Fixes #897
I think
importlib.metadata import version; __version__ = version('<package_name>')
is now the recommended way to get the version of an installed package. Except that I guess it makes things a bit slower and I don't know how stable that is. So I chose to still rely on trying first to get the version from_version.py
(automatically created by hatch-vcs/setuptools-scm) and only then, if it fails like in #897, to try to get it usingimportlib
.