-
-
Notifications
You must be signed in to change notification settings - Fork 244
Remove the dependency on pkg_resources and hence setuptools
#292
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
Remove the dependency on pkg_resources and hence setuptools
#292
Conversation
…thon>=3.10 Signed-off-by: Varsha GS <[email protected]>
|
Fixes #291 |
|
To handle the unexpected keyword argument: if sys.version_info < (3, 10):
def entry_points(*, group):
return importlib.metadata.entry_points().get(group, ())
else:
entry_points = importlib.metadata.entry_points |
Signed-off-by: Varsha GS <[email protected]>
|
Thanks for the suggestion. Implemented the same with a try-except block. |
pkg_resources and hence setuptools on Python>=3.10pkg_resources and hence setuptools
|
Ah crap. Didn't see you had this PR against master. Couldn't understand why GitHub actions was failing as couldn't see why it was based off old version of code, so merged it unthinkingly. 😩 I'll sort it out, but keep in mind that PRs should be against develop branch. |
|
With a bit of AI copilot help have managed to clean up master. Now to work out how I can add a test which checks this case. I don't think anything I have no will strictly test this as these entry points are usually defined in separate packages. |
|
FWIW, when trying to work out some tests, the AI copilot flagged that code could be written as: Still evaluating this as well as whether tests it generated even test it. 🤣 |
|
Oh my bad, will keep that in mind. I saw that the package we install from I actually checked my code with this on This alternative works as well callback = entrypoint.load() # Use the loaded callback directly
register_post_import_hook(callback, entrypoint.name) |
setuptoolsis not included with the standard library sincePython>=3.12Although
importlib.metadatawas introduced in python 3.8, we get the below error inPython < 3.10Why?
In Python 3.12 and later, since setuptools is not included in standard library, discover_post_import_hooks() fails when setuptools is not installed in the environment.☹️ .
It took so much time to find that this is the actual problem because the function just returns bluntly and dynamic import at runtime with autowrapt simply didn't work