如何在Google App Engine中使用自定义的Python库和应用程序? [英] How to use custom python libraries and apps in Google App Engine?

查看:92
本文介绍了如何在Google App Engine中使用自定义的Python库和应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在Google App Engine中安装和使用django nonrel中的第三方库和/或应用程序?



目前我的web应用程序使用django-nonrel,我想在github中安装一些库:



Ususally库需要通过pip或easy_install命令安装:

  $ pip install django-social-auth 

如何在Google App Engine中安装或使用库?



示例应用程序结构:

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


解决方案

将你想要的库放入应用程序路径的根目录(与app.yaml位置相同)。您需要执行此操作(或变体),以便在部署时将库的所有文件上载到App Engine的服务器。您的机器上的实际PYTHONPATH不会直接使用。



一个常见的变体是将符号链接放到您的主程序路径中的库中。因此,这里有一些变化:




  1. 使用PIP安装Django的社会身份验证,并创建符号链接的myapp / social_auth点到pip安装社交认证的地方。

  2. 从github下载源代码并将social_auth文件夹直接复制到myapp文件夹中。

  3. >
  4. 同步的GitHub库为Django的社会-AUTH,并创建符号链接的myapp / social_auth指向的地方Django的社会-AUTH / social_auth。



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

解决方案

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.

这篇关于如何在Google App Engine中使用自定义的Python库和应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