Re: Resource loading (Django without a filesystem)

2019-06-27 Thread Peter Baumgartner
Unfortunately you can't load resources from implicit namespace packages. It raises `FileNotFoundError: Package has no location ` The __init__.py appears to be required. On Thu, Jun 27, 2019 at 3:05 PM Andrew Godwin wrote: > > Well, remember that in Python 3 you don't need an __init__.py file to

Re: Resource loading (Django without a filesystem)

2019-06-27 Thread Andrew Godwin
Well, remember that in Python 3 you don't need an __init__.py file to have something be a module (because of https://www.python.org/dev/peps/pep-0420/), but I wonder if there still needs to be a proper discovery mechanism that flags that they should be considered as implicit packages/modules.

Re: Resource loading (Django without a filesystem)

2019-06-27 Thread Peter Baumgartner
The big issue I see is that a resource must reside directly in a Python module. You can not load a resource from a child directory, e.g. I can load "index.html" from the Python module "myproject.templates", but I can't load "app1/index.html" from the same module. This would require developers to

Re: Resource loading (Django without a filesystem)

2019-06-27 Thread Andrew Godwin
My impression reading over the problem a little yesterday was that we could work to provide a common "get me a resource" abstraction in Django that papers over the couple of different ways it has to work, though I haven't looked super far into things that require directory listing (e.g.

Re: Resource loading (Django without a filesystem)

2019-06-27 Thread Markus Holtermann
Hi Peter, PyOxidizer looks indeed super interesting. Talking about templates and specifically Jinja2 templates, they are internally converted to the Python AST if I'm not mistaking. Turning them into Python modules that a new Jinja2ModuleTemplateLoader could load doesn't seem like that far

Resource loading (Django without a filesystem)

2019-06-27 Thread Peter Baumgartner
I'm interested in using PyOxidizer [1] to create single-file executable Django projects. This currently isn't possible because of all the places Django assumes it is operating on a proper filesystem. I haven't done a full audit, but templates, migrations, and static files come to mind. Python