biolab / orange-canvas-core

Orange Canvas core workflow editor
GNU General Public License v3.0
36 stars 62 forks source link

Release 0.2.0 bug: get project name from entree point #292

Closed woutdenolf closed 9 months ago

woutdenolf commented 9 months ago

2023-12-15 13:45:42,261:ERROR:orangecanvas.registry.discovery: An exception occurred while processing EntryPoint.parse('Ewoks Demo = orangecontrib.ewoksdemo').
Traceback (most recent call last):
  File "/home/denolf/ewokstest/lib/python3.8/site-packages/orangecanvas/registry/discovery.py", line 141, in run
    self.process_category_package(
  File "/home/denolf/ewokstest/lib/python3.8/site-packages/orangecanvas/registry/discovery.py", line 213, in process_category_package
    cat_desc.project_name = distribution.name
  File "/home/denolf/ewokstest/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2900, in __getattr__
    return getattr(self._provider, attr)
AttributeError: 'PathMetadata' object has no attribute 'name'
``

It seems that the correct attribute is not 'name' but 'project_name' (I tried python 3.9 and 3.11).
woutdenolf commented 9 months ago

Seems like there are several places where this can occur:

https://github.com/biolab/orange-canvas-core/blob/124c559535f586b95beaf656aac3a4b811761638/orangecanvas/registry/discovery.py#L213

https://github.com/biolab/orange-canvas-core/blob/124c559535f586b95beaf656aac3a4b811761638/orangecanvas/registry/discovery.py#L352

https://github.com/biolab/orange-canvas-core/blob/124c559535f586b95beaf656aac3a4b811761638/orangecanvas/registry/discovery.py#L372

https://github.com/biolab/orange-canvas-core/blob/124c559535f586b95beaf656aac3a4b811761638/orangecanvas/registry/discovery.py#L415

woutdenolf commented 9 months ago

The distribution variable seems to be of type pkg_resources.DistInfoDistribution which does not have a name attribute.

woutdenolf commented 9 months ago

Problem seems to be this commit: https://github.com/biolab/orange-canvas-core/commit/488f691d1dbd3dda3c764703a62f96e6be8c4979#diff-8a4d7e657dbf9ce778437786cf1a4cfb7df551c2faf7792be0b7cd65ff191587

Ping @ales-erjavec

woutdenolf commented 9 months ago

When running the tests of this project the distribution variable type is importlib.metadata.PathDistribution which does have a name attribute.

However when getting the distribution from an entry point (not covered by the unit test but happens in reality) you get distribution variable type pkg_resources.DistInfoDistribution which does not have a name attribute (called project_name instead).

woutdenolf commented 9 months ago

In fact the issue lies in some of our projects:

  1. https://gitlab.esrf.fr/tomotools/tomwer/-/blob/main/orangecontrib/tomwer/widgets/__init__.py?ref_type=heads
  2. https://gitlab.esrf.fr/workflow/ewoks/ewoksorange/-/blob/main/src/ewoksorange/canvas/config.py?ref_type=heads

So this is not a bug but a breaking change for addons that define widget_discovery (similar to https://github.com/biolab/orange3/blob/master/Orange/widgets/__init__.py).

markotoplak commented 9 months ago

@woutdenolf, yes, orange-canvas-core 0.2.0 is indeed also incompatible with the current master of Orange (which depended on orange-canvas-core<0.2 for a long time now.

markotoplak commented 9 months ago

See https://github.com/biolab/orange3/pull/6655 for more info.