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

Tolerate distributions with no Name #368

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

cjwatson
Copy link
Contributor

@cjwatson cjwatson commented Jan 1, 2025

https://bugs.debian.org/1090247 shows a napari test failure caused by this on Python 3.13. On closer inspection I found that /usr/lib/python3.13/dist-packages/coverage-7.6.0.egg-info and /usr/lib/python3.13/dist-packages/tqdm-4.67.1.dist-info existed with no Name metadata field. This shouldn't cause a failure here.

https://bugs.debian.org/1090247 shows a napari test failure caused by
this on Python 3.13.  On closer inspection I found that
`/usr/lib/python3.13/dist-packages/coverage-7.6.0.egg-info` and
`/usr/lib/python3.13/dist-packages/tqdm-4.67.1.dist-info` existed with
no `Name` metadata field.  This shouldn't cause a failure here.
@jni
Copy link
Member

jni commented Jan 2, 2025

Thanks for the PR @cjwatson! You've caught us at an awkward time because npe2api relied on web scraping PyPI search results for some functionality, and that was recently broken by PyPI due to abuse. I think this is why the CI is failing. We're still figuring out the best fix but it'll probably be minimum 1-2 weeks until a fix because of the Christmas/New Year's break. 🙏

@jni
Copy link
Member

jni commented Jan 8, 2025

For other devs stumbling on this, this is the relevant bit of the report:

self = ReaderContribution(command='tmp_plugin._', filename_patterns=['*.fake'], accepts_directories=False)

    @property
    def plugin_name(self) -> str:
        """Return the manifest/plugin name for this contribution."""
        if not self._plugin_name:
            # we will likely never get here if the contribution was created
            # as a member of a PluginManifest.
            # But if not, we can use a couple heuristics...
            from importlib.metadata import distributions
    
            # look for a package name in the command id
>           dists = sorted(
                (d.metadata["Name"] for d in distributions()), key=len, reverse=True
            )
E           TypeError: object of type 'NoneType' has no len()

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e61a8af) to head (7b334e1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #368   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           37        37           
  Lines         2709      2709           
=========================================
  Hits          2709      2709           

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

@DragaDoncila
Copy link
Contributor

OK the reason we would ever be checking the plugin_name of tqdm here is because of the discover utility which goes through installed packages looking for npe2 manifests (or npe1 entrypoints). The effect of this change, I believe, is that if a napari plugin does not declare a name in its distribution metadata, it would not be discovered as a plugin. I think this is ok, and likely to be an extreme edge case, so I'm happy to merge the change as-is.

@jni jni merged commit 5fd114b into napari:main Jan 17, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants