@@ -27,19 +27,25 @@ class ServerlessPythonRequirements {
27
27
this . serverless . cli . log ( 'Installing required Python packages...' ) ;
28
28
29
29
return new BbPromise ( ( resolve , reject ) => {
30
- let cmd = 'pip' ;
31
- let options = [
32
- '--isolated' , 'install' ,
33
- '-t' , '.requirements' ,
34
- '-r' , 'requirements.txt' ,
30
+ let cmd , options ;
31
+ const pipCmd = [
32
+ 'pip' , '--isolated' , 'install' ,
33
+ '-t' , '.requirements' , '-r' , 'requirements.txt' ,
34
+ ] ;
35
+ const dockerCmd = [
36
+ 'docker' , 'run' , '--rm' ,
37
+ '-v' , `${ this . serverless . config . servicePath } :/var/task:z` ,
38
+ 'lambci/lambda:build-python2.7' ,
39
+ 'bash' , '-c' ,
35
40
] ;
36
41
if ( this . custom . dockerizePip ) {
37
- cmd = 'docker' ;
38
- options = [
39
- 'run' , '--rm' ,
40
- '-v' , `${ this . serverless . config . servicePath } :/var/task:z` ,
41
- 'lambci/lambda:build-python2.7' , 'pip' ,
42
- ] . concat ( options ) ;
42
+ cmd = dockerCmd [ 0 ] ;
43
+ options = dockerCmd . slice ( 1 ) ;
44
+ pipCmd . unshift ( 'pip install --upgrade pip &&' )
45
+ options . push ( pipCmd . join ( ' ' ) )
46
+ } else {
47
+ cmd = pipCmd [ 0 ] ;
48
+ options = pipCmd . slice ( 1 ) ;
43
49
}
44
50
const res = child_process . spawnSync ( cmd , options ) ;
45
51
if ( res . error ) {
0 commit comments