Parse pip requirement file and transform it to setuptools requirements
351668
def pip(filename):
    ''''''
    requirements = []
    for line in open(os.path.join('requirements', filename)).readlines():
        match = RE_REQUIREMENT.match(line)
        if match:
            requirements.extend(pip(match.group('filename')))
        else:
            requirements.append(line)
    return requirements
89290
def install_pip(env, requirements):
    """"""
    try:
        installation_source_folder = config.installation_cache_folder()
        options = setuptools_install_options(installation_source_folder)
        if installation_source_folder is not None:
            zip_eggs_in_folder(installation_source_folder)
        env.execute(["-m", "easy_install"] + options + requirements)
    except (KeyboardInterrupt, SystemExit):
        raise
    except Exception:
        raise EnvironmentSetupError("pip installation failed.")
930397
def load_requirements(self):
        """"""

        for module_name, pip_name in iteritems(self.metadata.requirements):
            extant = self.dataset.config.requirements[module_name].url

            force = (extant and extant != pip_name)

            self._library.install_packages(module_name, pip_name, force=force)

            self.dataset.config.requirements[module_name].url = pip_name

        python_dir = self._library.filesystem.python()
        sys.path.append(python_dir)
1218191
def pip(filename):
    ''''''
    path = join('requirements', filename)
    return [line for line in open(path).readlines() if not line.startswith('-e')]
20255
def install_package_requirements(self, psrc, stream_output=None):
        
        package = self.target + '/' + psrc
        assert isdir(package), package
        reqname = '/requirements.txt'
        if not exists(package + reqname):
            reqname = '/pip-requirements.txt'
            if not exists(package + reqname):
                return
        return self.user_run_script(
            script=scripts.get_script_path('install_reqs.sh'),
            args=['/project/' + psrc + reqname],
            rw_venv=True,
            rw_project=True,
            stream_output=stream_output
            )
1012427
def parse_setup(filepath):
    ''''''
    # TODO: Need to parse setup.cfg and merge with the data from below

    # Monkey patch setuptools.setup to capture keyword arguments
    setup_kwargs = {}

    def setup_interceptor(**kwargs):
        setup_kwargs.update(kwargs)

    import setuptools
    setuptools_setup = setuptools.setup
    setuptools.setup = setup_interceptor

    # Manually compile setup.py
    with open(filepath, 'r') as f:
        code = compile(f.read(), '', 'exec')
    setup = ModuleType('setup')
    exec(code, setup.__dict__)

    # Remove monkey patch
    setuptools.setup = setuptools_setup
    return setup_kwargs
103832
def parse_fade_requirement(text):
    """"""
    text = text.strip()

    if "::" in text:
        repo_raw, requirement = text.split("::", 1)
        try:
            repo = {'pypi': REPO_PYPI, 'vcs': REPO_VCS}[repo_raw]
        except KeyError:
            logger.warning("Not understood fades repository: %r", repo_raw)
            return
    else:
        if ":" in text and "/" in text:
            repo = REPO_VCS
        else:
            repo = REPO_PYPI
        requirement = text

    if repo == REPO_VCS:
        dependency = VCSDependency(requirement)
    else:
        dependency = list(parse_requirements(requirement))[0]
    return repo, dependency
390066
def setup():
    """"""
    install_requirements = ["attrdict"]
    if sys.version_info[:2] < (3, 4):
        install_requirements.append("pathlib")
    setup_requirements = ['six', 'setuptools>=17.1', 'setuptools_scm']
    needs_sphinx = {
        'build_sphinx',
        'docs',
        'upload_docs',
    }.intersection(sys.argv)
    if needs_sphinx:
        setup_requirements.append('sphinx')
    setuptools.setup(
        author="David Gidwani",
        author_email="david.gidwani@gmail.com",
        classifiers=[
            "Development Status :: 4 - Beta",
            "Intended Audience :: Developers",
            "License :: OSI Approved :: BSD License",
            "Operating System :: OS Independent",
            "Programming Language :: Python",
            "Programming Language :: Python :: 2",
            "Programming Language :: Python :: 2.7",
            "Programming Language :: Python :: 3",
            "Programming Language :: Python :: 3.3",
            "Programming Language :: Python :: 3.4",
            "Topic :: Software Development",
            "Topic :: Software Development :: Libraries :: Python Modules",
        ],
        description="Painless access to namespaced environment variables",
        download_url="https://github.com/darvid/biome/tarball/0.1",
        install_requires=install_requirements,
        keywords="conf config configuration environment",
        license="BSD",
        long_description=readme(),
        name="biome",
        package_dir={'': 'src'},
        packages=setuptools.find_packages('./src'),
        setup_requires=setup_requirements,
        tests_require=["pytest"],
        url="https://github.com/darvid/biome",
        use_scm_version=True,
    )
688839
def install_requirements(self, path, index=None):
        
        cmd = 'install -r {0}'.format(path)
        if index:

            cmd = 'install --index-url {0} -r {1}'.format(index, path)

        self.pip(cmd)
