Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
358996
def deduce_helpful_msg(req):
    # type: (str) -> str
    
    msg = ""
    if os.path.exists(req):
        msg = " It does exist."
        # Try to parse and check if it is a requirements file.
        try:
            with open(req, 'r') as fp:
                # parse first line only
                next(parse_requirements(fp.read()))
                msg += " The argument you provided " + \
                    "(%s) appears to be a" % (req) + \
                    " requirements file. If that is the" + \
                    " case, use the '-r' flag to install" + \
                    " the packages specified within it."
        except RequirementParseError:
            logger.debug("Cannot parse '%s' as requirements \
            file" % (req), exc_info=True)
    else:
        msg += " File '%s' does not exist." % (req)
    return msg
360776
def find_requirements(max_depth=3):
    """"""
    i = 0
    for c, d, f in walk_up(os.getcwd()):
        i += 1
        if i < max_depth:
            if "requirements.txt":
                r = os.path.join(c, "requirements.txt")
                if os.path.isfile(r):
                    return r

    raise RuntimeError("No requirements.txt found!")
1150937
def peep_port(paths):
    
    if not paths:
        print('Please specify one or more requirements files so I have '
              'something to port.\n')
        return COMMAND_LINE_ERROR

    comes_from = None
    for req in chain.from_iterable(
            _parse_requirements(path, package_finder(argv)) for path in paths):
        req_path, req_line = path_and_line(req)
        hashes = [hexlify(urlsafe_b64decode((hash + '=').encode('ascii'))).decode('ascii')
                  for hash in hashes_above(req_path, req_line)]
        if req_path != comes_from:
            print()
            print('# from %s' % req_path)
            print()
            comes_from = req_path

        if not hashes:
            print(req.req)
        else:
            print('%s' % (req.link if getattr(req, 'link', None) else req.req), end='')
            for hash in hashes:
                print(' \\')
                print('    --hash=sha256:%s' % hash, end='')
            print()
467158
function tryRequire(filePath) {
  let resolvedPath = req.resolve(filePath);

  if (resolvedPath) {
    return req(resolvedPath);
  }

  return undefined;
}
1161948
def get_requirements():
    ''''''
    packages = []
    with open("requirements.txt", "r") as req_doc:
        for package in req_doc:
            packages.append(package.replace("\n", ""))
    return packages
543427
async def requirements(client: Client, search: str) -> dict:
    
    return await client.get(MODULE + '/requirements/%s' % search, schema=REQUIREMENTS_SCHEMA)
859373
def install_via_requirements(requirements_str, force=False):
    
    if requirements_str[0] == '@':
        path = requirements_str[1:]
        if os.path.isfile(path):
            yaml_data = load_yaml(path)
            if 'packages' not in yaml_data.keys():
                raise CommandException('Error in {filename}: missing "packages" node'.format(filename=path))
        else:
            raise CommandException("Requirements file not found: {filename}".format(filename=path))
    else:
        yaml_data = yaml.safe_load(requirements_str)
    for pkginfo in yaml_data['packages']:
        info = parse_package_extended(pkginfo)
        install(info.full_name, info.hash, info.version, info.tag, force=force)
851274
def requirements(self, requires):
        '''
        
        '''
        if requires:
            if isinstance(requires, basestring) and \
               os.path.isfile(os.path.abspath(requires)):
                self._requirements_file = os.path.abspath(requires)
            else:
                if isinstance(self._requirements, basestring):
                    requires = requires.split()
                self._requirements_file = None
                self._requirements = requires
        else:
            # If the default requirements file is found use that
            if os.path.isfile(self._requirements_file):
                return
            self._requirements, self._requirements_file = None, None
645030
def requirements(requirements_file):
    
    return [
        str(pkg.req) for pkg in parse_requirements(
            requirements_file, session=pip_download.PipSession()) if pkg.req is not None]
1037153
def load_requirements(*requirements_paths):
    
    requirements = set()
    for path in requirements_paths:
        requirements.update(
            line.split('#')[0].strip() for line in open(path).readlines()
            if is_requirement(line.strip())
        )
    return list(requirements)
1228614
def get_requirements():
    """"""
    with open(os.path.join(topdir, 'requirements.txt')) as fin:
        lines = fin.readlines()
    lines = [line.strip() for line in lines]
    return lines
1254266
def check_file_path(self, path):
        
        if os.path.exists(path) is not True:
            msg = "File Not Found {}".format(path)
            raise OSError(msg)
