Include option to maintain the file include paths when copying to build package
see #8 first comment
I think I've solved this issue in my fork at onlicar/serverless-package-python-functions - I've added a new resources option alongside includes and a globalResources option to custom. We have resources on our serverless API like html email templates so we need to copy files in place.
I don't really see a use case for includes as it currently stands - why would you need to copy files to the top level of the lambda zip? I think all users of this plugin will need to copy files in place so that the code structure is the same whether we are online or offline. e.g. when I import a file likerepositories/vehicle.py I do this:
from repositories.vehicles import get_vehicle
Whereas, with includes the way it stands, it would have to be changed to this, (somehow) just for deployment:
from vehicles import get_vehicle
Let me know if I should open a pull request with the current changes (adding resources alongside includes so not a breaking change) or open one that overwrites the includes implementation (breaking change).
+1
@danbovey Thanks for the feedback! Please make a PR request and I'll take a look.
I think I've solved this issue in my fork at onlicar/serverless-package-python-functions - I've added a new
resourcesoption alongsideincludesand aglobalResourcesoption tocustom. We have resources on our serverless API like html email templates so we need to copy files in place.I don't really see a use case for
includesas it currently stands - why would you need to copy files to the top level of the lambda zip? I think all users of this plugin will need to copy files in place so that the code structure is the same whether we are online or offline. e.g. when I import a file likerepositories/vehicle.pyI do this:from repositories.vehicles import get_vehicleWhereas, with
includesthe way it stands, it would have to be changed to this, (somehow) just for deployment:from vehicles import get_vehicleLet me know if I should open a pull request with the current changes (adding
resourcesalongsideincludesso not a breaking change) or open one that overwrites theincludesimplementation (breaking change).
Hi,
How did you solve this issue? I am having very similar issue. Whenever I have to run my unit tests, my import doesn't work. If I change my imports to suit unit tests then aws lambda doesn't like it.
Is there any workaround for this?
Regards, Ashish
As of now, for my unit test cases, I have solved the problem with setting PYTHONPATH. But is there cleaner way of handling this scenario?
Regards,
Is this feature being worked upon? We are facing a similar condition where we need to copy files in place to a lambda package.
Hi @danbovey. Did you happen to end up with a solution for this?
As already mentioned here, not having each lambda as an individual package introduces all kinds of issues when you start add unit tests, linting with mypy, etc. to the project.