diff --git a/README.md b/README.md index 37254fd3..57b8039f 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,8 @@ custom: - pytest ``` +N.B. When using a `Pipfile`, instead of `requirements.txt`, there is no need to specify `pytest` in the `noDeploy` list if you have specified it as a dev dependency. + To include the default omitted packages, set the `noDeploy` option to an empty list: ```yaml @@ -236,6 +238,15 @@ custom: noDeploy: [] ``` +Or to use both a custom list of ommitted packages, and the defaults listed above use the `addDefaultNoDeploys` option e.g.: +```yaml +custom: + pythonRequirements: + addDefaultNoDeploys: true + noDeploy: + - external_layer_provided_package +``` + ## Extra Config Options ### Caching You can enable two kinds of caching with this plugin which are currently both DISABLED by default. First, a download cache that will cache downloads that pip needs to compile the packages. And second, a what we call "static caching" which caches output of pip after compiling everything for your requirements file. Since generally requirements.txt files rarely change, you will often see large amounts of speed improvements when enabling the static cache feature. These caches will be shared between all your projects if no custom cacheLocation is specified (see below). diff --git a/index.js b/index.js index b5200285..9cc1192d 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,20 @@ BbPromise.promisifyAll(fse); * Plugin for Serverless 1.x that bundles python requirements! */ class ServerlessPythonRequirements { + get default_no_deploys() { + return [ + 'boto3', + 'botocore', + 'docutils', + 'jmespath', + 'python-dateutil', + 's3transfer', + 'six', + 'pip', + 'setuptools' + ]; + } + /** * get the custom.pythonRequirements contents, with defaults set * @return {Object} @@ -53,23 +67,17 @@ class ServerlessPythonRequirements { cacheLocation: false, staticCacheMaxVersions: 0, pipCmdExtraArgs: [], - noDeploy: [ - 'boto3', - 'botocore', - 'docutils', - 'jmespath', - 'python-dateutil', - 's3transfer', - 'six', - 'pip', - 'setuptools' - ], + noDeploy: this.default_no_deploys, + addDefaultNoDeploys: false, vendor: '' }, (this.serverless.service.custom && this.serverless.service.custom.pythonRequirements) || {} ); + if (options.addDefaultNoDeploys) { + options.noDeploy = options.noDeploy.concat(this.default_no_deploys); + } if (options.dockerizePip === 'non-linux') { options.dockerizePip = process.platform !== 'linux'; }