How to use custom python libraries and apps in Google App Engine?

匆匆过客 提交于 2019-12-02 03:54:42

问题


I would like to know how to install and use third party libraries and/or apps in django nonrel at Google App Engine?

Currently my web application uses django-nonrel and I would like to install some libraries available in github:

Ususally libraries require installation via the pip or easy_install command:

$ pip install django-social-auth    

How can I install or use libraries in Google App Engine?

Sample App Structure:

myapp/
    lib/
        django-social-auth/     
    app.yaml
    index.yaml
    main.py
    views.py

回答1:


Put the library you want in the root of your app path (same place as your app.yaml). You will need to do this (or a variation) so that all the files of your library are uploaded to App Engine's servers when you deploy. Your actual PYTHONPATH on your machine isn't used directly.

One common variation to this is to put symlinks to your libraries in your main app path. So here are some variations:

  1. Use pip to install django-social-auth, and create the symlink myapp/social_auth to point to the place where pip installed social auth.

  2. Download the source from github and copy the social_auth folder directly into your myapp folder.

  3. Sync the github repo for django-social-auth, and create the symlink myapp/social_auth to point to the place django-social-auth/social_auth.



来源:https://stackoverflow.com/questions/15324136/how-to-use-custom-python-libraries-and-apps-in-google-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!