-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Vendoring of importlib_metadata
is shadowing actual package
#3113
Comments
Are you sure? Setuptools started vendoring It'd be good to know if 6.9.0 experiences the undesirable behavior you report. This issue is particularly tricky because:
Can you speak a little more to the impact of this issue? Other than that the entry_point values have unexpected origins, what is the concern (why not just ignore it)? Have you considered not importing setuptools? I expect Setuptools to be used primarily as a build backend for building packages, where I would not expect the class of EntryPoint to be particularly relevant. What is your usage of |
Thanks @jaraco for the detailed comment.
I am not an expert, so I probably described the exact cause incorrectly. But what I reported as the observed behavior seems to be reproducible. It seems then maybe that when setuptools started using it, the behavior was triggered.
I will do this test later and report back with the results.
We discovered the problem, because in our application we have the following logic: from importlib_metadata import EntryPoint
if isinstance(some_variable, EntryPoint):
# Some logic With
We don't install nor import it in our package, but for the bug to manifest, |
The behavior for 60.9.0 is identical to that of 60.9.1: Python 3.8.10 (default, Nov 26 2021, 20:14:08)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import setuptools
In [2]: setuptools.__version__
Out[2]: '60.9.0'
In [3]: from importlib_metadata import entry_points
In [4]: ep = entry_points().select(group='aiida.calculations', name='core.arithmetic.add')['core.arithmetic.add']
In [5]: type(ep)
Out[5]: setuptools._vendor.importlib_metadata.EntryPoint
In [6]: str(ep)
Out[6]: "EntryPoint(name='core.arithmetic.add', value='aiida.calculations.arithmetic.add:ArithmeticAddCalculation', group='aiida.calculations')" |
If Edit: I found an instance of I assume this has to do with python/cpython#88779 ? Not sure. Or more likely python/importlib_metadata#396 |
setuptools version
setuptools==60.9.1
Python version
Python 3.8 and Python 3.9
OS
Ubuntu 20.04
Additional environment information
No response
Description
Since
setuptools
started vendoringimportlib_metadata
it is shadowing the actual package. This means that the type of entry points are no longer the class provided by the originalimportlib_metadata
but the vendored package instead. Example:Expected behavior
Installing
setuptools
should not have its vendored library shadow the real one changing the types returned by functions of theimportlib_metadata
package.How to Reproduce
setuptools>=60.9.0
in Python 3.8 or Python 3.9Output
Behavior of
setuptools==60.8
Behavior of
setuptools>=60.9.0
Note how the type of the return value of
entry_points().select
has changed.The text was updated successfully, but these errors were encountered: