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

Support for plugins #1258

Closed
geier opened this issue May 24, 2023 · 10 comments · Fixed by #1312
Closed

Support for plugins #1258

geier opened this issue May 24, 2023 · 10 comments · Fixed by #1312

Comments

@geier
Copy link
Member

geier commented May 24, 2023

We should support plugins, probably most useful for UI changes. There have been several suggested major changes or additions to the UI (as PRs). I'm hesitant to merge (or even getting them to a state to be mergable). In the past, some of those bigger merged PRs let to code that needed to be maintained by the "core team" and for other, they just go against my personal preferences. Having the ability to support plugins would solve those issues, as those UI changes could be supported by other parties out of tree.

Does anyone have experience with supporting plugins in python code bases? My first naive idea would be to load any python module placed in a specific directly, probably after all click related parts have been initialized.

@choucavalier
Copy link
Contributor

i'm not sure exactly how to properly architecture khal's codebase to support plugins

are you suggesting that the plugin would modify or register new cli functionalities? not sure exactly how this can be done but it really makes me think of the pdbpp project which works by extending the Python debugger (pdb) without pdb explicitly supporting any "plugin". i think pdbpp just comes to slightly modify ("patching") pdb's code in some way? haven't looked at the code but it works out of the box and "replaces" (not really because it's just a better UX) pdb

@geier
Copy link
Member Author

geier commented Jun 26, 2023

In #1279, I experimented with the "load all python modules in xdg_data_home/khal/plugins/ approach and at least for loading color themes it seems to work fine. Not sure yet how it would work with new (click) commands.

@geier
Copy link
Member Author

geier commented Jul 5, 2023

Some python plugin frameworks:

@choucavalier
Copy link
Contributor

pluggy looks like the best option:

  • good architectural system, according to the "How does it work" section of the main page of the documentation
  • well maintained (commits every week)
  • battle-tested by pytest, which is invaluable

@tcuthbert
Copy link
Contributor

tcuthbert commented Jul 11, 2023

Some python plugin frameworks:

I missed this!

I got a start on a very basic way of registering plugins, similar to how mdformat works (i.e. with global maps, callables and interfaces).

I wouldn't have thought too many third party plugins would be needed, making a plugin manager overkill, but I can see the value in less boiler plate.

I'm not attached to my work, happy to help integrate a 3rd party library too.

@geier
Copy link
Member Author

geier commented Aug 16, 2023

@tcuthbert I'm also not attached to any of those frameworks.

@geier
Copy link
Member Author

geier commented Oct 29, 2023

@tcuthbert
I have tried something very simple at #1309 and #1303 but I believe your approach using importlib is much smarter. I'll try to rebase #1309 and #1303 and the example plugins on your branch.

@geier
Copy link
Member Author

geier commented Oct 29, 2023

I have merged @tcuthbert's and my work at #1312

@tcuthbert
Copy link
Contributor

tcuthbert commented Oct 29, 2023 via email

@geier
Copy link
Member Author

geier commented Oct 30, 2023

Excellent! I ended up starting a new job and lost all my free time to work on it.

I hope, it's fun and pays well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants