-
Notifications
You must be signed in to change notification settings - Fork 294
Adds option to leave python libraries out of the deployment #33
Conversation
…-by-line basis by adding a #no-deploy comment beside it in requirements.txt. Creates a parsed .requirements.txt file and retargets pip install to that file.
|
neat suggestion. probably a good enough solution for #14 as well. We're super busy at @unitedincome right now, so I'll look at this when I actually have time. |
|
|
||
| this.serverless.cli.log( | ||
| `Parsing Python requirements.txt`); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use fs-extra which is already imported as fse.
| this.serverless.cli.log( | ||
| `Parsing Python requirements.txt`); | ||
|
|
||
| var fs = require('fs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const please.
|
|
||
| var fs = require('fs'); | ||
| var reqs = fs.readFileSync("requirements.txt").toString().split('\n'); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let please.
| var fs = require('fs'); | ||
| var reqs = fs.readFileSync("requirements.txt").toString().split('\n'); | ||
|
|
||
| var newReqs = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (.. of ..) and template strings and triple equal:
for (const req of reqs) {
if (req.indexOf('#no-deploy') === -1) {
newReqs += `${req}\n`;
}
}
| if(reqs[i].indexOf('#no-deploy') == -1) { | ||
| newReqs += reqs[i] + '\n' | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build tools should use mktemp to avoid clobbering existing files whenever possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(BTW, just using mktemp as an example, you obviously can't write this into /tmp and have it be visible.)
Solves the issue of unnecessarily packaging libraries that are required but included by default by the cloud provider - such as boto3 by AWS.
Done on a line-by-line basis by adding a #no-deploy comment beside the desired library in requirements.txt. Creates a parsed .requirements.txt file and re-targets pip install to that file.
example: