Skip to content
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

Fix entry point discovery on Python < 3.10 #604

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

cottsay
Copy link
Member

@cottsay cottsay commented Jan 4, 2024

It seems that the behavior of the importlib.metadata.entry_points function changed in Python 3.10 to automatically de-duplicate distributions, but prior to that the "shadowed" distributions were also enumerated. This change specifically ignores "shadowed" distributions so that they aren't identified as extension point overwrites.

Fixes #562
Closes #596
When released, will eventually close ros2/ci#737.

@cottsay cottsay added the bug Something isn't working label Jan 4, 2024
@cottsay cottsay self-assigned this Jan 4, 2024
@cottsay
Copy link
Member Author

cottsay commented Jan 4, 2024

Looks like a change in setuptools broke the unit tests (which is distinctly unsurprising). I'll follow up with a fix tomorrow.

Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all just questions, since I'm not really familiar with all of this:

  1. What does a 'distribution' mean in this context?
  2. What order are 'distribution's returned from distribution()? Alphabetical? Path-length? Something else?

@cottsay
Copy link
Member Author

cottsay commented Jan 17, 2024

What does a 'distribution' mean in this context?

In short: there is a 1-to-1 mapping of distributions and things that you can "pip install". Distributions can carry more than one top-level module, but you can think of distributions as a "python package" to some extent.

What order are 'distribution's returned from distribution()? Alphabetical? Path-length? Something else?

From what I can tell, the path discovery order is respected but I'm not sure the order within each path is consistent. If you have a distribution "A-1.0" on your system and it is shadowed by a distribution "A-1.1" by something on your PYTHONPATH, you should always discover "A-1.1" first.

Later versions of importlib.metadata make this discovery process easier but I think we need to drop Python 3.6 and 3.7 support to access those new functions.

@cottsay
Copy link
Member Author

cottsay commented Jan 17, 2024

Unrelated fix for CI: #606

It seems that the behavior of the importlib.metadata.entry_points
function changed in Python 3.10 to automatically de-duplicate
distributions, but prior to that the "shadowed" distributions were also
enumerated. This change specifically ignores "shadowed" distributions so
that they aren't identified as extension point overwrites.
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d29f38d) 83.32% compared to head (f8439ff) 83.30%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #604      +/-   ##
==========================================
- Coverage   83.32%   83.30%   -0.02%     
==========================================
  Files          65       65              
  Lines        3760     3762       +2     
  Branches      725      727       +2     
==========================================
+ Hits         3133     3134       +1     
- Misses        551      552       +1     
  Partials       76       76              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cottsay cottsay merged commit 500dec0 into master Jan 17, 2024
35 checks passed
@delete-merged-branch delete-merged-branch bot deleted the cottsay/py39_entry_points branch January 17, 2024 22:05
@cottsay cottsay added this to the 0.15.2 milestone Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

RHEL CI jobs have many colcon warnings ERROR:colcon.colcon_core* is declared multiple times
2 participants