提问人:Devvex23 提问时间:7/16/2023 最后编辑:Devvex23 更新时间:7/16/2023 访问量:309
Python AWS CDK 构建昨天中断 - “请确保已安装 libxml2 和 libxslt 开发包。
Python AWS CDK build broke yesterday - 'Please make sure the libxml2 and libxslt development packages are installed.'
问:
一年多来,我一直在使用 CDK 定期将基于 python 的 lambda 部署到 AWS,并且效果很好。构建昨天坏了,我注意到我使用的映像在几天前更新了:https://github.com/aws/aws-lambda-base-images/commits/python3.9/Dockerfile.python3.9
我现在收到一个构建错误“请确保安装了 libxml2 和 libxslt 开发包。
我的函数和层是以类似的方式构建的,例如:
from aws_cdk import (
aws_lambda_python_alpha as _lambda,
DockerImage,
AssetHashType,
NestedStack,
RemovalPolicy,
)
def create_lambda_layer(
self, deploy_folder: str, layer_name: str, only_include_these=[]
) -> _lambda.PythonLayerVersion:
layer_folder = self.build_dependencies_layer(
deploy_folder, layer_name, only_include_these=only_include_these
)
print(layer_name, layer_folder, deploy_folder, only_include_these)
return _lambda.PythonLayerVersion(
self,
layer_name,
entry=layer_folder,
compatible_runtimes=[Runtime.PYTHON_3_9],
compatible_architectures=[Architecture.ARM_64],
bundling={
"image": DockerImage("public.ecr.aws/sam/build-python3.9:latest-arm64"),
"asset_hash_type": AssetHashType.SOURCE,
},
removal_policy=RemovalPolicy.RETAIN,
)
我有一个特定的层,它依赖于 Zeep python 库。我记得这在我的 Apple Silicon Mac 上捆绑/构建是有问题的。构建该层时,在 Docker 映像中运行的 pip 失败,并显示以下错误:
Collecting lxml>=4.6.0
Downloading lxml-4.9.3.tar.gz (3.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 8.7 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [3 lines of output]
Building lxml version 4.9.3.
Building without Cython.
Error: Please make sure the libxml2 and libxslt development packages are installed.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
其中的突出线是:
Please make sure the libxml2 and libxslt development packages are installed.
如何使这些可用于进行构建的 docker 映像?我是构建自己的映像,还是需要在 docker 映像上/“在”中“运行一些安装步骤。有什么建议吗?
[编辑] 我尝试修改构建以指向 Docker 文件并自己安装依赖项。我可以看到这些二进制文件安装在 Docker 映像中,但容器中的 pip 仍然失败
FROM public.ecr.aws/sam/build-python3.9:latest-arm64
RUN yum install -y libxml2 libxslt
[/编辑]
[编辑2] 让它工作。我正在安装 libxml2 和 libxslt,而不是他们的 DEVELOPMENT 包,这就是构建错误所说的。因此,通过在 Dockerfile 中执行以下操作解决了这个问题:
FROM public.ecr.aws/sam/build-python3.9:latest-arm64
RUN yum install -y Cython libxml2-devel libxslt-devel
然后为了构建我现在做的层:
bundling={
'image': DockerImage.from_build(os.path.expanduser('~/workplace/cdk/stacks/')),
'asset_hash_type': AssetHashType.SOURCE
}
它正在工作
[/编辑2]
答:
让它工作。我正在安装 libxml2 和 libxslt,而不是他们的 DEVELOPMENT 包,这就是构建错误所说的。因此,通过在 Dockerfile 中执行以下操作解决了这个问题:
FROM public.ecr.aws/sam/build-python3.9:latest-arm64
RUN yum install -y Cython libxml2-devel libxslt-devel
然后为了构建我现在做的层:
bundling={
'image': DockerImage.from_build(os.path.expanduser('~/workplace/cdk/stacks/')),
'asset_hash_type': AssetHashType.SOURCE
}
它正在工作
评论