Add utility for pip installation using -t

This commit is contained in:
Ryan S. Brown 2016-01-23 10:24:29 -05:00
parent bfe2976d07
commit 495376ccd4
2 changed files with 12 additions and 1 deletions

View File

@ -232,7 +232,7 @@ usage: serverless component create`,
_installComponentDependencies() {
let _this = this;
if (_this.runtime === 'nodejs') {
if (_this.evt.options.runtime === 'nodejs') {
SCli.log('Installing "serverless-helpers" for this component via NPM...');
SUtils.npmInstall(path.join(this.S.config.projectPath, this.evt.options.component));
} else if (_this.runtime === 'python2.7') {

View File

@ -539,6 +539,17 @@ exports.npmInstall = function(dir) {
process.chdir(process.cwd());
};
/**
* Pip install using prefix strategy (not virtualenv), requires a modern `pip` version
*/
exports.pipPrefixInstall = function(requirements, dir) {
if (exec(`pip install -t "${dir}" -r "${requirements}"`, { silent: false }).code !== 0) {
throw new SError(`Error executing pip install on ${dir}`, SError.errorCodes.UNKNOWN);
}
process.chdir(process.cwd());
};
/**
* Write to console.log if process.env.DEBUG is true
* - If we ever want to get more complicated with log levels we should use winston