为要在AWS Lambda中使用的python软件包指定C(++)依赖关系 [英] Specifying C(++) dependencies for python packages for use in AWS Lambda

查看:101
本文介绍了为要在AWS Lambda中使用的python软件包指定C(++)依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个无服务器服务,希望能够使用AWS Lambda中的sasl pypi软件包.不幸的是,AWS Lambda环境似乎没有最新版本的libstdc ++.so,这意味着当我们的构建服务器压缩pip install d的sasl包并调用lambda时,会出现预期的错误:

I have a serverless service that I want to be able to use the sasl pypi package from in AWS Lambda. Unfortunately, the AWS Lambda environment doesn't seem to have the newest versions of libstdc++.so, which means that when our build server zips up the pip install'd sasl package and we invoke the lambda, there are the expected errors:

Unable to import module 'handler': /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /var/task/sasl/saslwrapper.so)

我的问题是:如何解决这个问题? 有没有一种方法可以针对更新的libstdc ++.so.6在Amazon Linux实例上构建这些文件,以便可以将它们与这些库捆绑在一起?将LD_LIBRARY_PATH env变量设置为.并包括libstdc ++.so.6的最新版本是否可以工作?是否在任何地方都有最佳实践?

My question is: How to get around this? Is there a way to build these on an Amazon Linux instance against updated libstdc++.so.6 so that it can be bundled in with the libs? Would setting LD_LIBRARY_PATH env variable to . and including the newest version of libstdc++.so.6 work? Are there best practices around this anywhere?

推荐答案

您可以将docker与amazonlinux用作基础映像来构建所有依赖项,然后将它们复制到压缩包中,以上传到实际的lambda中: https://medium.com/@johnnyopao/python-dependencies-and -aws-lambda-18acbdebca20

You can use docker with amazonlinux as your base image to build all your dependencies then copy these to your zipped package to be uploaded to your actual lambda: https://medium.com/@johnnyopao/python-dependencies-and-aws-lambda-18acbdebca20

或者您可以在远程EC2(构建)实例上执行等效操作:

Or you can do the equivalent on a remote EC2 (build) instance: http://www.perrygeo.com/running-python-with-compiled-code-on-aws-lambda.html

最后一个选项,按照以下建议使用AWS Cloud 9作为您的IDE: https://markn.ca/2018/02/python-extension-modules-in-aws-lambda/

Last option, use AWS Cloud 9 as your IDE, as suggested by: https://markn.ca/2018/02/python-extension-modules-in-aws-lambda/

这篇关于为要在AWS Lambda中使用的python软件包指定C(++)依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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