Skip to content

Added feature to use the default noDeploy list with custom list #354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Expand Down
30 changes: 19 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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';
}
Expand Down