-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Only load distribution of a name once #25296
Conversation
67f8abf
to
4d7cdc7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks okay, but (I think) we need to expand the tests to cover this behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Tests woudl be good..
I’ve added a test for the function. |
4d7cdc7
to
001d139
Compare
Tests failing :( |
001d139
to
a2cdce1
Compare
self.dist = dist.metadata['name'] | ||
self.dist = dist.metadata['Name'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python pacakge metadata keys are case-insensitive, I use Name
(the case used by the standard) everywhere so tests are easier to write.
This mimics the import system's behavior -- package of a name in front of sys.path "shadows" the one in the back, and should avoid a package from being loaded multiple times, if its containing directory appears multiple times in sys.path. This also causes a side effect: if there are *different* plugins of the same name, previously the one later in sys.path would have been discovered, but now it wouldn't. This is a reasonable compromise to me, since loading multiple packages of one same name is never a good idea in Python, and we should have been careful to preclude the possibility to begin with.
a2cdce1
to
1e7b5ec
Compare
Looks green now. @ashb ? |
(cherry picked from commit c30dc5e)
(cherry picked from commit c30dc5e)
This mimics the import system's behavior -- package of a name in front of
sys.path
"shadows" the one in the back, and should avoid a package from being loaded multiple times, if its containing directory appears multiple times insys.path
.This also causes a side effect: if there are different plugins of the same name, previously the one later in
sys.path
would have been discovered, but now it wouldn't. I think this is a reasonable compromise, since loading multiple packages of one same name is never a good idea inPython in the first place, and we should have been careful to preclude the possibility to begin with.
Should fix #25271. cc @rino0601 @bmoon4