@@ -77,26 +77,36 @@ async function pipfileToRequirements() {
77
77
78
78
if ( semver . gt ( pipenvVersion , LEGACY_PIPENV_VERSION ) ) {
79
79
// 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
80
82
try {
81
- await spawn ( 'pipenv' , [ 'lock' , '--keep-outdated '] , {
83
+ res = await spawn ( 'pipenv' , [ 'requirements ' ] , {
82
84
cwd : this . servicePath ,
83
85
} ) ;
84
86
} catch ( e ) {
85
87
const stderrBufferContent =
86
88
( e . stderrBuffer && e . stderrBuffer . toString ( ) ) || '' ;
87
- if ( stderrBufferContent . includes ( 'must exist to use ' ) ) {
89
+ if ( stderrBufferContent . includes ( 'FileNotFoundError ' ) ) {
88
90
// 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
+ }
89
100
await spawn ( 'pipenv' , [ 'lock' ] , {
90
101
cwd : this . servicePath ,
91
102
} ) ;
103
+ res = await spawn ( 'pipenv' , [ 'requirements' ] , {
104
+ cwd : this . servicePath ,
105
+ } ) ;
92
106
} else {
93
107
throw e ;
94
108
}
95
109
}
96
-
97
- res = await spawn ( 'pipenv' , [ 'requirements' ] , {
98
- cwd : this . servicePath ,
99
- } ) ;
100
110
} else {
101
111
// Falling back to legacy pipenv syntax
102
112
res = await spawn (
0 commit comments