@@ -69,7 +69,8 @@ function generateRequirementsFile(
69
69
filterRequirementsFile (
70
70
path . join ( servicePath , '.serverless/requirements.txt' ) ,
71
71
targetFile ,
72
- options
72
+ options ,
73
+ serverless
73
74
) ;
74
75
serverless . cli . log (
75
76
`Parsed requirements.txt from pyproject.toml in ${ targetFile } ...`
@@ -81,13 +82,14 @@ function generateRequirementsFile(
81
82
filterRequirementsFile (
82
83
path . join ( servicePath , '.serverless/requirements.txt' ) ,
83
84
targetFile ,
84
- options
85
+ options ,
86
+ serverless
85
87
) ;
86
88
serverless . cli . log (
87
89
`Parsed requirements.txt from Pipfile in ${ targetFile } ...`
88
90
) ;
89
91
} else {
90
- filterRequirementsFile ( requirementsPath , targetFile , options ) ;
92
+ filterRequirementsFile ( requirementsPath , targetFile , options , serverless ) ;
91
93
serverless . cli . log (
92
94
`Generated requirements from ${ requirementsPath } in ${ targetFile } ...`
93
95
) ;
@@ -372,13 +374,13 @@ function getRequirements(source) {
372
374
* assist with matching the static cache. The sorting will skip any
373
375
* lines starting with -- as those are typically ordered at the
374
376
* start of a file ( eg: --index-url / --extra-index-url ) or any
375
- * lines that start with -f or -i , Please see:
377
+ * lines that start with -c, -e, -f, -i or -r , Please see:
376
378
* https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format
377
379
* @param {string } source requirements
378
380
* @param {string } target requirements where results are written
379
381
* @param {Object } options
380
382
*/
381
- function filterRequirementsFile ( source , target , options ) {
383
+ function filterRequirementsFile ( source , target , options , serverless ) {
382
384
const noDeploy = new Set ( options . noDeploy || [ ] ) ;
383
385
const requirements = getRequirements ( source ) ;
384
386
var prepend = [ ] ;
@@ -389,10 +391,23 @@ function filterRequirementsFile(source, target, options) {
389
391
return false ;
390
392
} else if (
391
393
req . startsWith ( '--' ) ||
394
+ req . startsWith ( '-c' ) ||
395
+ req . startsWith ( '-e' ) ||
392
396
req . startsWith ( '-f' ) ||
393
- req . startsWith ( '-i' )
397
+ req . startsWith ( '-i' ) ||
398
+ req . startsWith ( '-r' )
394
399
) {
395
- // If we have options (prefixed with --) keep them for later
400
+ if ( req . startsWith ( '-e' ) ) {
401
+ // strip out editable flags
402
+ // not required inside final archive and avoids pip bugs
403
+ // see https://github.com/UnitedIncome/serverless-python-requirements/issues/240
404
+ req = req . split ( '-e' ) [ 1 ] . trim ( ) ;
405
+ serverless . cli . log (
406
+ `Warning: Stripping -e flag from requirement ${ req } `
407
+ ) ;
408
+ }
409
+
410
+ // Keep options for later
396
411
prepend . push ( req ) ;
397
412
return false ;
398
413
} else if ( req === '' ) {
0 commit comments