python-lambda-layer-builder

授权协议 MIT License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 柏高洁
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

python-lambda-layer-builder

Creates an AWS Lambda Layers structure that is optimized for: Lambda Layer directory structure, compiled library compatibility, and minimal file size.

This repo was created to address these issues:

  • Many methods of creating Lambda zip files for Python functions don't work for Lambda Layers
    • This is due to the fact Lambda Layers require specific library paths within the zip, where regular Lambda zips don't
  • Compiled dependencies must be created in an environment that matches the Lambda runtime
  • Reduce size of the layer by removing unnecessary libraries and files

Note: This script requires Docker and uses a container to mimic the Lambda environment.

Features

  • Builds either a zip file or a raw directory strucutre (e.g. if you want to use frameworks like Serverless for packaging) containing Python dependencies and places the libraries into the proper directory structure for lambda layers
  • Ensures compiled libraries are compatible with Lambda environment by using the lambci/lambda Docker container that mimics the lambda runtime environment
  • Optimized the zip size by removing .pyc files and unnecessary libraries
  • Allows specifying lambda supported python versions: 2.7, 3.6, 3.7 and 3.8
  • Automatically searches for requirements.txt file in several locations:
    • same directory as script
    • parent directory or script (useful when used as submodule)
    • function sub-directory of the parent directory

Installation

This function can be cloned for standalone use, into a parent repo or added as a submodule.

Clone for standalone use or within a repo:

# If installing into an exisiting repo, navigate to repo dir
git clone --depth 1 https://github.com/tobilg/python-lambda-layer-builder _build_layer

Alternatively, add as a submodule:

cd {repo root}
git submodule add https://github.com/tobilg/python-lambda-layer-builder _build_layer
# Update submodule
git submodule update --init --recursive --remote

Usage

$ ./build.sh -h
AWS Lambda Layer Builder for Python Libraries

Usage: build.sh [-p PYTHON_VER] [-n NAME] [-f] [-r] [-h] [-v]
  -p PYTHON_VER : Python version to use: 2.7, 3.6, 3.7, 3.8 (default 3.7)
  -n NAME       : Name of the layer
  -f REQ_PATH	  : Path to requirements file
  -r            : Raw mode, don't zip layer contents
  -d            : Don't install Python dependencies
  -s            : Don't strip .so files
  -h            : Help
  -v            : Display build.sh version
  • Run the builder with the command ./build.sh
    • or _build_layer/build.sh if installed in sub-dir
  • It uses the first requirements.txt file found in these locations (in order):
    • Input on the command line using the -f switch
    • Same directory as script
    • Parent directory of script (useful when used as submodule)
    • Function sub-directory of the parent directory (useful when used as submodule)
  • Optionally specify Python Version
    • -p PYTHON_VER - specifies the Python version: 2.7, 3.6, 3.7, 3.8 (default 3.7)

Custom cleaning logic

You can edit the _clean.sh file if you want to add custom cleaning logic for the build of the Lambda layer. The above part of the file must stay intact:

#!/usr/bin/env bash
# Change to working directory
cd $1
# ----- DON'T CHANGE THE ABOVE -----

# Cleaning statements
# ----- CHANGE HERE -----
rm test.xt

The _make.sh script will then execute the commands after the Python packages have been installed.

Uninstall

If installed as submodule and need to remove

# Remove the submodule entry from .git/config
git submodule deinit -f $submodulepath
# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/$submodulepath
# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f $submodulepath
# remove entry in submodules file
git config -f .git/config --remove-section submodule.$submodulepath
  • 由于总结了太多的东西,所以篇幅有点长,这也是我"缝缝补补"总结了好久的东西。 Py2 VS Py3 print成为了函数,python2是关键字 不再有unicode对象,默认str就是unicode python3除号返回浮点数 没有了long类型 xrange不存在,range替代了xrange 可以使用中文定义函数名变量名 高级解包 和*解包 限定关键字参数 *后的变量必须加入名字=值 ra

  • 你可以使用内部扩展来修改运行时进程。内部扩展不是独立的进程,它们作为运行时进程的一部分运行。 Lambda提供了特定于语言的环境变量,你可以设置这些变量来为运行时添加选项和工具。Lambda还提供了包装脚本,它允许Lambda将运行时的启动委托给你的脚本。你可以创建一个包装脚本来定制运行时的启动行为。 特定语言的环境变量 Lambda支持纯配置的方式,通过以下特定语言的环境变量,使代码在函数初始化

  • pip install tensorflow-gpu==2.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple 1 description 通过c++实现一个clip layer 编译生成共享库 使用python动态加载该库文件 通过TensorRT的PluginRegistry 注册插件 在UFF解析中使用这个插件 2 run 编译clip插件 mkd

  • 前端 span设置margin上下无效果,因为span是行内元素,是没有宽高的。 Py2 VS Py3 print成为了函数,python2是关键字 不再有unicode对象,默认str就是unicode python3除号返回浮点数 没有了long类型 rangex不存在,range替代了rangex 可以使用中文定义函数名变量名 高级解包 和*解包 限定关键字参数 *后的变量必须加入名字=值

  • 前言 本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,如有问题请及时联系我们以作处理。 PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取 python免费学习资料以及群交流解答点击即可加入 Py2 VS Py3 print成为了函数,python2是关键字 不再有unicode对象,默认str就是unicode python3除号返回浮点数 没有了long类

 相关资料
  • Bash in AWS Lambda NO LONGER SUPPORTED This repository and layer is no longer receiving updates or support. I've been too busy to keep up with changes in the Lambda environment and this has fallen beh

  • layer 是一款多年来备受青睐的 Web 弹出层组件,具备多种交互模式。任何水平段的开发者都能使用,您的页面会因此拥有丰富友好的操作体验。 在与同类组件的选择中,layer 常一度被推荐为首选。这不仅是因为界面风格,而是它尽可能地在以更少的代码展现更强健的功能,且格外注重功能的扩展、易用和实用性,layer 甚至还兼容了包括 IE6 在内的所有浏览器。其数量可观的基础属性和方法,使得您可以自定义

  • Python-lambda is a toolset for developing and deploying serverless Python code in AWS Lambda. A call for contributors With python-lambda and pytube both continuing to gain momentum, I'm calling forcon

  • CMAP~ Layer 图层的基类 FeatureLayer ThingLayer BigDataLayer的父类 new Layer() Extends THING.BaseObject Members angles :Array.<number> 三轴相对角度,相对于自身坐标 Type: Array.<number> Inherited From: THING.BaseObject#angle

  • Layer Style s是一个用于生成 CSS3 样式的网页应用程序,通过设置一些基本参数(阴影、圆角等)生成你想要的样式。 拾色器可以选择您要处理的元素的任何颜色 将图像拖放到页面上以将其用作背景或选择其颜色 颜色色板,渐变和样式本地存储 这个HTML5的程序是开源的,可以下载到本地来使用。

  • layer mobile是为移动设备(手机、平板等webkit内核浏览器/webview)量身定做的弹层UI。由于是采用原生 JavaScript编写,所有并不依赖任何第三方库。layer mobile完全独立于PC版的layer,您需要按照场景选择使用。layer mobile正致力于成为您WebApp开发过程中弹出交互的不二选择。  演示:http://layer.layui.com/mobile/