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

Add support for Out-of-Tree applets #213

Closed
wants to merge 5 commits into from

Conversation

attie
Copy link
Member

@attie attie commented Oct 9, 2020

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).

@attie attie force-pushed the out-of-tree branch 2 times, most recently from 243d80b to 78b5948 Compare October 9, 2020 22:22
@attie
Copy link
Member Author

attie commented Oct 9, 2020

Oh, the reasoning behind the GLASGOW_DISABLE_OOT environment variable (instead of a command line argument) is that the external applets should be listed in the glasgow run --help output, which is produced as soon as --help is found.

I couldn't see a good way to get and deal with a flag (or a missing flag) before the help output is produced.

@whitequark
Copy link
Member

whitequark commented Oct 10, 2020

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.'):
Copy link
Member Author

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.

@attie attie force-pushed the out-of-tree branch 2 times, most recently from f9235a4 to e77e376 Compare October 10, 2020 22:49
@whitequark
Copy link
Member

@attie FYI, I plan to address out-of-tree applets as a part of the item 3 from #234. Although I appreciate that you took time to do this, I think that none of the code in this PR can be integrated, and I would prefer if you let me do it as described in #234, instead. It would reduce wasted effort.

@attie
Copy link
Member Author

attie commented Dec 29, 2020

Oop, sure. I'd missed it / forgotten it was mentioned in that ticket.

@attie attie closed this Dec 29, 2020
@whitequark
Copy link
Member

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!)

@attie
Copy link
Member Author

attie commented Dec 29, 2020

Your PR predates that ticket!

Ha, so it does... (my brain does funny things with time)

Sounds good, let me know if I can help.

@whitequark
Copy link
Member

whitequark commented Dec 29, 2020

I'll probably get around to it once the Windows issues are fixed (#231). Do you feel like implementing a mutable counterpart to glasgow.support.bits to replace bitarray (#179)? We can do a quick discussion on IRC on the strategy for that.

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

Successfully merging this pull request may close these issues.

None yet

4 participants