colcon / colcon-core

Command line tool to build sets of software packages
http://colcon.readthedocs.io
Apache License 2.0
103 stars 46 forks source link

Fix entry point discovery on Python < 3.10 #604

Closed cottsay closed 8 months ago

cottsay commented 9 months ago

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 commented 9 months ago

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

cottsay commented 8 months ago

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 commented 8 months ago

Unrelated fix for CI: #606

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.