librelist archives

« back to archive

question about 'packaging/deployement'

question about 'packaging/deployement'

From:
Sebastien Estienne
Date:
2010-05-18 @ 21:24
hello,

i read the page http://flask.pocoo.org/docs/patterns/distribute/

But it doesn't seem to cover the simple case: having only on python
file eg: hello.py
packages=['hello'] doesn't work.

or maybe i'm misunderstanding something.

I think it could help if the doc would contain an example hierarchy
like this page:
http://flask.pocoo.org/docs/patterns/packages/#larger-applications

i've a file webui.py and the static and templates folder.
i created a file setup.py / MANIFEST.in at the same level
and changes packages to packages=['webui']

but setup.py build returns
package directory 'webui' does not exist

should i move webui.py -> webui/__init__.py ?

thanx,
Sebastien Estienne

Re: [flask] question about 'packaging/deployement'

From:
Armin Ronacher
Date:
2010-05-18 @ 22:35
Hi,

On 5/18/10 11:24 PM, Sebastien Estienne wrote:
> But it doesn't seem to cover the simple case: having only on python
> file eg: hello.py
> packages=['hello'] doesn't work.
>
> or maybe i'm misunderstanding something.
The reason is on that page:

"In this case we assume your application is called yourapplication.py
  and you are not using a module, but a package. Distributing resources
  with standard modules is not supported by distribute so we will not
  bother with it."

> should i move webui.py ->  webui/__init__.py ?
Yes.  And add a second file called run.py next to webui with this as 
content:

     from webui import app
     app.run()

Because "python webui/__init__.py" to run the application does not work, 
it needs a separate file.  This is a limitation (well, it's not really a 
limitation, it makes perfectly fine if you know how the Python import 
system works) of Python we have to live with.

However for the package case I consider adding a function to flask 
itself so that you can run any Flask application like this:

     @ python -mflask webui

This would then run webui as development server.


Regards,
Armin