Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

python - Unable to use cflag optimization when building a lambda layer

I am trying to build a lambda compatible layer locally to reduce the size of my deployment. However, if I try to build normally, my deployment is still too large, so I am trying to use cflags when installing packages, using this guide: https://avilpage.com/2020/02/reduce-python-package-footprint.html.

One problem I am running into is that I am getting this error:

docker: Error response from daemon: OCI runtime create failed: 
container_linux.go:349: starting container process caused "exec:
 "CFLAGS=-g0": executable file not found in $PATH": unknown.

when running with this build file...

build_package.sh

repo_name = 'generic_name'
PKG_DIR="python"
CFLAGS_ARG = "-g0 -Wl -I/usr/include:/usr/local/include -L/usr/lib:/usr/local/lib"

rm -rf ${PKG_DIR} && mkdir -p ${PKG_DIR}

docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.8 
    CFLAGS= ${CFLAGS_ARG} 
    pip install -r requirements.v1.txt --no-deps --no-cache-dir -t ${PKG_DIR}

rm -rf ${PKG_DIR}/*.dist-info
zip -r  ${repo_name}.zip ${PKG_DIR}
rm -rf ${PKG_DIR}

Does anyone know how to fix this error? I'm not sure how to fix this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...