Skip to content

Zip example breaks compatibility for python dependencies with layers #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sansmoraxz opened this issue Apr 19, 2024 · 2 comments
Closed

Comments

@sansmoraxz
Copy link
Contributor

sansmoraxz commented Apr 19, 2024

The examples for python are overwriting the environment variable for PYTHONPATH. The layers are stored mounted to /opt directory. Python dependencies from layers are mounted to /opt/python. This will result in code failing to import dependencies properly.

I propose updating the run.sh scripts to something like:

#!/bin/bash

PATH=$PATH:$LAMBDA_TASK_ROOT/bin \
    PYTHONPATH=$LAMBDA_TASK_ROOT:$PYTHONPATH:/opt/python \
    exec python -m uvicorn --port=$PORT main:app

Working example repo here: sansmoraxz/fastapi-layer-zip-example-with-layers

@bnusunny
Copy link
Contributor

Thanks for reporting this issue. Would you like to push a PR?

@sansmoraxz
Copy link
Contributor Author

Sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants