执行函数时无法从 AWS Layer 切换到指定本地构建的可编辑 pip3 包

Unable to switch from AWS Layer to specifying locally built editable pip3 packages when executing function

我正在学习 python 并尝试构建多个 lambda 来存储和处理 Spotify 收听历史。我最初编写了一个 lambda,将所有依赖项打包在同一目录中并使用相对路径导入。

创建使用相同依赖项的类似函数后,我将依赖项从函数中分离出来,并使用 pip3 和 setup.py 构建它们。当 运行 pip3 list 我可以按预期看到包。要使用 sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json 在本地执行函数并验证是否成功,我指定了一个我构建的层 - 这有效!

为了避免重建层和修改我的功能,我希望能够恢复使用 requirements.txt 文件并删除指定的层。

重现问题的步骤:

Build local editable package - pip3 install -e .
Specify in requirements.txt
sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json

观测结果:

Building resource 'SpotifyPlayHistoryListener'
Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: spotify-client

预期结果:

构建成功,函数执行成功。

其他环境详细信息:

当使用 Layer

指定依赖项时,我能够使用 sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json 在本地执行函数

我创建了以下问题 https://github.com/awslabs/aws-lambda-builders/issues/155。我认为这可能是我对 python 和 pip 的理解的问题,因此打开的问题可能不相关。

由于我的依赖项没有发布到 pypi,我需要修改 requirement.txt 中的条目以使用包的实际文件路径。