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}
184152
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}...`
    );
  }
}
1206361
function serveRawSwaggerFiles (req, res, next) {
    if (req.method === "GET" || req.method === "HEAD") {
      let configPath = getConfiguredPath(options.rawFilesPath);
      configPath = util.normalizePath(configPath, router);
      let reqPath = util.normalizePath(req.path, router);

      if (_.startsWith(reqPath, configPath) && context.parser && context.parser.$refs) {
        // Get the normalized path of the requested file, relative to the baseDir
        let relativePath = req.path.substring(configPath.length);
        if (_.startsWith(relativePath, "/")) {
          relativePath = relativePath.substring(1);
        }
        relativePath = path.normalize(util.normalizePath(relativePath, router));

        // See if any of the Swagger files match this path
        let filePath = _.find(context.parser.$refs.paths(), (file) => {
          let relativeFile = path.relative(baseDir, file);
          relativeFile = util.normalizePath(relativeFile, router);
          return relativeFile === relativePath;
        });

        if (filePath) {
          // Normalize the file path (required for Windows)
          filePath = path.normalize(filePath);

          util.debug("%s %s => Sending file %s", req.method, req.path, filePath);
          res.sendFile(filePath);
          return;
        }
        else {
          util.debug("%s %s does not match any files in the Swagger API", req.method, req.path);
        }
      }
    }

    next();
  }
561198
function removeVendorHelper() {
  if (this.options.zip && this.options.cleanupZipHelper) {
    if (this.serverless.service.package.individually) {
      return BbPromise.resolve(this.targetFuncs)
        .map(f => {
          if (!get(f, 'module')) {
            set(f, ['module'], '.');
          }
          return f;
        })
        .then(funcs => uniqBy(funcs, f => f.module))
        .map(f => {
          this.serverless.cli.log(
            `Removing Python requirements helper from ${f.module}...`
          );
          return fse.removeAsync(
            path.join(this.servicePath, f.module, 'unzip_requirements.py')
          );
        });
    } else {
      this.serverless.cli.log('Removing Python requirements helper...');
      return fse.removeAsync(
        path.join(this.servicePath, 'unzip_requirements.py')
      );
    }
  }
}
1200423
def get_requirements(requirements_filepath):
    '''
    
    '''
    requirements = []
    with open(os.path.join(ROOT_DIR, requirements_filepath), 'rt') as f:
        for line in f:
            if line.startswith('#'):
                continue
            line = line.rstrip()
            if not line:
                continue
            requirements.append(line)
    return requirements
2004
function FileClient(serviceRegistry, filter) {
		var _patterns;
		var _services;
		var _names;

		EventTarget.attach(this);
		/* @callback */
		function _noMatch(loc) {
			var d = new Deferred();
			d.reject(messages["No Matching FileService for location:"] + loc);
			return d;
		}

		var _fileSystemsRoots = [];
		var _allFileSystemsService = {
			/* @callback */
			fetchChildren: function() {
				var d = new Deferred();
				d.resolve(_fileSystemsRoots);
				return d;
			},
			/* @callback */
			createWorkspace: function() {
				var d = new Deferred();
				d.reject(messages["no file service"]);
				return d;
			},
			/* @callback */
			loadWorkspaces: function() {
				var d = new Deferred();
				d.reject(messages['no file service']);
				return d;
			},
			/* @callback */
			loadWorkspace: function(loc) {
				var d = new Deferred();
				window.setTimeout(function() {
					d.resolve({
						Directory: true,
						Length: 0,
						LocalTimeStamp: 0,
						Name: messages["File Servers"],
						Location: "/",
						Children: _fileSystemsRoots,
						ChildrenLocation: "/"
					});
				}, 100);
				return d;
			},
			/* @callback */
			read: function(loc) {
				if (loc === "/") {
					return this.loadWorkspace(loc);
				}
				return _noMatch(loc);
			},
			/**
			 * @description Computes the project context from the given location
			 * @param {String} context The resource context to find the project for
			 * @since 14.0
			 */
			getProject: _noMatch,
			search: _noMatch,
			createProject: _noMatch,
			createFolder: _noMatch,
			createFile: _noMatch,
			deleteFile: _noMatch,
			moveFile: _noMatch,
			copyFile: _noMatch,
			write: _noMatch
		};

		/**
		 * @description Initialize the service
		 * @private
		 */
		function init() {
			if (_services) { return; }
			_patterns = [];
			_services = [];
			_names = [];

			var allReferences = serviceRegistry.getServiceReferences("orion.core.file"); //$NON-NLS-1$
			var _references = allReferences;
			if (filter) {
				_references = [];
				for(var i = 0; i < allReferences.length; ++i) {
					if (filter(allReferences[i])) {
						_references.push(allReferences[i]);
					}
				}
			}
			_references.sort(function (ref1, ref2) {
				var ranking1 = ref1.getProperty("ranking") || 0; //$NON-NLS-1$
				var ranking2 = ref2.getProperty("ranking")  || 0; //$NON-NLS-1$
				return ranking1 - ranking2;
			});
			for(var j = 0; j < _references.length; ++j) {
				_fileSystemsRoots[j] = {
					Directory: true,
					Length: 0,
					LocalTimeStamp: 0,
					Location: _references[j].getProperty("top"), //$NON-NLS-1$
					ChildrenLocation: _references[j].getProperty("top"), //$NON-NLS-1$
					Name: _references[j].getProperty("Name") || _references[j].getProperty("NameKey") //$NON-NLS-1$ //$NON-NLS-2$
				};

				var filetop = _references[j].getProperty("top"); //$NON-NLS-1$
				var patternStringArray = _references[j].getProperty("pattern") || (filetop ? filetop.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") : ""); //$NON-NLS-1$ //$NON-NLS-2$
				if (!Array.isArray(patternStringArray)) {
					patternStringArray = [patternStringArray];
				}
				var patterns = [];
				for (var k = 0; k < patternStringArray.length; k++) {
					var patternString = patternStringArray[k];
					if (patternString[0] !== "^") {
						patternString = "^" + patternString;
					}
					patterns.push(new RegExp(patternString));
				}
				_patterns[j] = patterns;
				_services[j] = serviceRegistry.getService(_references[j]);
				_names[j] = _references[j].getProperty("Name") || _references[j].getProperty("NameKey"); //$NON-NLS-1$ //$NON-NLS-2$
			}
		}

		/**
		 * @description Returns the index of the service for the given item location
		 * @function
		 * @private
		 * @param {String} itemLocation
		 * @returns returns
		 */
		this._getServiceIndex = function(itemLocation) {
			init();
			// client must specify via "/" when a multi file service tree is truly wanted
			if (itemLocation === "/") {
				return -1;
			} else if (!itemLocation || itemLocation.length && itemLocation.length === 0) {
				// TODO we could make the default file service a preference but for now we use the first one
				return _services[0] ? 0 : -1;
			}
			for(var i = 0; i < _patterns.length; ++i) {
				for (var j = 0; j < _patterns[i].length; j++) {
					if (_patterns[i][j].test(itemLocation)) {
						return i;
					}
				}
			}
			throw new Error(i18nUtil.formatMessage(messages['NoFileSrv'], itemLocation));
		};
		/**
		 * Returns the file service managing this location
		 * @param {String} itemLocation The location of the item
		 * @private
		 * @returns {FileClient} The service for the given item
		 */
		this._getService = function(itemLocation) {
			var i = this._getServiceIndex(itemLocation);
			return i === -1 ? _allFileSystemsService : _services[i];
		};
		/**
		 * Returns the name of the file service managing this location
		 * @param {String} itemLocation The location of the item
		 * @private
		 * @return {String} The name of this file service
		 */
		this._getServiceName = function(itemLocation) {
			var i = this._getServiceIndex(itemLocation);
			return i === -1 ? _allFileSystemsService.Name : _names[i];
		};
		/**
		 * Returns the root url of the file service managing this location
		 * @param {String} itemLocation The location of the item
		 * @private
		 * @return {String} The root URL of the given item
		 */
		this._getServiceRootURL = function(itemLocation) {
			var i = this._getServiceIndex(itemLocation);
			return i === -1 ? _allFileSystemsService.Location : _fileSystemsRoots[i].Location;
		};

		this._frozenEvent = {type: "Changed"};
		this._eventFrozenMode = false;

		serviceRegistry.registerService("orion.core.file.client", this); //$NON-NLS-1$
	}
393777
function requirePath(fromPath, require) {
  // console.log('requirePath:fromPath: ' + fromPath);
  // console.log('requirePath:require: ' + require);
  if (fromPath === null || fromPath === undefined
    || require === null || require === undefined) {
    return null;
  }
  var filePath = path.resolve(path.dirname(fromPath), require);
  return realRequirPath(filePath);
}
374026
def generate_requirements_files(self, base_dir='.'):
        

        print("Creating requirements files\n")

        # TODO How to deal with requirements that are not simple, e.g. a github url

        shared = self._get_shared_section()

        requirements_dir = self._make_requirements_directory(base_dir)

        for section in self.config.sections():
            if section == 'metadata':
                continue

            requirements = {}
            for option in self.config.options(section):
                requirements[option] = self.config.get(section, option)

            if not requirements:
                # No need to write out an empty file
                continue

            filename = os.path.join(requirements_dir, '%s.txt' % section)
            self._write_requirements_file(shared, section, requirements, filename)
580143
function fetchArchive(targetPath, template) {
  var q = Q.defer();
  var replace = require("replace");

  var archiveUrl = template.repo
  // The folder name the project will be downloaded and extracted to
  var message = ['Downloading:'.bold, archiveUrl].join(' ');
  console.log(message);

  var tmpFolder = os.tmpdir();
  var tempZipFilePath = path.join(tmpFolder, 'mobilecaddy-' + new Date().getTime());

  new Download({mode: '755', extract: true})
    .get(archiveUrl)
    .dest(tempZipFilePath)
    .run(function (err, files) {
        if (!err) {
          fs.rename(files[0].path, targetPath,
            function(res){
              if (!res) {
                replace({
                    regex: template.name,
                    replacement: targetPath,
                    paths: [targetPath],
                    recursive: true,
                    silent: true,
                });
                q.resolve();
              } else {
                console.error('Renaming template repo failed '.error);
                console.error(res);
                q.reject(res);
              }
            })
        } else {
          console.error(err);
          q.reject(err);
        }
    });

  return q.promise;
}
969263
function isPoetryProject(servicePath) {
  const pyprojectPath = path.join(servicePath, 'pyproject.toml');

  if (!fse.existsSync(pyprojectPath)) {
    return false;
  }

  const pyprojectToml = fs.readFileSync(pyprojectPath);
  const pyproject = tomlParse(pyprojectToml);

  const buildSystemReqs =
    (pyproject['build-system'] && pyproject['build-system']['requires']) || [];

  for (var i = 0; i < buildSystemReqs.length; i++) {
    if (buildSystemReqs[i].startsWith('poetry')) {
      return true;
    }
  }

  return false;
}
370242
function tryBindPath(serverless, bindPath, testFile) {
  const options = [
    'run',
    '--rm',
    '-v',
    `${bindPath}:/test`,
    'alpine',
    'ls',
    `/test/${testFile}`
  ];
  try {
    const ps = dockerCommand(options);
    if (process.env.SLS_DEBUG) {
      serverless.cli.log(`Trying bindPath ${bindPath} (${options})`);
      serverless.cli.log(ps.stdout.trim());
    }
    return ps.stdout.trim() === `/test/${testFile}`;
  } catch (err) {
    return false;
  }
}
259916
function (deployPath) {
  const envFilePath = setupHelper.setupFolderAbsolutePath() + '/' + setupConfig.env_vars_file
    , clearCacheOfExpr = /(openst-platform\/config\/)|(openst-platform\/lib\/)|(openst-platform\/services\/)/;

  return new Promise(function (onResolve, onReject) {
    // source env
    shellSource(envFilePath, async function (err) {
      if (err) {
        throw err;
      }
      Object.keys(require.cache).forEach(function (key) {
        if (key.search(clearCacheOfExpr) !== -1) {
          delete require.cache[key];
        }
      });

      const setupHelper = require(deployPath);
      return onResolve(await setupHelper.perform());
    });
  });

}
704155
function createPackTargetFile(options, context) {
    var ns = fis.config.get('namespace');
    var connector = fis.config.get('namespaceConnector', ':');

    var packFile = options.target;
    if (!packFile) {
        fis.log.error('missing the pack target info');
        return;
    }

    var pkgId = options.packId || ((ns ? ns + connector : '') + 'p' + (pkgCounter++));
    var pkg = context.createFile(packFile, {useHash: true,isPackBundles:!!options.isPackBundles});
    var pkgPath = pkg.subpath;
    if (context.isPackageIdExist(pkgId)) {
        return fis.log.error('duplicate package id: %s', pkgId);
    }

    if (context.isFileExisted(pkg)) {
        pkg = context.getFileBySubPath(pkgPath);
        // fis.log.warning('there is a namesake file of package [' + pkgPath + ']');

        if (pkg.isPkgFile) {
            fis.log.info('ignore the same pack target %s', pkgPath);
            return {
                referPkg: pkg.pkgId
            };
        }

        if (pkg.release === false || pkg.isPartial) {
            fis.log.warn(
                'the pack target is not released or is part of anthor files: %s',
                pkgPath
            );
            return;
        }

        pkg.useExistedPack = true;
    }

    pkg.isPkgFile = true;
    pkg.pkgId = pkgId;

    return pkg;
}
800162
function(targetPath, callback) {
            client
                .deleteFile(targetPath)
                .then(function() {
                    __executeCallbackAsync(callback, [null]);
                })
                .catch(callback);
        }
1205473
function realRequirPath(filePath) {
  // console.log('realRequirPath:filePath: ' + filePath);
  var jsFilePath = filePath + '.js';
  if (fs.existsSync(filePath)) {
    if (fs.statSync(filePath).isDirectory()) {
      jsFilePath = filePath + '.js';
      if (fs.existsSync(jsFilePath)) {
        return jsFilePath;
      } else {
        jsFilePath = path.join(filePath, 'index.js');
      }
      // console.log('realRequirPath:jsFilePath: ' + jsFilePath);
    } else if (fs.statSync(filePath).isFile()) {
      return filePath;
    } else {
      return null;
    }
  } else {
    jsFilePath = filePath + '.js';
    // console.log('realRequirPath:filePath: ' + filePath);
  }

  if (fs.existsSync(jsFilePath)) {
    // console.log('realRequirPath:filePath: ' + filePath);
    return jsFilePath;
  } else {
    return null;
  }
}
981353
def parse_requirements(path):
    
    try:
        print(os.path.join(os.path.dirname(__file__), *path.splitlines()))
        requirements = map(str.strip, local_file(path).splitlines())
    except IOError:
        raise RuntimeError("Couldn't find the `requirements.txt' file :(")

    links = []
    pkgs = []
    for req in requirements:
        if not req:
            continue
        if 'http:' in req or 'https:' in req:
            links.append(req)
            name, version = re.findall("\#egg=([^\-]+)-(.+$)", req)[0]
            pkgs.append('{0}=={1}'.format(name, version))
        else:
            pkgs.append(req)

    return pkgs, links
