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

AttributeError due to improperly specified dependency #1644

Open
atleta opened this issue Jan 12, 2023 · 6 comments
Open

AttributeError due to improperly specified dependency #1644

atleta opened this issue Jan 12, 2023 · 6 comments

Comments

@atleta
Copy link

atleta commented Jan 12, 2023

5.2.4, as of now, throws an Attribute error when I try to run my (django) app:

  File ".../project/root_package/__init__.py", line 5, in <module>
    from .celery import app as celery_app
  File ".../project/root_package/celery.py", line 9, in <module>
    from raven.contrib.celery import register_logger_signal, register_signal
  File ".../project/env/lib/python3.7/site-packages/raven/contrib/celery/__init__.py", line 13, in <module>
    from celery.signals import (
  File ".../project/env/lib/python3.7/site-packages/celery/signals.py", line 14, in <module>
    from .utils.dispatch import Signal
  File ".../project/env/lib/python3.7/site-packages/celery/utils/__init__.py", line 16, in <module>
    from .nodenames import nodename, nodesplit, worker_direct
  File ".../project/env/lib/python3.7/site-packages/celery/utils/nodenames.py", line 6, in <module>
    from kombu.entity import Exchange, Queue
  File ".../project/env/lib/python3.7/site-packages/kombu/entity.py", line 7, in <module>
    from .serialization import prepare_accept_content
  File ".../project/env/lib/python3.7/site-packages/kombu/serialization.py", line 440, in <module>
    for ep, args in entrypoints('kombu.serializers'):  # pragma: no cover
  File ".../project/env/lib/python3.7/site-packages/kombu/utils/compat.py", line 82, in entrypoints
    for ep in importlib_metadata.entry_points().get(namespace, [])
AttributeError: 'EntryPoints' object has no attribute 'get'

The reason apparently is that importlib_metadata has released v 6.0.0 which changed the API and broke Kombu. Celery has a similar bug last April. These kind of bugs will keep popping up until you specify not just the minimum but also the maximum version for your dependencies. Please consider pinning all your dependencies with a maximum version number too.

@open-collective-bot
Copy link

Hey @atleta 👋,
Thank you for opening an issue. We will get back to you as soon as we can.
Also, check out our Open Collective and consider backing us - every little helps!

We also offer priority support for our sponsors.
If you require immediate assistance please consider sponsoring us.

@auvipy
Copy link
Member

auvipy commented Jan 13, 2023

#1601 should fix this already

@atleta
Copy link
Author

atleta commented Jan 13, 2023

@auvipy No, it doesn't. It does fix the code, that was broken by the change in the dependency, it does not fix the problem. Next time there is a breaking change importlib_metadata (or any other dependency) the same thing will happen. You can't claim that your code is compatible with all future versions of your dependencies, but this is what you do when you only specify a minimum version requirement.

The problem is actually even worse than this: if someone pins a specific version of kombu (or, more likely, celery) and there is a breaking change in the dependencies a few releases down the line, then they are screwed, because they won't be able to upgrade. Of course, everyone can debug it themselves and figure out which version to pin the dependency at, but wouldn't it be simpler if the project maintainers did it?

In this case, the maintainer of importlib_metadata claims that this specific API has been depricated for 1.5 years, with the code printing warnings. (Though it would have probably been better if it stated the version it will be removed in because that may have maybe inspired you to use it in the pin.)

@auvipy
Copy link
Member

auvipy commented Jan 13, 2023

you are welcome to contribute a fix you think better

@atleta
Copy link
Author

atleta commented Feb 8, 2023

Thanks for the detailed answer. Thoughtfull but compact responses like this, packed with arguments prove that it's worth giving detailed feedback and suggestions then extend it with further explanations if one feels that they weren't able to put all the details into the original report.

This also gives me sufficient trust that my contribution will be accepted, so I'll clone the project and add the missing 5 or so characters.

@auvipy
Copy link
Member

auvipy commented Feb 8, 2023

I will be happy to review you PR and merge within reasonable time frame.

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

No branches or pull requests

2 participants