10

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.

Community
  • 1
  • 1
Prembo
  • 2,256
  • 2
  • 30
  • 50

4 Answers4

5

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.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
2

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.

gomad
  • 1,029
  • 7
  • 16
2

My master thesis as a student was implemented in App Engine. The project is open source and you can use it however you like, I hope you will get the idea and you might adapt it to your needs.

topless
  • 8,069
  • 11
  • 57
  • 86
  • Hey -- I tried to check out your project but got "Error: You do not have access to this repository." at BitBucket. Is it still available? – marclar Apr 25 '12 at 15:52
  • I removed the previous version and I am close to finish the second one, misconfiguration. You can try again now. CoffeeScript is also included in the structure ;) – topless Apr 25 '12 at 19:16
  • 1
    For large scale projects I would strongly suggest having a look at this architecture http://gae-init.appspot.com/ – topless Apr 26 '12 at 16:22
1

The GAE Python SDK creates its own Virtual Environment when running on your local environment, so virtualenv won't help you much. There are frameworks like web2py and django-nonrel that works well with GAE, if you're up to porting your code, or at least take inspiration on their folder structure.

user83768
  • 154
  • 1
  • 4