393300
def consolidate_dependencies(needs_ipython, child_program,
                             requirement_files, manual_dependencies):
    """"""
    # We get the logger here because it's not defined at module level
    logger = logging.getLogger('fades')

    if needs_ipython:
        logger.debug("Adding ipython dependency because --ipython was detected")
        ipython_dep = parsing.parse_manual(['ipython'])
    else:
        ipython_dep = {}

    if child_program:
        srcfile_deps = parsing.parse_srcfile(child_program)
        logger.debug("Dependencies from source file: %s", srcfile_deps)
        docstring_deps = parsing.parse_docstring(child_program)
        logger.debug("Dependencies from docstrings: %s", docstring_deps)
    else:
        srcfile_deps = {}
        docstring_deps = {}

    all_dependencies = [ipython_dep, srcfile_deps, docstring_deps]

    if requirement_files is not None:
        for rf_path in requirement_files:
            rf_deps = parsing.parse_reqfile(rf_path)
            logger.debug('Dependencies from requirements file %r: %s', rf_path, rf_deps)
            all_dependencies.append(rf_deps)

    manual_deps = parsing.parse_manual(manual_dependencies)
    logger.debug("Dependencies from parameters: %s", manual_deps)
    all_dependencies.append(manual_deps)

    # Merge dependencies
    indicated_deps = {}
    for dep in all_dependencies:
        for repo, info in dep.items():
            indicated_deps.setdefault(repo, set()).update(info)

    return indicated_deps
108990
def install_deps(pkgpath):
    
    if os.path.exists(os.path.join(pkgpath, "requirements.txt")):
        logger.debug("installing dependencies")
        click.secho("[*] Installing dependencies")
        pipargs = ["install", "--target", os.path.join(pkgpath, defs.DEPS_DIR), "--ignore-installed",
                   "-r", os.path.join(pkgpath, "requirements.txt")]
        logger.debug("running pip %s", pipargs)
        return subprocess.check_call([sys.executable, "-m", "pip"] + pipargs)
    return 0
401128
def get_install_requires():
    
    requirements = []
    for line in open('requirements.txt').readlines():
        # skip to next iteration if comment or empty line
        if line.startswith('#') or line == '' or line.startswith('http') or line.startswith('git'):
            continue
        # add line to requirements
        requirements.append(line)
    return requirements
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
452997
def projects_from_cli(args):
    """"""
    description = ('Determine if a set of project dependencies will work with '
                   'Python 3')
    parser = argparse.ArgumentParser(description=description)
    req_help = 'path(s) to a pip requirements file (e.g. requirements.txt)'
    parser.add_argument('--requirements', '-r', nargs='+', default=(),
                        help=req_help)
    meta_help = 'path(s) to a PEP 426 metadata file (e.g. PKG-INFO, pydist.json)'
    parser.add_argument('--metadata', '-m', nargs='+', default=(),
                        help=meta_help)
    parser.add_argument('--projects', '-p', nargs='+', default=(),
                        help='name(s) of projects to test for Python 3 support')
    parser.add_argument('--verbose', '-v', action='store_true',
                        help='verbose output (e.g. list compatibility overrides)')
    parsed = parser.parse_args(args)

    if not (parsed.requirements or parsed.metadata or parsed.projects):
        parser.error("Missing 'requirements', 'metadata', or 'projects'")

    projects = []
    if parsed.verbose:
        logging.getLogger('ciu').setLevel(logging.INFO)
    projects.extend(projects_.projects_from_requirements(parsed.requirements))
    metadata = []
    for metadata_path in parsed.metadata:
        with io.open(metadata_path) as file:
            metadata.append(file.read())
    projects.extend(projects_.projects_from_metadata(metadata))
    projects.extend(map(packaging.utils.canonicalize_name, parsed.projects))

    return projects
1173695
def get_requirements(cls):
        """"""
        try:
            with open("requirements.txt") as f:
                return tuple(parse_requirements(f.readlines()))
        except IOError as e:
            LOG.debug("Couldn't open requirements file: %s", e)
            return ()
157293
def get_requirements(
            self, install=True, extras=True, setup=False, tests=False):
        """"""
        requires = []
        if install:
            requires.extend(parse_requirements(
                self.keywords.get('install_requires', ()),
            ))
        if extras:
            for r in self.keywords.get('extras_require', {}).values():
                requires.extend(parse_requirements(r))
        if setup:
            requires.extend(parse_requirements(
                self.keywords.get('setup_requires', ()),
            ))
        if tests:
            requires.extend(parse_requirements(
                self.keywords.get('tests_require', ()),
            ))
        return requires
525239
def download_pip(env, requirements):
    """"""
    if config.installation_cache_folder() is None:
        raise EnvironmentSetupError("Local installation cache folder not "
            "defined but required for downloading a pip installation.")
    # Installation cache folder needs to be explicitly created for setuptools
    # to be able to copy its downloaded installation files into it. Seen using
    # Python 2.4.4 & setuptools 1.4.
    _create_installation_cache_folder_if_needed()
    try:
        env.execute(["-m", "easy_install", "--zip-ok", "--multi-version",
            "--always-copy", "--exclude-scripts", "--install-dir",
            config.installation_cache_folder()] + requirements)
        zip_eggs_in_folder(config.installation_cache_folder())
    except (KeyboardInterrupt, SystemExit):
        raise
    except Exception:
        raise EnvironmentSetupError("pip download failed.")