-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Guard against missing setuptools #1100
Conversation
Are you on the latest astroid ? We used |
@Pierre-Sassoulas I am on the latest. The trouble is this line in return pkg_resources is not None and modname in pkg_resources._namespace_packages I believe you can't access that without |
The code should not fail though, it's guarded by a try catch: try:
import pkg_resources
except ImportError:
pkg_resources = None
def is_namespace(modname):
return pkg_resources is not None and modname in pkg_resources._namespace_packages I don't know how it's possible that you had an error. Did you do something particular to get the error ? It also look like |
But that line doesn't guard against the missing Right now, I can't reproduce the error I got though. What I remember is that pylint was failing with that cryptic error, and then I installed setuptools and the error went away. I wish I could reproduce it. |
It's possible that it's worse than just a dependency to setuptools and that we're depending on a specific version of setuptools ( |
I actually tested this, and found that pylint fails with setuptools version 10, but it's mainly because setuptools 10 doesn't seem to work at all. Not sure if that's actually a problem.
Yes, that would be awesome if it's possible. |
Maybe you could just add another guard? return pkg_resources is not None and and hasattr(pkg_resources, '_namespace_packages') and modname in pkg_resources._namespace_packages |
Yeah you're right, let's do the fast fix and open another issue for the refactor. Do you want to add this to your MR ? |
Okay I'll do that |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank for the fix. I think we might still need to add setuptools to the requirements (because of distutils used elsewhere) and you should add yourself to the contributor. Maybe you could rebase this on your original changes if you still have the commit name ?
I overwrote it. It's just one extra line in your requirements, right? And I'll happily add my name to contributors. |
Done, except I couldn't find the contributors list ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho nevermind for the contributors I'm confusing astroid with pylint where there is a Contributors.txt. git is tracking all this anyway :)
Without the dependency on setuptools, poetry won't update setuptools when updating astroid. And if a user uninstalls setuptools, poetry won't reinstall it when updating. This causes the cryptic error "'pkg_resources' has no attribute '_namespace_packages' " when running pylint.