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

pythonRequirements->vendor does not work if package->individually is set to true

Open amitm02 opened this issue 8 years ago • 2 comments

from the code:

if (this.serverless.service.package.individually) {
...
} else {
    installRequirements(
      this.options.fileName,
      '.serverless',
      this.serverless,
      this.servicePath,
      this.options
    );
    if (this.options.vendor) {
      // copy vendor libraries to requirements folder
      copyVendors(this.options.vendor, '.serverless', this.serverless);
    }
  }

I think

if (this.options.vendor) {
   // copy vendor libraries to requirements folder
   copyVendors(this.options.vendor, '.serverless', this.serverless);
}

should be outside the if-else block as probably we want the general - "cross functions" vendor folder to be copied to each module, even if individuality was set to true

amitm02 avatar Jun 19 '18 07:06 amitm02

That seems right to me too. Feel free to make a PR :+1:

dschep avatar Jun 19 '18 11:06 dschep

@dschep What if I have a vendor library with custom modules that some functions depend on also created by ourselves in below manner.

project-name
   /vendor
      ...
      __init__.py
      /custom
           __init__.py
           package.py
  /functions
      /func1
          __init__.py
          handler.py

Here in my handler.py I have imported package like from vendor.custom import package and because of above issues I used function level vendoring. But when I deploy the code I get all the files in modules copied into function folder without the module structure. Any idea why this is happening or am I doing it in the right way?

singhabahu avatar Aug 15 '18 10:08 singhabahu