Python modules are kind of complicated, but this at least gets defonce working, I think. I'm also not caching __main__, which is kind of the default. Making some other default would require deeper changes. I'm assuming that if you're importlib..reloading what's going to be __main__, it's not going to be called that (or the reload would bypass the if __name__ == "__main__" guard and restart your app.
This is required for defonce.
transpile
will also set__file__
.Python modules are kind of complicated, but this at least gets
defonce
working, I think. I'm also not caching__main__
, which is kind of the default. Making some other default would require deeper changes. I'm assuming that if you'reimportlib..reload
ing what's going to be__main__
, it's not going to be called that (or the reload would bypass theif __name__ == "__main__"
guard and restart your app.