Find missing dependencies of a Python package.

        :param requirement: A :class:`.Requirement` object.
        :returns: A list of strings with system package names.
9397
def find_missing_dependencies(self, requirement):
        
        known_dependencies = self.find_known_dependencies(requirement)
        if known_dependencies:
            installed_packages = self.find_installed_packages()
            logger.debug("Checking for missing dependencies of %s ..", requirement.name)
            missing_dependencies = sorted(set(known_dependencies).difference(installed_packages))
            if missing_dependencies:
                logger.debug("Found %s: %s",
                             pluralize(len(missing_dependencies), "missing dependency", "missing dependencies"),
                             concatenate(missing_dependencies))
            else:
                logger.info("All known dependencies are already installed.")
            return missing_dependencies
1257797
def is_dependant(package, project_name):
    """"""
    for requirement in package.requires():
        # perform case-insensitive matching
        if requirement.project_name.lower() == project_name.lower():
            return True
    return False
1029029
def verify_packages_installed(self, package_names):
        
        if not package_names:
            raise ValueError('package_names required.')

        missing_packages = []
        for package_name in package_names:
            if not self.is_package_installed(package_name):
                missing_packages.append(package_name)

        if missing_packages:
            comma_packages = ', '.join(missing_packages)
            message = '''
Required RPM not installed: [{0}].
Install the RPM package.
'''.format(comma_packages)
            raise InstallError(message)
1291215
def dependencies(dist, recursive=False, info=False):
    """"""

    def case_sorted(items):
        """Return unique list sorted in case-insensitive order."""
        return sorted(set(items), key=lambda i: i.lower())

    def requires(distribution):
        """Return the requirements for a distribution."""
        if recursive:
            req = set(pkg_resources.require(distribution.project_name))
            req.remove(distribution)
            return {r.as_requirement() for r in req}
        return distribution.requires()

    def modifier(distribution):
        """Return project's name or full requirement string."""
        return str(distribution) if info else distribution.project_name

    return case_sorted(modifier(r) for r in requires(dist))
1115198
def get_dependencies(requirement, sources):
    
    getters = [
        _get_dependencies_from_cache,
        _cached(_get_dependencies_from_json, sources=sources),
        _cached(_get_dependencies_from_pip, sources=sources),
    ]
    ireq = requirement.as_ireq()
    last_exc = None
    for getter in getters:
        try:
            result = getter(ireq)
        except Exception as e:
            last_exc = sys.exc_info()
            continue
        if result is not None:
            deps, pyreq = result
            reqs = [requirementslib.Requirement.from_line(d) for d in deps]
            return reqs, pyreq
    if last_exc:
        six.reraise(*last_exc)
    raise RuntimeError("failed to get dependencies for {}".format(
        requirement.as_line(),
    ))
427868
def get_table_dependencies(self, package="reports"):
        
        dependencies = easydev.get_dependencies(package)
        # TODO: Could re-use new method in HTMLTable for adding href
        # but needs some extra work in the add_href method.
        names = [x.project_name for x in dependencies]
        versions = [x.version for x in dependencies]
        links = ["""https://pypi.python.org/pypi/%s""" % p for p in names]
        df = pd.DataFrame({
            'package': ["""<a href="%s">%s</a>""" % (links[i], p)
                for i, p in enumerate(names)],
            'version': versions})
        table = HTMLTable(df, name="dependencies", escape=False)
        table.sort('package')
        return table
46565
def read_dependencies(filename):
    
    dependencies = []
    filepath = os.path.join('requirements', filename)
    with open(filepath, 'r') as stream:
        for line in stream:
            package = line.strip().split('#')[0].strip()
            if package and package.split(' ')[0] != '-r':
                dependencies.append(package)
    return dependencies
