Use importlib.metadata instead of deprecated pkg_resources#2096
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2096 +/- ##
=======================================
Coverage 93.09% 93.09%
=======================================
Files 237 237
Lines 12794 12795 +1
=======================================
+ Hits 11910 11911 +1
Misses 884 884
|
|
I'm not able to reproduce the issue reported by Codacy locally and usage with a |
valeriupredoi
left a comment
There was a problem hiding this comment.
@bouweandela there is an issue with this implementation in Python 3.9, bud. I'll also have a look, possibly Codacy is complaining for the same reason
|
first clue as for the fail issue - there are two slightly different packages installed (for all Python versions, not just 3.9): this no bueno. Lemme dig deeper |
|
so
|
|
@zklaus what's the best way to report a broken package to conda-forge? Via gitter or open an actual issue? 🍺 |
|
OK gotcha - iris needs both importlib_metadata and importlib-metadata (hopefully not via one of their deps) |
it's in fact via |
|
Note that this module is part of the standard library: https://docs.python.org/3.11/library/importlib.metadata.html. I guess something changed between Python 3.9 and 3.10, though it isn't immediately obvious from the documentation. It looks like API docs are completely missing for the module. |
|
ah then I chased a red herring then 🐟 - still, for Python 3.9 and only for Python 3.9 there are two Look at the sizes of the pkgs - lemme try try not specifying |
|
boom! Problem solved - by good old conda-forge packaging 😁 If you want to you can add |
|
OK, but the point of this pull request was to use the Python standard library instead of the package that backports that to older Python versions. I'll have a look if I can get it to work for Python 3.9 when I have some time. |
|
Why are you keen on using the standard library - as you can see from here, the c-f package is more stable, rather, I thought the idea was to retire pkg_resources 🍺 |
|
I'd like to explain a bit the ecosystem. Pypi decided that So when you depend on
How did you come to this conclusion? The conda-forge packages are |
| self.recipes = Recipes() | ||
| self._extra_packages = {} | ||
| if not list(iter_entry_points('esmvaltool_commands')): | ||
| if not list(entry_points(group='esmvaltool_commands')): |
There was a problem hiding this comment.
We should probably avoid calling entry_points twice. Do we really need to turn this into a list? Or would if not entry_points(... work?
You are looking in the wrong place. We don't care about Anaconda packages; the corresponding Conda-forge package is alive and well at https://anaconda.org/conda-forge/importlib_metadata. |
|
To record some insight we generated at the workshop yesterday: In Python 3.9, Both The downside is that from 3.10 on, this usage is deprecated and will generate a |
b4fd2fe to
a97befd
Compare
|
Should we really be removing We should be using |
|
PS: Seems the only place where this is used is at ESMValCore/esmvalcore/config/_config.py Line 24 in 91aa9e4 |
|
Yes, I forgot to remove that code when dropping support for Python 3.8 in #2053 and then I spotted the old dependencies, thought I might as well replace them with what we currently need. Did a grep through the code for any uses, but apparently missed the use in esmvalcore/config/_config.py. |
|
python=3.8 went to the fishes a while back, Klaus 🐟 |
zklaus
left a comment
There was a problem hiding this comment.
Except for the github actions trigger I think this is ok.
As a side note, we might want to change the name for the entry points group to esmvaltool.commands. That would be more in line with the specification and prepare us for possible future entry points esmvaltool.recipes and esmvaltool.diagnostics.
| push: | ||
| branches: | ||
| - main | ||
| - use-importlib-metadata |
Description
Closes #2094
Before you get started
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.
To help with the number pull requests: