-
Notifications
You must be signed in to change notification settings - Fork 201
Add support for Out-of-Tree applets #213
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
Conversation
243d80b
to
78b5948
Compare
Oh, the reasoning behind the I couldn't see a good way to get and deal with a flag (or a missing flag) before the help output is produced. |
The situation here is a bit similar with #211, I'll make sure to do a proper review here though as it's a pretty crucial feature. |
@@ -27,6 +27,10 @@ def __new__(metacls, clsname, bases, namespace, name=None, **kwargs): | |||
namespace["has_custom_repl"] = False | |||
|
|||
cls = ABCMeta.__new__(metacls, clsname, bases, namespace, **kwargs) | |||
|
|||
if not namespace['__module__'].startswith('glasgow.applet.'): |
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 suspect there's a better way to handle this... I'm open to suggestions.
f9235a4
to
e77e376
Compare
Oop, sure. I'd missed it / forgotten it was mentioned in that ticket. |
Your PR predates that ticket! At the time I thought the task would be a lot simpler than I currently think it is, so for a while I was going to integrate your PR, but now I see this as much more of a dependency management problem than a simple matter of hooking up the entry points. (I even think we can have out-of-tree applets that do not have an associated pip package, which would indeed be convenient--all of our in-tree applets are basically that!) |
Ha, so it does... (my brain does funny things with time) Sounds good, let me know if I can help. |
It sounded like this was a reasonable idea when we were discussing it the other day... and I think I'd appreciate it!
Fundamentally, this implements the ability to add (or subclass) applets that are stored out-of-tree, and in another package.
A basic example that re-implements the
UARTApplet
is given in/examples/out-of-tree-applet/
.I've used the
glasgow
entrypoint for this, but I've not looked to see if that's already used by another project (the package name is free on pypi still, so I feel it's somewhat safe... perhaps "we" should grab it?).Due to the way that merely declaring a subclass of
GlasgowApplet
will register the applet, we don't need to give the specific module / class name in the entry point... so long as it's parsed and loaded it'll be available.All external applets are tagged
[Out-of-Tree]
in the help output.Setting
GLASGOW_DISABLE_OOT
in your environment will disable all external applets (may be helpful if/when issues arise).