@@ -77,26 +77,36 @@ async function pipfileToRequirements() {
7777
7878 if ( semver . gt ( pipenvVersion , LEGACY_PIPENV_VERSION ) ) {
7979 // Using new pipenv syntax ( >= 2022.8.13)
80+ // Generate requirements from existing lock file.
81+ // See: https://pipenv.pypa.io/en/latest/advanced/#generating-a-requirements-txt
8082 try {
81- await spawn ( 'pipenv' , [ 'lock' , '--keep-outdated '] , {
83+ res = await spawn ( 'pipenv' , [ 'requirements ' ] , {
8284 cwd : this . servicePath ,
8385 } ) ;
8486 } catch ( e ) {
8587 const stderrBufferContent =
8688 ( e . stderrBuffer && e . stderrBuffer . toString ( ) ) || '' ;
87- if ( stderrBufferContent . includes ( 'must exist to use ' ) ) {
89+ if ( stderrBufferContent . includes ( 'FileNotFoundError ' ) ) {
8890 // No previous Pipfile.lock, we will try to generate it here
91+ if ( this . log ) {
92+ this . log . warning (
93+ 'No Pipfile.lock found! Review https://pipenv.pypa.io/en/latest/pipfile/ for recommendations.'
94+ ) ;
95+ } else {
96+ this . serverless . cli . log (
97+ 'WARNING: No Pipfile.lock found! Review https://pipenv.pypa.io/en/latest/pipfile/ for recommendations.'
98+ ) ;
99+ }
89100 await spawn ( 'pipenv' , [ 'lock' ] , {
90101 cwd : this . servicePath ,
91102 } ) ;
103+ res = await spawn ( 'pipenv' , [ 'requirements' ] , {
104+ cwd : this . servicePath ,
105+ } ) ;
92106 } else {
93107 throw e ;
94108 }
95109 }
96-
97- res = await spawn ( 'pipenv' , [ 'requirements' ] , {
98- cwd : this . servicePath ,
99- } ) ;
100110 } else {
101111 // Falling back to legacy pipenv syntax
102112 res = await spawn (
0 commit comments