-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
distributions() finds two packages for editable installs #481
Comments
Interestingly... there's a difference in behavior for importlib.metadata in python3.10.12 and importlib_metadata 7.0.1. The latter behaves slightly better for src-style layouts, showing the second distribution package as having no files. But also, once I install importlib_metadata, |
The intended design is for importlib metadata (both versions) to reflect and honor the actual configuration. That is, if there are two metadata for the same package, they'll both be returned, but some functions, like That is to say, it is more-or-less working as intended. Ideally, this issue will be addressed by refining the packaging tools to only produce one copy of the metadata or to ensure that the preferred metadata is given precedence in sys.path.
That's because pip performs the specified name normalization before resolving the package name, so |
Cross-posting from pypa/setuptools#4170, since I'm not sure which is the right repo to fix this in, or whether both repos have something to consider here:
tl;dr: When setuptools does an editable install,
importlib.metadata.distributions()
finds aPathDistribution
for both thedist-info
directory in site-packages as well as aPathDistribution
for the localegg-info
directory. See the above issue for MWE repo. The current consequences for importlib.metadata are:distributions()
finds two distributionsdistribution(name)
gives a different distribution depending upon whether the package has a flat or src layout. In a flat layout, the egg-info distribution is found at""
( I think, because it's the first entry ofsys.path
), and in an src layout, the egg-info distribution is found in whatever folder is added by the .pth file created in an editable install (the last entry ofsys.path
).distributions_packages()
shows a single distribution package name with identical copies of import package names, e.g."foo": ["foo", "foo"]
So regardless of anything setuptools needs to do differently in creating editable installs, what is the expected behavior when importlib metadata finds multiple packages of the same name? I can think of a few options...
I can't think of a legitimate reason for two distribution package names to be installed simultaneously with the exact same import package names, so I'm not sure 1 is correct. But IIUC and I probably don't, 2 or 3 would change the expected behavior of a
DistributionFinder
, and I'm not sure what the performance cost of disambiguation would be.The text was updated successfully, but these errors were encountered: