serverless-python-requirements icon indicating copy to clipboard operation
serverless-python-requirements copied to clipboard

Package individually not working with pipenv modules

Open username-dot-com opened this issue 5 years ago • 4 comments

I have a service where each function is a module using pipenv to manage dependencies for each module. The plugin doesn't generate requirements.txt using pipenv unless I have a Pipfile in the root of the service, even if I have them in the modules. However, when I do that, the plugin generates a requirements.txt for each module using the root pipfile instead of the pipfile in the module itself.

I think the issue might be in the function "pipfileToRequirements()" in pipenv.js. It always passes the service root to the spawnSync call.

Packaging seems to work if I manually generate the requirements.txt in each module prior to sls deploy/package. Though there is still another issue where serverless generates two zips per function. One zip is named the lambda function name specified in serverless.yml that follows include/exclude but otherwise would contain the entire service. The other is a zip named the lambda function after it is deployed which I believe is the one generated by this plugin. My understanding according to the docs is there should only be 2 zips?

I'm not sure if these two issues are related to each other nor if the second issue isn't really an issue and is just how it works currently, so I'd like some insight into this if possible.

I've created a reproduction repo for this here: https://github.com/username-dot-com/sls-python-test

username-dot-com avatar Oct 12 '18 15:10 username-dot-com

Good catch. That was probably over looked in the package individually implementation. cc @cgrimal

dschep avatar Oct 12 '18 19:10 dschep

It would be nice if this were documented somewhere. Tried to setup the plugin with pipenv yesterday for quite a while until I found this issue.

felschr avatar Aug 14 '19 10:08 felschr

Is it already fixed? I took a long time searching for a solution until I find this issue. I was suspecting that Pipfile was not supported in modules.

psvaiter avatar Feb 07 '22 19:02 psvaiter

It seems to not be fixed, but we would definitely be happy to accept a solution/improvement PR for this. 💯

pgrzesik avatar Feb 08 '22 11:02 pgrzesik