Read the requirements.txt file and parse into requirements for setup's
  install_requirements option.
484817
def findRequirements():
  
  requirementsPath = os.path.join(REPO_DIR, "requirements.txt")
  requirements = parse_file(requirementsPath)

  # User has a pre-release version of numenta packages installed, which is only
  # possible if the user installed and built the packages from source and
  # it is up to the user to decide when to update these packages.  We'll
  # quietly remove the entries in requirements.txt so as to not conflate the
  # two.
  if nupicPrereleaseInstalled():
    requirements = [req for req in requirements if "nupic" not in req]

  if htmresearchCorePrereleaseInstalled():
    requirements = [req for req in requirements if "htmresearch-core" not in req]

  return requirements
827529
def install_reqs(venv, repo_dest):
    """"""
    with dir_path(repo_dest):
        args = ['-r', 'requirements/compiled.txt']
        if not verbose:
            args.insert(0, '-q')
        subprocess.check_call([os.path.join(venv, 'bin', 'pip'), 'install'] +
                              args)
1154788
def get_requirements(source):
    

    install_reqs = parse_requirements(filename=source, session=PipSession())

    return [str(ir.req) for ir in install_reqs]
187514
def parse_pip_file(path):
    """"""
    # requirement lines sorted by importance
    # also collect other pip commands
    rdev = dict()
    rnormal = []
    stuff = []

    try:
        with open(path) as f:
            for line in f:
                line = line.strip()

                # see https://pip.readthedocs.org/en/1.1/requirements.html
                if line.startswith('-e'):
                    # devel requirement
                    splitted = line.split('#egg=')
                    rdev[splitted[1].lower()] = line

                elif line.startswith('-r'):
                    # recursive file command
                    splitted = re.split('-r\\s+', line)
                    subrdev, subrnormal, substuff = parse_pip_file(splitted[1])
                    for k, v in subrdev.iteritems():
                        if k not in rdev:
                            rdev[k] = v
                    rnormal.extend(subrnormal)
                    result.extend(substuff)

                elif line.startswith('-'):
                    # another special command we don't recognize
                    stuff.append(line)

                else:
                    # ordenary requirement, similary to them used in setup.py
                    rnormal.append(line)
    except IOError:
        print(
            'Warning: could not parse requirements file "{}"!',
            file=sys.stderr
        )

    return rdev, rnormal, stuff
536900
def _install_requirements(requirements):
    """"""
    import importlib
    import pip

    pip.main(["install", "-r", requirements])
    # Some shenanigans to be sure everything is importable after this, especially .egg-link files which
    # are referenced in *.pth files and apparently loaded by site.py at some magic bootstrap moment of the
    # python interpreter.
    pip.utils.pkg_resources = importlib.reload(pip.utils.pkg_resources)
    import site

    importlib.reload(site)
1167235
def python_dependencies(context: Context, extras=None):
    
    with mock.patch('setuptools.setup'):
        from setup import install_requires, extras_require

        requirements = install_requires.copy()
        if extras:
            requirements.extend(extras_require[extras])
    return context.pip_command('install', *requirements)
497341
def get_install_requirements_dockerfile(self, name: str, tag: str, repo_path: Path,
                                            requirements_option: RequirementsOptions) -> str:
        
        if requirements_option == RequirementsOptions.requirements_txt:
            target_file = "requirements.txt"
            requirements_files = [repo_path / self.requirements_location]

            install_cmd = "pip"
            cmd_arguments = "install -r /srv/requirements.txt"

        elif requirements_option == RequirementsOptions.pipfile:
            target_file = ""
            requirements_files = [repo_path / self.pipfile_location / "Pipfile",
                                  repo_path / self.pipfile_location / "Pipfile.lock"]

            install_cmd = "pipenv"
            cmd_arguments = "install --system --ignore-pipfile --deploy"
        else:
            raise ValueError("Invalid requirements_option")

        dockerfile = self.INSTALL_REQUIREMENTS.format(
            name=name,
            tag=tag,
            timeout=self.requirements_timeout,
            target_file=target_file,
            requirements_files=" ".join(str(x.relative_to(repo_path.parent)) for x in requirements_files),
            cmd_arguments=cmd_arguments,
            install_cmd=install_cmd
        )

        logger.debug("Installing Python requirements with Dockerfile: %s", dockerfile)

        return dockerfile
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
1300078
def get_requirements(lookup=None):
    ''''''

    if lookup == None:
        lookup = get_lookup()

    install_requires = []
    for module in lookup['INSTALL_REQUIRES']:
        module_name = module[0]
        module_meta = module[1]
        if "exact_version" in module_meta:
            dependency = "%s==%s" %(module_name,module_meta['exact_version'])
        elif "min_version" in module_meta:
            if module_meta['min_version'] == None:
                dependency = module_name
            else:
                dependency = "%s>=%s" %(module_name,module_meta['min_version'])
        install_requires.append(dependency)
    return install_requires
341284
def get_requirements(filename=None):
    
    if filename is None:
        filename = 'requirements.txt'

    file = WORK_DIR / filename

    install_reqs = parse_requirements(str(file), session='hack')
    return [str(ir.req) for ir in install_reqs]
139391
def requirements(filename):
    """"""
    with open(filename) as f:
        return [x.strip() for x in f.readlines() if x.strip()]
992386
def parse_requirements(requirements_file):
    

    if os.path.exists(requirements_file):
        # return a list that contains each line of the requirements file
        return open(requirements_file, 'r').read().splitlines()
    else:
        print("ERROR: requirements file " + requirements_file + " not found.")
        sys.exit(1)
747388
def parse_reqs(filename):
    """"""
    install_reqs = parse_requirements(filename, session=False)
    return [str(ir.req) for ir in install_reqs]
285652
def check(path_dir, requirements_name='requirements.txt'):
    ''''''
    requirements = _load_requirements(requirements_name, path_dir)
    imported_modules = _iter_modules(path_dir)
    installed_packages = _list_installed_packages()

    imported_modules.update(_excluded_imports())

    diff = {lib for lib in installed_packages if lib not in imported_modules}
    with_dependencies, _ = _list_dependencies(diff)
    unused_dependencies = sorted([d for d in diff if d in requirements])

    for unused_dependency in unused_dependencies:
        if with_dependencies.get(unused_dependency):
            print('    - {}'.format(unused_dependency))
            for dependency in with_dependencies.get(unused_dependency):
                print('\t - {}'.format(dependency))
        else:
            print('    - {}'.format(unused_dependency))
1313426
def _parse_requirements_file(requirements_file):
    '''
    
    '''
    parsed_requirements = []
    with open(requirements_file) as rfh:
        for line in rfh.readlines():
            line = line.strip()
            if not line or line.startswith(('#', '-r')):
                continue
            parsed_requirements.append(line)
    return parsed_requirements
640760
def _generate_requirements(self):
        """"""
        if not self._pip_packages:
            return

        reqs = ''
        for req in self._pip_packages:
                reqs += "{}\n".format(req)
        reqs_include = {
            'contents': reqs,
            'target':'opt/python/streams',
            'name': 'requirements.txt'}

        if 'opt' not in self._files:
             self._files['opt'] = [reqs_include]
        else:
             self._files['opt'].append(reqs_include)
961773
def get_requirements():
    """"""

    install_requires = []
    with open("requirements/project.txt") as f:
        for line in f:
            if not line.startswith("#"):
                install_requires.append(line.strip())
    return install_requires