Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Conversation

@medwig
Copy link

@medwig medwig commented Jun 12, 2017

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:

$ cat requirements.txt  
requests    
boto3 #no-deploy
pandas

…-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.
@dschep
Copy link
Contributor

dschep commented Jun 13, 2017

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`);

Copy link
Contributor

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');
Copy link
Contributor

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');

Copy link
Contributor

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 = ''
Copy link
Contributor

@dschep dschep Jun 22, 2017

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'
}
}
Copy link
Contributor

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.

Copy link
Contributor

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.)

@dschep dschep merged commit b9f436c into serverless:master Jul 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants