lib/pip.js
function installAllRequirements() {
  // fse.ensureDirSync(path.join(this.servicePath, '.serverless'));
  // First, check and delete cache versions, if enabled
  checkForAndDeleteMaxCacheVersions(this.options, this.serverless);

  // Then if we're going to package functions individually...
  if (this.serverless.service.package.individually) {
    let doneModules = [];
    this.targetFuncs
      .filter(func =>
        (func.runtime || this.serverless.service.provider.runtime).match(
          /^python.*/
        )
      )
      .map(f => {
        if (!get(f, 'module')) {
          set(f, ['module'], '.');
        }
        // If we didn't already process a module (functions can re-use modules)
        if (!doneModules.includes(f.module)) {
          const reqsInstalledAt = installRequirementsIfNeeded(
            this.servicePath,
            f.module,
            this.options,
            f,
            this.serverless
          );
          // Add modulePath into .serverless for each module so it's easier for injecting and for users to see where reqs are
          let modulePath = path.join(
            this.servicePath,
            '.serverless',
            `${f.module}`,
            'requirements'
          );
          // Only do if we didn't already do it
          if (
            reqsInstalledAt &&
            !fse.existsSync(modulePath) &&
            reqsInstalledAt != modulePath
          ) {
            if (this.options.useStaticCache) {
              // Windows can't symlink so we have to copy on Windows,
              // it's not as fast, but at least it works
              if (process.platform == 'win32') {
                fse.copySync(reqsInstalledAt, modulePath);
              } else {
                fse.symlink(reqsInstalledAt, modulePath);
              }
            } else {
              fse.rename(reqsInstalledAt, modulePath);
            }
          }
          doneModules.push(f.module);
        }
      });
  } else {
    const reqsInstalledAt = installRequirementsIfNeeded(
      this.servicePath,
      '',
      this.options,
      {},
      this.serverless
    );
    // Add symlinks into .serverless for so it's easier for injecting and for users to see where reqs are
    let symlinkPath = path.join(
      this.servicePath,
      '.serverless',
      `requirements`
    );
    // Only do if we didn't already do it
    if (
      reqsInstalledAt &&
      !fse.existsSync(symlinkPath) &&
      reqsInstalledAt != symlinkPath
    ) {
      // Windows can't symlink so we have to use junction on Windows
      if (process.platform == 'win32') {
        fse.symlink(reqsInstalledAt, symlinkPath, 'junction');
      } else {
        fse.symlink(reqsInstalledAt, symlinkPath);
      }
    }
  }
}
function installAllRequirements() {
  // fse.ensureDirSync(path.join(this.servicePath, '.serverless'));
  // First, check and delete cache versions, if enabled
  checkForAndDeleteMaxCacheVersions(this.options, this.serverless);

  // Then if we're going to package functions individually...
  if (this.serverless.service.package.individually) {
    let doneModules = [];
    this.targetFuncs
      .filter(func =>
        (func.runtime || this.serverless.service.provider.runtime).match(
          /^python.*/
        )
      )
      .map(f => {
        if (!get(f, 'module')) {
          set(f, ['module'], '.');
        }
        // If we didn't already process a module (functions can re-use modules)
        if (!doneModules.includes(f.module)) {
          const reqsInstalledAt = installRequirementsIfNeeded(
            this.servicePath,
            f.module,
            this.options,
            f,
            this.serverless
          );
          // Add modulePath into .serverless for each module so it's easier for injecting and for users to see where reqs are
          let modulePath = path.join(
            this.servicePath,
            '.serverless',
            `${f.module}`,
            'requirements'
          );
          // Only do if we didn't already do it
          if (
            reqsInstalledAt &&
            !fse.existsSync(modulePath) &&
            reqsInstalledAt != modulePath
          ) {
            if (this.options.useStaticCache) {
              // Windows can't symlink so we have to copy on Windows,
              // it's not as fast, but at least it works
              if (process.platform == 'win32') {
                fse.copySync(reqsInstalledAt, modulePath);
              } else {
                fse.symlink(reqsInstalledAt, modulePath);
              }
            } else {
              fse.rename(reqsInstalledAt, modulePath);
            }
          }
          doneModules.push(f.module);
        }
      });
  } else {
    const reqsInstalledAt = installRequirementsIfNeeded(
      this.servicePath,
      '',
      this.options,
      {},
      this.serverless
    );
    // Add symlinks into .serverless for so it's easier for injecting and for users to see where reqs are
    let symlinkPath = path.join(
      this.servicePath,
      '.serverless',
      `requirements`
    );
    // Only do if we didn't already do it
    if (
      reqsInstalledAt &&
      !fse.existsSync(symlinkPath) &&
      reqsInstalledAt != symlinkPath
    ) {
      // Windows can't symlink so we have to use junction on Windows
      if (process.platform == 'win32') {
        fse.symlink(reqsInstalledAt, symlinkPath, 'junction');
      } else {
        fse.symlink(reqsInstalledAt, symlinkPath);
      }
    }
  }
}
function installAllRequirements ( ) { // fse.ensureDirSync(path.join(this.servicePath, '.serverless')); // First, check and delete cache versions, if enabled checkForAndDeleteMaxCacheVersions ( this . options , this . serverless ) ; // Then if we're going to package functions individually... if ( this . serverless . service . package . individually ) { let doneModules = [ ] ; this . targetFuncs . filter ( func => ( func . runtime || this . serverless . service . provider . runtime ) . match ( / ^python.* / ) ) . map ( f => { if ( ! get ( f , 'module' ) ) { set ( f , [ 'module' ] , '.' ) ; } // If we didn't already process a module (functions can re-use modules) if ( ! doneModules . includes ( f . module ) ) { const reqsInstalledAt = installRequirementsIfNeeded ( this . servicePath , f . module , this . options , f , this . serverless ) ; // Add modulePath into .serverless for each module so it's easier for injecting and for users to see where reqs are let modulePath = path . join ( this . servicePath , '.serverless' , ` ${ f . module } ` , 'requirements' ) ; // Only do if we didn't already do it if ( reqsInstalledAt && ! fse . existsSync ( modulePath ) && reqsInstalledAt != modulePath ) { if ( this . options . useStaticCache ) { // Windows can't symlink so we have to copy on Windows, // it's not as fast, but at least it works if ( process . platform == 'win32' ) { fse . copySync ( reqsInstalledAt , modulePath ) ; } else { fse . symlink ( reqsInstalledAt , modulePath ) ; } } else { fse . rename ( reqsInstalledAt , modulePath ) ; } } doneModules . push ( f . module ) ; } } ) ; } else { const reqsInstalledAt = installRequirementsIfNeeded ( this . servicePath , '' , this . options , { } , this . serverless ) ; // Add symlinks into .serverless for so it's easier for injecting and for users to see where reqs are let symlinkPath = path . join ( this . servicePath , '.serverless' , ` ` ) ; // Only do if we didn't already do it if ( reqsInstalledAt && ! fse . existsSync ( symlinkPath ) && reqsInstalledAt != symlinkPath ) { // Windows can't symlink so we have to use junction on Windows if ( process . platform == 'win32' ) { fse . symlink ( reqsInstalledAt , symlinkPath , 'junction' ) ; } else { fse . symlink ( reqsInstalledAt , symlinkPath ) ; } } } }
pip install the requirements to the requirements directory
@return {undefined}
pip install the requirements to the requirements directory