Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to structure standard Python project (modules, libraries) for future use in Google App Engine?

I'm currently developing a Python project which is growing and I may implement it as a webapp in GAE in the future.

As the project is growing I'm pruning potentially reusable code into separate packages & modules, which at present are on my PYTHONPATH.

Do you have any advice on how to structure my project, and reusable packages so that it will fit nicely into a GAE project in the future?

Looking at recommendations on GAE project structure in other posts (such as this and this and this) seem fairly flat - is that the best way to go?

What about 3rd party packages/modules? Is it best to bite the bullet and use VirtualEnv from the beginning?

Thanks very much. Prembo.

like image 366
Prembo Avatar asked Oct 20 '11 22:10

Prembo


2 Answers

Just put your various libraries in packages off the root directory of your app. The root directory is automatically added to your app's sys.path.

If you wish you can put them in a lib directory off the root, you can do so, but you'll have to write a module that adds that directory to the end of sys.path, and import it before you import anything from lib.

Using virtualenv is an option, but I personally don't think it gains you much, since you can't run a virtualenv in production, and the dev_appserver emulates the production environment.

like image 136
Nick Johnson Avatar answered Sep 23 '22 04:09

Nick Johnson


I can't tell you about GAE in particular, but I can tell you that biting the bullet has nothing to do with it - using VirtualEnv (and virtualenvwrapper) will make your Python development smoother, simpler, and easier all around.

The over head is low, the benefits are many.

Switch. Now.

like image 35
gomad Avatar answered Sep 20 '22 04:09

gomad