I'm both learning python and attempting to build multiple lambdas that will both store and process Spotify listening history. I originally wrote one lambda with all dependencies packaged in the same directory and imported using relative paths.
Once creating similar functions which use the same dependencies, I've split the dependencies from the function and built them using pip3 and setup.py. When running pip3 list I can see the packages as expected. To execute the function locally using sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json
and verify success, I'm specifying a layer I've built - this works!
To avoid having to rebuild the layer and modifying my function, I'd like to be able to revert to using a requirements.txt file and removing the specified layer.
Steps to reproduce the issue:
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
Observed result:
Building resource 'SpotifyPlayHistoryListener'
Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - Could not satisfy the requirement: spotify-client
Expected result:
Build succeeds and function executes successfully.
Additional environment details:
I'm able to execute the function locally using sam build && sam local invoke SpotifyPlayHistoryListener --env-vars env.json --event events/event.json
when specfying dependencies using a Layer
I've created the following issue https://github.com/awslabs/aws-lambda-builders/issues/155. I think this may be an issue with my understanding of python and pip so the opened issue may not be relevant.
As my dependencies weren't published to pypi, I needed to modify the entries in requirement.txt to use the actual file path to the package.