posts/plugins-as-python-native-namespace-packages/ #28
Replies: 7 comments
-
Thanks for this confirmation of what my own researches were leading me towards. The scenario you lay out at the end is exactly what I wanted, but I really don't want to give up on my init.py in the top level namespace of the original package, as that imports various functions, classes etc. into the main namespace, including things as basic as a version string. My current thought for a fix is to create a separate top level (namespace) package for the plugins, which can do without the init.py, but I suspect there will be some issues I haven't yet thought of. |
Beta Was this translation helpful? Give feedback.
-
Glad to see I'm not the only one with this idea! So, what you are thinking about is to have your regular main package, lets call it
The main package would then be able to import plugins from the namespaced That's a very nice idea! I'll try to think a bit more about it and see if I could apply it to my own project 🙂 Thanks a lot for sharing 😄 |
Beta Was this translation helpful? Give feedback.
-
I can see a limitation indeed. Lets say the main package lists the plugins one as a dependency to provide some "builtin" plugins, like a plugin whose module is named Possible answers to this are:
|
Beta Was this translation helpful? Give feedback.
-
Your summary is exactly what I was thinking of, I was thinking of using straight.plugin to handle the loading part. My use case is in image processing - I want the user to basically have a list of plugins that will each transform an image and that can come from a variety of packages installed on the same namespace. Supporting overriding is not something I was worried about but I did have the concern of possible namespace clashes. I don't really know what to do about that and I haven't been able to find any references as to what happens under those circumstances. In my case I primarily want the plugin architecture so I can have individual versioning on each plugin, I will probably be writing most of the plugins myself so can avoid that problem, but in general I don't have a good solution. Even if we separate out the native plugins, there is nothing stopping people trying to install two plugin packages that compete for the same module name. |
Beta Was this translation helpful? Give feedback.
-
Yeah you're right. Actually I'm not even sure overriding is possible with current mkdocstrings architecture. I guess I'll update the docs to say that overriding builtin plugins is not possible, and two plugins using the same module names is not supported either. |
Beta Was this translation helpful? Give feedback.
-
Do you have any new ideas on this? Also running in the same problem, but no real elegant solution yet... |
Beta Was this translation helpful? Give feedback.
-
Well, I've been playing more and more with namespace packages (actually trying to support them in a project of mine), and I can tell you that namespace packages are complicated. Two packages of the same namespace can be installed in the same folder, or in different folders (different entries in |
Beta Was this translation helpful? Give feedback.
-
Python packages and plugins as namespace packages - pawamoy's website
Findings, thoughts, tutorials, work. Pieces of my mind!
https://pawamoy.github.io/posts/plugins-as-python-native-namespace-packages/
Beta Was this translation helpful? Give feedback.
All reactions