-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Fix version check for entrypoint plugins with unequal project/package names #2594
Fix version check for entrypoint plugins with unequal project/package names #2594
Conversation
I dug into the original issue just a bit (literally, this time) and found that we probably could differentiate the This PR works as a quick fix for the exact issue you ran into, but I do think the real solution should be actually handling entry points correctly (i.e. not just as "spicy modules" like the current impl). For checking the version in particular, an |
Bonked on the underlying issue here with my newest plugin project, which bundles multiple related plugins into a single package as My patch below is not tested thoroughly, but if you want to come back to this branch it already has a test ready and you probably have Tox set up locally to run said test suite across all supported Python versions. 😸 GitHub still has that annoying limitation on how far away from the actual change you can start a line note, so unfortunately I can't make this into a one-click suggestion: # inside `EntryPointPlugin.get_version()`; you already know where,
# since this PR already touches the same area 😉
if (
version is None
and hasattr(self.entry_point, "dist")
and hasattr(self.entry_point.dist, "name")
):
try:
version = importlib.metadata.version(self.entry_point.dist.name)
except Exception:
# fine, just give up
pass |
I was looking for that solution, and yes, this is exactly the right solution here, as demonstrated by this snippet of code (running with Python 3.10):
Once you have an Alternatively, I don't mind if we separate the plugin version from the package version, i.e. allow a Plugin author to use |
I think the intent is already there in the code, by checking whether the version is |
After discussing on IRC, what's left here is for me to integrate @dgw's suggested tweak, and also to see about adding a logger instance here to strike a balance between more broadly catching exceptions and falling back on the |
I had a partial implementation of what's discussed in #2594 (comment) and committed it on top of this branch to clean out uncommitted changes in my Gitpod workspace (they are apparently discontinuing their turnkey cloud IDE product, which sucks). CI failures appear unrelated; the error is in
Must have been an update somewhere since the last type-checking cleanup in #2614. |
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.
I approve on the premise that you'll rebase on master and solve the merge conflict. I added a nitpick but it's not blocking anything.
b545c27
to
bb0487e
Compare
Sorry about the force-push noise, but this should clear the unrelated typing problems in CI now and is ready for final review. Happy to squash it further if desired. |
Lovely! Reading your commit history, I think it's a good case for a squash into a single commit, because the code & test should go together here, and because the last commits erase/replace the initial commit's changes. |
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.
I agree with @Exirel about squashing to a single commit. While I could suggest merging some changes together and rearranging the chronology to make a multi-commit history that tells a coherent story about the feature, this patch isn't big enough to make it worth the time it'd take to carefully rewrite history that way.
Oh, I also played around a little and found that self.entry_point.dist
(if it exists) has a version
attr. I have not looked at all the edge cases that importlib.metadata.version()
should theoretically handle for us, though, so don't mess with the patch any more. This is a curiosity I wanted to mention, not patch feedback!
Co-authored-by: Florian Strzelecki <[email protected]>
bb0487e
to
8d6853e
Compare
Squishy squashed again, ready to rock |
Realized it's been over a week since this got squashed and readied for re-review… Had to tear myself away from working on updates to a Factorio mod (balance changes for 2.0, etc.) 😅 |
Description
Fixes #2593.
This changeset swallows all exceptions when trying to determine the version of an
EntryPointPlugin
, as there are more failure cases than what catchingValueError
specifically covers, and allowing those exceptions to propagate breaks plugin reloading.Checklist
make qa
(runsmake lint
andmake test
)1388 passed, 8 xfailed, 1 warning in 45.44s