798353
function createSourceFilesMiddleware (filesPromise, serveFile, basePath, urlRoot) {
  return function (request, response, next) {
    const requestedFilePath = composeUrl(request.url, basePath, urlRoot)
    // When a path contains HTML-encoded characters (e.g %2F used by Jenkins for branches with /)
    const requestedFilePathUnescaped = composeUrl(querystring.unescape(request.url), basePath, urlRoot)

    request.pause()

    log.debug(`Requesting ${request.url}`)
    log.debug(`Fetching ${requestedFilePath}`)

    return filesPromise.then(function (files) {
      // TODO(vojta): change served to be a map rather then an array
      const file = findByPath(files.served, requestedFilePath) || findByPath(files.served, requestedFilePathUnescaped)
      const rangeHeader = request.headers['range']

      if (file) {
        const acceptEncodingHeader = request.headers['accept-encoding']
        const matchedEncoding = Object.keys(file.encodings).find(
          (encoding) => new RegExp(`(^|.*, ?)${encoding}(,|$)`).test(acceptEncodingHeader)
        )
        const content = file.encodings[matchedEncoding] || file.content

        serveFile(file.contentPath || file.path, rangeHeader, response, function () {
          if (/\?\w+/.test(request.url)) {
            common.setHeavyCacheHeaders(response) // files with timestamps - cache one year, rely on timestamps
          } else {
            common.setNoCacheHeaders(response) // without timestamps - no cache (debug)
          }
          if (matchedEncoding) {
            response.setHeader('Content-Encoding', matchedEncoding)
          }
        }, content, file.doNotCache)
      } else {
        next()
      }

      request.resume()
    })
  }
}
447257
private Result compile(File source, File target) throws ServiceException {
        AssetServices assetServices = ServiceLocator.getAssetServices();
        AssetInfo parser = assetServices.getAsset(NODE_PACKAGE + "/parser.js");
        if (parser == null)
            throw new ServiceException(ServiceException.NOT_FOUND, "Asset not found: " + parser);
        AssetInfo runner = assetServices.getAsset(NODE_PACKAGE + "/webpackRunner.js");
        if (runner == null)
            throw new ServiceException(ServiceException.NOT_FOUND, "Asset not found: " + runner);

        NodeJS nodeJS = NodeJS.createNodeJS();

        logger.info("Compiling " + source + " using NODE JS: " + nodeJS.getNodeVersion());
        V8Object fileObj = new V8Object(nodeJS.getRuntime()).add("file", runner.getFile().getAbsolutePath());
        JavaCallback callback = (receiver, parameters) -> fileObj;
        nodeJS.getRuntime().registerJavaMethod(callback, "getRunner");

        final Result parseResult = new Result();
        callback = (receiver, parameters) -> {
            V8Object resultObj = parameters.getObject(0);
            parseResult.status = resultObj.getString("status");
            parseResult.message = resultObj.getString("message");
            resultObj.release();
            return null;
        };
        nodeJS.getRuntime().registerJavaMethod(callback, "setParseResult");

        nodeJS.exec(parser.getFile());
        while (nodeJS.isRunning()) {
            nodeJS.handleMessage();
        }

        fileObj.release();
        nodeJS.release();

        if (!parseResult.status.equals("OK"))
            throw new ServiceException(runner + " -> " + parseResult);

        // run
        nodeJS = NodeJS.createNodeJS();
        V8Object inputObj = new V8Object(nodeJS.getRuntime());
        inputObj.add("source", source.getAbsolutePath());
        inputObj.add("root", assetServices.getAssetRoot().getAbsolutePath());
        inputObj.add("output", target.getAbsolutePath());
        inputObj.add("debug", logger.isDebugEnabled());
        inputObj.add("devMode", isDevMode());
        callback = (receiver, parameters) -> inputObj;
        nodeJS.getRuntime().registerJavaMethod(callback, "getInput");

        final Result webpackResult = new Result();
        callback = (receiver, parameters) -> {
            V8Object resultObj = parameters.getObject(0);
            webpackResult.status = resultObj.getString("status");
            webpackResult.message = resultObj.getString("message");
            resultObj.release();
            return null;
        };
        nodeJS.getRuntime().registerJavaMethod(callback, "setWebpackResult");

        nodeJS.exec(runner.getFile());
        while (nodeJS.isRunning()) {
            nodeJS.handleMessage();
        }
        inputObj.release();
        nodeJS.release();

        if (!webpackResult.status.equals("OK"))
            throw new ServiceException(source + " -> " + webpackResult);

        return webpackResult;
    }