How to use custom python libraries and apps in Goo

2019-02-26 04:43发布

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条回答
Juvenile、少年°
2楼-- · 2019-02-26 05:22

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.

查看更多
登录 后发表回答