@@ -69,7 +69,8 @@ function generateRequirementsFile(
6969 filterRequirementsFile (
7070 path . join ( servicePath , '.serverless/requirements.txt' ) ,
7171 targetFile ,
72- options
72+ options ,
73+ serverless
7374 ) ;
7475 serverless . cli . log (
7576 `Parsed requirements.txt from pyproject.toml in ${ targetFile } ...`
@@ -81,13 +82,14 @@ function generateRequirementsFile(
8182 filterRequirementsFile (
8283 path . join ( servicePath , '.serverless/requirements.txt' ) ,
8384 targetFile ,
84- options
85+ options ,
86+ serverless
8587 ) ;
8688 serverless . cli . log (
8789 `Parsed requirements.txt from Pipfile in ${ targetFile } ...`
8890 ) ;
8991 } else {
90- filterRequirementsFile ( requirementsPath , targetFile , options ) ;
92+ filterRequirementsFile ( requirementsPath , targetFile , options , serverless ) ;
9193 serverless . cli . log (
9294 `Generated requirements from ${ requirementsPath } in ${ targetFile } ...`
9395 ) ;
@@ -372,13 +374,13 @@ function getRequirements(source) {
372374 * assist with matching the static cache. The sorting will skip any
373375 * lines starting with -- as those are typically ordered at the
374376 * 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:
376378 * https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format
377379 * @param {string } source requirements
378380 * @param {string } target requirements where results are written
379381 * @param {Object } options
380382 */
381- function filterRequirementsFile ( source , target , options ) {
383+ function filterRequirementsFile ( source , target , options , serverless ) {
382384 const noDeploy = new Set ( options . noDeploy || [ ] ) ;
383385 const requirements = getRequirements ( source ) ;
384386 var prepend = [ ] ;
@@ -389,10 +391,23 @@ function filterRequirementsFile(source, target, options) {
389391 return false ;
390392 } else if (
391393 req . startsWith ( '--' ) ||
394+ req . startsWith ( '-c' ) ||
395+ req . startsWith ( '-e' ) ||
392396 req . startsWith ( '-f' ) ||
393- req . startsWith ( '-i' )
397+ req . startsWith ( '-i' ) ||
398+ req . startsWith ( '-r' )
394399 ) {
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
396411 prepend . push ( req ) ;
397412 return false ;
398413 } else if ( req === '' ) {
0 commit comments