-
-
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] Setuptools overriding standard lib importlib.metadata.PathDistribution
#3169
Comments
fwiw, git bisect puts this at 2d6cc80 (before that the following script would exit successfully) from importlib import metadata
assert isinstance(metadata.distribution('pip'), metadata.Distribution)
import setuptools
assert isinstance(metadata.distribution('pip'), metadata.Distribution) (but it's possible i didn't setup the setuptools dev environment properly and that's a red herring 😄 ) |
Hi @tlambert03 thank you very much for the in-depth study about this behaviour. Do you have a use case that depends on the particular implementation of the I was going through the Is |
Thanks @abravalheri, I found this issue while working on the plugin architecture for a program that I work on (napari). I have a bit of code that checks From a typing perspective, my code was sound. For example if you run the following script through mypy: from importlib import metadata
d = metadata.distribution('pip')
reveal_type(d) the output will be:
however, because One could certainly make the argument that I should only be doing structural typing, and should not have used
I agree! definitely fine to add stuff to meta_path: I guess more than anything, I'm wondering why the |
Thanks for the quick response @tlambert03.
According to #3102, the versions of A very similar behaviour will also be observed if at any point the user of your program installs a package inside the same virtual environment that uses the I think the best here is to do a structural check, since setuptools is not the only dependency that can break your plugin architecture. |
I agree. thanks for having a look. If you feel like this is just how it's going to be, I can close this issue (but feel free to re-open if you think there's anything actionable here on your end) |
I think it would be nice to avoid breaking the users' expectations like it is happening right now, but since this workaround comes directly from This workaround also seems necessary for |
you have a nearly impossible task here at setuptools :) keep up the good work |
setuptools version
60.9.3
Python version
python 3.9
OS
macOS
Additional environment information
Description
this seems similar to #3102, but issue was closed by #3108, without activity since then, and I still seeing this issue in the latest release.
importing setuptools overrides/removes the behavior and return type of of the standard library
importlib.metadata.distribution()
function:Expected behavior
importing setuptools doesn't supersede/remove the distribution finder from standard library importlib
How to Reproduce
setuptools
importlib.metadata.distribution()
Output
The text was updated successfully, but these errors were encountered: