You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
yes, I would like to include a common folder, I tried with vendor, but instead of copying complete folder as it is, it cooies files inside vendor folder. it messes up the import statement in py files.
I've found due to how Python packages and Lambda environments work, you have to create installable packages to support your use case. That's what prompted my pre-alpha configure-django package.
Then you can do things like: from common.thing import do_action.
In that case, it will not work on local. As import should be from vendored-library.common.thing import action
Plugin copies the files instead of complete root folder (vendor folder), that's the issue.
I've found due to how Python packages and Lambda environments work, you have to create installable packages to support your use case. That's what prompted my pre-alpha configure-django package.
Could you let me know how to create installable package and use it in yml file ? without publishing the package to public.
So does it not work to have /vendor/common/ and then import common?
If I import as import common, it will work on lambda, but it will not work on local env., as
import actually should be import vendor.common
Activity
dschep commentedon Oct 11, 2018
Is this specifically when using
package: individually
?infinitedreams9586 commentedon Oct 11, 2018
yes, I would like to include a common folder, I tried with vendor, but instead of copying complete folder as it is, it cooies files inside vendor folder. it messes up the import statement in py files.
infinitedreams9586 commentedon Oct 11, 2018
for ex. if I have python file where import is like,
from common.db import tables
and add vendor: common instead of copying common folder as it is, it copies files inside it without common folder, so import statement above fails.
pydanny commentedon Oct 12, 2018
I've found due to how Python packages and Lambda environments work, you have to create installable packages to support your use case. That's what prompted my pre-alpha configure-django package.
pydanny commentedon Oct 13, 2018
Another idea is to do this with your vendor library:
Then you can do things like:
from common.thing import do_action
.infinitedreams9586 commentedon Oct 13, 2018
In that case, it will not work on local. As import should be
from vendored-library.common.thing import action
Plugin copies the files instead of complete root folder (vendor folder), that's the issue.
infinitedreams9586 commentedon Oct 15, 2018
Could you let me know how to create installable package and use it in yml file ? without publishing the package to public.
dschep commentedon Oct 17, 2018
So does it not work to have
/vendor/common/
and thenimport common
?dschep commentedon Oct 17, 2018
Also, bc of how serverless handles them.. symlinks should be a workable solution too:
infinitedreams9586 commentedon Oct 18, 2018
dschep commentedon Oct 18, 2018
right, you'd have to set
PYTHONPATH=vendor
to run locally.infinitedreams9586 commentedon Oct 19, 2018
@dschep Thank you very much. I understood now.
I got everything working as expected, using symlinks method you mentioned above.
Thanks for your help.
dschep commentedon Oct 22, 2018
👍 Glad you got it working @infinitedreams9586!
I'll leave this open for now as a reminder to write up some better documentation about using the vendor option.