diff --git a/README.md b/README.md index 63b1a32a..2daddf16 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,18 @@ functions: vendor: ./hello-vendor # The option is also available at the function level ``` +### Copy dependencies instead of linking + +Before final packaging, a link is created in .serverless folder for python dependencies. +If it is not possible for the OS to create a symbolic link, dependencies can be copied, +instead of linked, with the following option: + +```yaml +custom: + pythonRequirements: + useSymlinks: false +``` + ## Manual invocations The `.requirements` and `requirements.zip`(if using zip support) files are left diff --git a/index.js b/index.js index c6577fe0..c1bcd497 100644 --- a/index.js +++ b/index.js @@ -58,6 +58,7 @@ class ServerlessPythonRequirements { pipCmdExtraArgs: [], noDeploy: [], vendor: '', + useSymlinks: true, }, (this.serverless.service.custom && this.serverless.service.custom.pythonRequirements) || diff --git a/lib/pip.js b/lib/pip.js index 9f950664..c52f8d58 100644 --- a/lib/pip.js +++ b/lib/pip.js @@ -782,7 +782,9 @@ async function installAllRequirements() { reqsInstalledAt != symlinkPath ) { // Windows can't symlink so we have to use junction on Windows - if (process.platform == 'win32') { + if (!this.serverless.service.custom.pythonRequirements.useSymlinks) { + fse.copySync(reqsInstalledAt, symlinkPath); + } else if (process.platform == 'win32') { fse.symlink(reqsInstalledAt, symlinkPath, 'junction'); } else { fse.symlink(reqsInstalledAt, symlinkPath);