-
-
Notifications
You must be signed in to change notification settings - Fork 419
Description
Consider:
>>> import attr
>>> attr.__version__
<stdin>:1: DeprecationWarning: Accessing attr.__version__ is deprecated and will be removed in a future release. Use importlib.metadata directly to query for attrs's packaging metadata.
'23.1.0'But the code wanting to get the version number from attr can't do this:
>>> import importlib.metadata as M
>>> M.version("attr")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/timj/work/lsstsw/miniconda/envs/lsst-scipipe-6.0.0/lib/python3.10/importlib/metadata/__init__.py", line 996, in version
return distribution(distribution_name).version
File "/Users/timj/work/lsstsw/miniconda/envs/lsst-scipipe-6.0.0/lib/python3.10/importlib/metadata/__init__.py", line 969, in distribution
return Distribution.from_name(distribution_name)
File "/Users/timj/work/lsstsw/miniconda/envs/lsst-scipipe-6.0.0/lib/python3.10/importlib/metadata/__init__.py", line 548, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for attrThis is fundamentally because there is no metadata for the attr package because it's all in the attrs package but the attrs package installs code into two separate namespaces and has no way of registering that fact with the installer.
The reason this is a problem for me is that we have some code that gathers version information for our running scientific pipeline code so that we can recreate the environment and have provenance information. The code doing this can't tell that attr is actually part of attrs and realizes that importlib.metadata does not work, so it falls back to __version__. This then results in a warning. I'm not sure what the solution is but thought I should mention the problem.