241129
def check_dependencies():
    
    print("Checking required dependencies")
    for dep, msg in [(["git", "--version"], "Git (http://git-scm.com/)"),
                     (["wget", "--version"], "wget"),
                     (["bzip2", "-h"], "bzip2")]:
        try:
            p = subprocess.Popen(dep, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
            out, code = p.communicate()
        except OSError:
            out = "Executable not found"
            code = 127
        if code == 127:
            raise OSError("bcbio-nextgen installer requires %s\n%s" % (msg, out))
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
1355510
def get_dependants(cls, dist):
        """"""
        for package in cls.installed_distributions:
            for requirement_package in package.requires():
                requirement_name = requirement_package.project_name
                # perform case-insensitive matching
                if requirement_name.lower() == dist.lower():
                    yield package
200170
def _get_dependencies(self):
        
        #The only complication with the whole process is that we need to get the list of
        #dependencies for the current module. For full lib, we compile *all* the files in
        #the directory, otherwise only those that are explicitly required.
        from os import path
        modules = self.module.search_dependencies()
        result = {}
        for module in modules:
            self.module.parent.load_dependency(module, True, True, False)
            
        for modname, module in list(self.module.parent.modules.items()):
            pathkey = path.dirname(module.filepath).lower()
            if pathkey not in result:
                result[pathkey] = path.dirname(module.filepath)

        return result
293329
def check_pypi_exists(dependencies):
    """"""
    for dependency in dependencies.get('pypi', []):
        logger.debug("Checking if %r exists in PyPI", dependency)
        try:
            exists = _pypi_head_package(dependency)
        except Exception as error:
            logger.error("Error checking %s in PyPI: %r", dependency, error)
            raise FadesError("Could not check if dependency exists in PyPI")
        else:
            if not exists:
                logger.error("%s doesn't exists in PyPI.", dependency)
                return False
    return True
1362838
def _get_dependencies_from_cache(ireq):
    
    if os.environ.get("PASSA_IGNORE_LOCAL_CACHE"):
        return
    if ireq.editable:
        return
    try:
        deps = DEPENDENCY_CACHE[ireq]
        pyrq = REQUIRES_PYTHON_CACHE[ireq]
    except KeyError:
        return

    # Preserving sanity: Run through the cache and make sure every entry if
    # valid. If this fails, something is wrong with the cache. Drop it.
    try:
        packaging.specifiers.SpecifierSet(pyrq)
        ireq_name = packaging.utils.canonicalize_name(ireq.name)
        if any(_is_cache_broken(line, ireq_name) for line in deps):
            broken = True
        else:
            broken = False
    except Exception:
        broken = True

    if broken:
        print("dropping broken cache for {0}".format(ireq.name))
        del DEPENDENCY_CACHE[ireq]
        del REQUIRES_PYTHON_CACHE[ireq]
        return

    return deps, pyrq
666634
def check_required_keys(self, required_keys):
        ''''''
        h = self._contents_hash
        for key in required_keys:
            if key not in h:
                raise InsufficientGraftMPackageException("Package missing key %s" % key)
540262
def check_dependencies(req, indent=1, history=None):
    
    # keep a history to avoid infinite loops
    if history is None:
        history = set()
    if req in history:
        return
    history.add(req)
    d = pkg_resources.get_distribution(req)
    extras = parse_extras(req)
    if indent == 1:
        print_package(req, 0)
    for r in d.requires(extras=extras):
        print_package(r, indent)
        check_dependencies(r, indent + 1, history)
775271
def check_pypi_updates(dependencies):
    """"""
    dependencies_up_to_date = []
    for dependency in dependencies.get('pypi', []):
        # get latest version from PyPI api
        try:
            latest_version = get_latest_version_number(dependency.project_name)
        except Exception as error:
            logger.warning("--check-updates command will be aborted. Error: %s", error)
            return dependencies
        # get required version
        required_version = None
        if dependency.specs:
            _, required_version = dependency.specs[0]

        if required_version:
            dependencies_up_to_date.append(dependency)
            if latest_version > required_version:
                logger.info("There is a new version of %s: %s",
                            dependency.project_name, latest_version)
            elif latest_version < required_version:
                logger.warning("The requested version for %s is greater "
                               "than latest found in PyPI: %s",
                               dependency.project_name, latest_version)
            else:
                logger.info("The requested version for %s is the latest one in PyPI: %s",
                            dependency.project_name, latest_version)
        else:
            project_name_plus = "{}=={}".format(dependency.project_name, latest_version)
            dependencies_up_to_date.append(pkg_resources.Requirement.parse(project_name_plus))
            logger.info("The latest version of %r is %s and will use it.",
                        dependency.project_name, latest_version)

    dependencies["pypi"] = dependencies_up_to_date
    return dependencies
523031
def check_other(self):
        
        if self.reqs:
            self.stdout.write(self.style.ERROR("\nOnly pypi and github based requirements are supported:"))
            for name, req in self.reqs.items():
                if "dist" in req:
                    pkg_info = "{dist.project_name} {dist.version}".format(dist=req["dist"])
                elif "url" in req:
                    pkg_info = "{url}".format(url=req["url"])
                else:
                    pkg_info = "unknown package"
                self.stdout.write(self.style.BOLD("{pkg_info:40} is not a pypi or github requirement".format(pkg_info=pkg_info)))