@@ -14,29 +14,48 @@ async function pipfileToRequirements() {
1414 return ;
1515 }
1616
17- this . serverless . cli . log ( 'Generating requirements.txt from Pipfile...' ) ;
17+ let generateRequirementsProgress ;
18+ if ( this . progress ) {
19+ generateRequirementsProgress = this . progress . get (
20+ 'python-generate-requirements-pipfile'
21+ ) ;
22+ generateRequirementsProgress . update (
23+ 'Generating requirements.txt from Pipfile' ,
24+ { isMainEvent : true }
25+ ) ;
26+ } else {
27+ this . serverless . cli . log ( 'Generating requirements.txt from Pipfile...' ) ;
28+ }
1829
19- let res ;
2030 try {
21- res = await spawn ( 'pipenv' , [ 'lock' , '--requirements' , '--keep-outdated' ] , {
22- cwd : this . servicePath ,
23- } ) ;
24- } catch ( e ) {
25- if (
26- e . stderrBuffer &&
27- e . stderrBuffer . toString ( ) . includes ( 'command not found' )
28- ) {
29- throw new Error (
30- `pipenv not found! Install it with 'pip install pipenv'.`
31+ let res ;
32+ try {
33+ res = await spawn (
34+ 'pipenv' ,
35+ [ 'lock' , '--requirements' , '--keep-outdated' ] ,
36+ {
37+ cwd : this . servicePath ,
38+ }
3139 ) ;
40+ } catch ( e ) {
41+ if (
42+ e . stderrBuffer &&
43+ e . stderrBuffer . toString ( ) . includes ( 'command not found' )
44+ ) {
45+ throw new Error (
46+ `pipenv not found! Install it with 'pip install pipenv'.`
47+ ) ;
48+ }
49+ throw e ;
3250 }
33- throw e ;
51+ fse . ensureDirSync ( path . join ( this . servicePath , '.serverless' ) ) ;
52+ fse . writeFileSync (
53+ path . join ( this . servicePath , '.serverless/requirements.txt' ) ,
54+ removeEditableFlagFromRequirementsString ( res . stdoutBuffer )
55+ ) ;
56+ } finally {
57+ generateRequirementsProgress && generateRequirementsProgress . remove ( ) ;
3458 }
35- fse . ensureDirSync ( path . join ( this . servicePath , '.serverless' ) ) ;
36- fse . writeFileSync (
37- path . join ( this . servicePath , '.serverless/requirements.txt' ) ,
38- removeEditableFlagFromRequirementsString ( res . stdoutBuffer )
39- ) ;
4059}
4160
4261/**
0 commit comments