535276
def get_requirement_files(args=None):
    
    if args and args.input_filename:
        return [args.input_filename]

    paths = []
    for regex in settings.REQUIREMENTS_SOURCE_GLOBS:
        paths.extend(glob.glob(regex))
    return paths
1315458
def get_requirements_information(self, path: Path) -> Tuple[RequirementsOptions, Optional[str]]:
        
        if self.pipfile_location is not None:
            pipfile = path / self.pipfile_location / "Pipfile"
            pipfile_lock = path / self.pipfile_location / "Pipfile.lock"

            pipfile_exists = pipfile.exists()
            pipfile_lock_exists = pipfile_lock.exists()

            if pipfile_exists and pipfile_lock_exists:
                option = RequirementsOptions.pipfile
                return option, self.hash_file_contents(option, pipfile_lock)
            elif pipfile_exists:
                raise BuildError("Only the Pipfile is included in the repository, Arca does not support that.")
            elif pipfile_lock_exists:
                raise BuildError("Only the Pipfile.lock file is include in the repository, Arca does not support that.")

        if self.requirements_location:
            requirements_file = path / self.requirements_location

            if requirements_file.exists():
                option = RequirementsOptions.requirements_txt
                return option, self.hash_file_contents(option, requirements_file)

        return RequirementsOptions.no_requirements, None
1190839
def find_requirement(self, req, upgrade, ignore_compatibility=False):
        # type: (InstallRequirement, bool, bool) -> Optional[Link]
        
        all_candidates = self.find_all_candidates(req.name)

        # Filter out anything which doesn't match our specifier
        compatible_versions = set(
            req.specifier.filter(
                # We turn the version object into a str here because otherwise
                # when we're debundled but setuptools isn't, Python will see
                # packaging.version.Version and
                # pkg_resources._vendor.packaging.version.Version as different
                # types. This way we'll use a str as a common data interchange
                # format. If we stop using the pkg_resources provided specifier
                # and start using our own, we can drop the cast to str().
                [str(c.version) for c in all_candidates],
                prereleases=(
                    self.allow_all_prereleases
                    if self.allow_all_prereleases else None
                ),
            )
        )
        applicable_candidates = [
            # Again, converting to str to deal with debundling.
            c for c in all_candidates if str(c.version) in compatible_versions
        ]

        if applicable_candidates:
            best_candidate = max(applicable_candidates,
                                 key=self._candidate_sort_key)
        else:
            best_candidate = None

        if req.satisfied_by is not None:
            installed_version = parse_version(req.satisfied_by.version)
        else:
            installed_version = None

        if installed_version is None and best_candidate is None:
            logger.critical(
                'Could not find a version that satisfies the requirement %s '
                '(from versions: %s)',
                req,
                ', '.join(
                    sorted(
                        {str(c.version) for c in all_candidates},
                        key=parse_version,
                    )
                )
            )

            raise DistributionNotFound(
                'No matching distribution found for %s' % req
            )

        best_installed = False
        if installed_version and (
                best_candidate is None or
                best_candidate.version <= installed_version):
            best_installed = True

        if not upgrade and installed_version is not None:
            if best_installed:
                logger.debug(
                    'Existing installed version (%s) is most up-to-date and '
                    'satisfies requirement',
                    installed_version,
                )
            else:
                logger.debug(
                    'Existing installed version (%s) satisfies requirement '
                    '(most up-to-date version is %s)',
                    installed_version,
                    best_candidate.version,
                )
            return None

        if best_installed:
            # We have an existing version, and its the best version
            logger.debug(
                'Installed version (%s) is most up-to-date (past versions: '
                '%s)',
                installed_version,
                ', '.join(sorted(compatible_versions, key=parse_version)) or
                "none",
            )
            raise BestVersionAlreadyInstalled

        logger.debug(
            'Using version %s (newest of versions: %s)',
            best_candidate.version,
            ', '.join(sorted(compatible_versions, key=parse_version))
        )
        return best_candidate.location
1229447
def _read_requirements(filename, extra_packages):
    """"""
    requirements_file = open(filename).read()

    hard_requirements = []
    for line in requirements_file.splitlines():
        if _is_requirement(line):
            if line.find(';') > -1:
                dep, condition = tuple(line.split(';'))
                extra_packages[condition.strip()].append(dep.strip())
            else:
                hard_requirements.append(line.strip())
    return hard_requirements, extra_packages
1029700
def check_requirements(self, request=None, response=None, context=None):
        
        for requirement in self.requires:
            conclusion = requirement(response=response, request=request, context=context, module=self.api.module)
            if conclusion and conclusion is not True:
                return conclusion