lib/pip.js
function generateRequirementsFile(
  requirementsPath,
  targetFile,
  serverless,
  servicePath,
  options
) {
  if (
    options.usePoetry &&
    fse.existsSync(path.join(servicePath, 'pyproject.toml'))
  ) {
    filterRequirementsFile(
      path.join(servicePath, '.serverless/requirements.txt'),
      targetFile,
      options
    );
    serverless.cli.log(
      `Parsed requirements.txt from pyproject.toml in ${targetFile}...`
    );
  } else if (
    options.usePipenv &&
    fse.existsSync(path.join(servicePath, 'Pipfile'))
  ) {
    filterRequirementsFile(
      path.join(servicePath, '.serverless/requirements.txt'),
      targetFile,
      options
    );
    serverless.cli.log(
      `Parsed requirements.txt from Pipfile in ${targetFile}...`
    );
  } else {
    filterRequirementsFile(requirementsPath, targetFile, options);
    serverless.cli.log(
      `Generated requirements from ${requirementsPath} in ${targetFile}...`
    );
  }
}
function generateRequirementsFile(
  requirementsPath,
  targetFile,
  serverless,
  servicePath,
  options
) {
  if (
    options.usePoetry &&
    fse.existsSync(path.join(servicePath, 'pyproject.toml'))
  ) {
    filterRequirementsFile(
      path.join(servicePath, '.serverless/requirements.txt'),
      targetFile,
      options
    );
    serverless.cli.log(
      `Parsed requirements.txt from pyproject.toml in ${targetFile}...`
    );
  } else if (
    options.usePipenv &&
    fse.existsSync(path.join(servicePath, 'Pipfile'))
  ) {
    filterRequirementsFile(
      path.join(servicePath, '.serverless/requirements.txt'),
      targetFile,
      options
    );
    serverless.cli.log(
      `Parsed requirements.txt from Pipfile in ${targetFile}...`
    );
  } else {
    filterRequirementsFile(requirementsPath, targetFile, options);
    serverless.cli.log(
      `Generated requirements from ${requirementsPath} in ${targetFile}...`
    );
  }
}
function generateRequirementsFile ( requirementsPath , targetFile , serverless , servicePath , options ) { if ( options . usePoetry && fse . existsSync ( path . join ( servicePath , 'pyproject.toml' ) ) ) { filterRequirementsFile ( path . join ( servicePath , '.serverless/requirements.txt' ) , targetFile , options ) ; serverless . cli . log ( ` ${ targetFile } ` ) ; } else if ( options . usePipenv && fse . existsSync ( path . join ( servicePath , 'Pipfile' ) ) ) { filterRequirementsFile ( path . join ( servicePath , '.serverless/requirements.txt' ) , targetFile , options ) ; serverless . cli . log ( ` ${ targetFile } ` ) ; } else { filterRequirementsFile ( requirementsPath , targetFile , options ) ; serverless . cli . log ( ` ${ requirementsPath } ${ targetFile } ` ) ; } }
Just generate the requirements file in the .serverless folder
@param {string} requirementsPath
@param {string} targetFile
@param {Object} serverless
@param {string} servicePath
@param {Object} options
@return {undefined}
Just generate the requirements file in the . serverless folder