Return an InstallationCandidate or None
547360
def _link_package_versions(self, link, search, ignore_compatibility=True):
        # type: (Link, Search, bool) -> Optional[InstallationCandidate]
        """"""
        version = None
        if link.egg_fragment:
            egg_info = link.egg_fragment
            ext = link.ext
        else:
            egg_info, ext = link.splitext()
            if not ext:
                self._log_skipped_link(link, 'not a file')
                return None
            if ext not in SUPPORTED_EXTENSIONS:
                self._log_skipped_link(
                    link, 'unsupported archive format: %s' % ext,
                )
                return None
            if "binary" not in search.formats and ext == WHEEL_EXTENSION and not ignore_compatibility:
                self._log_skipped_link(
                    link, 'No binaries permitted for %s' % search.supplied,
                )
                return None
            if "macosx10" in link.path and ext == '.zip' and not ignore_compatibility:
                self._log_skipped_link(link, 'macosx10 one')
                return None
            if ext == WHEEL_EXTENSION:
                try:
                    wheel = Wheel(link.filename)
                except InvalidWheelFilename:
                    self._log_skipped_link(link, 'invalid wheel filename')
                    return None
                if canonicalize_name(wheel.name) != search.canonical:
                    self._log_skipped_link(
                        link, 'wrong project name (not %s)' % search.supplied)
                    return None

                if not wheel.supported(self.valid_tags) and not ignore_compatibility:
                    self._log_skipped_link(
                        link, 'it is not compatible with this Python')
                    return None

                version = wheel.version

        # This should be up by the search.ok_binary check, but see issue 2700.
        if "source" not in search.formats and ext != WHEEL_EXTENSION:
            self._log_skipped_link(
                link, 'No sources permitted for %s' % search.supplied,
            )
            return None

        if not version:
            version = _egg_info_matches(egg_info, search.canonical)
        if not version:
            self._log_skipped_link(
                link, 'Missing project version for %s' % search.supplied)
            return None

        match = self._py_version_re.search(version)
        if match:
            version = version[:match.start()]
            py_version = match.group(1)
            if py_version != sys.version[:3]:
                self._log_skipped_link(
                    link, 'Python version is incorrect')
                return None
        try:
            support_this_python = check_requires_python(link.requires_python)
        except specifiers.InvalidSpecifier:
            logger.debug("Package %s has an invalid Requires-Python entry: %s",
                         link.filename, link.requires_python)
            support_this_python = True

        if not support_this_python and not ignore_compatibility:
            logger.debug("The package %s is incompatible with the python "
                         "version in use. Acceptable python versions are: %s",
                         link, link.requires_python)
            return None
        logger.debug('Found link %s, version: %s', link, version)

        return InstallationCandidate(search.supplied, version, link, link.requires_python)
1138365
def freeze():
    '''
    
    '''
    installations = {}
    for dist in get_installed_distributions():
        req = pip.FrozenRequirement.from_dist(dist, [], find_tags=False)
        installations[req.name] = req

    return [str(installation).rstrip() for installation in
        sorted(installations.values(), key=lambda x: x.name.lower())]
573572
def which_bin(exes):
    '''
    
    '''
    if not isinstance(exes, Iterable):
        return None
    for exe in exes:
        path = which(exe)
        if not path:
            continue
        return path
    return None
14458
def getInstalled():
    
    installed = _find_installed()
    return [os.path.basename(p.pathname)[3:] for p in installed]
117807
def upgrade_available(name):
    '''
    
    '''
    version_num = None
    cmd = '/opt/csw/bin/pkgutil -c --parse --single {0}'.format(
        name)
    out = __salt__['cmd.run_stdout'](cmd)
    if out:
        version_num = out.split()[2].strip()
    if version_num:
        if version_num == "SAME":
            return ''
        else:
            return version_num
    return ''
276977
def get_install_requires():
    """"""
    install_requires = get_requirements('requirements.txt')
    if 'bdist_wheel' not in sys.argv:
        if sys.platform == 'win32':
            install_requires.append('colorama')
    return sorted(install_requires)
1369171
def installFuncVersionedLib(target, source, env):
    """"""
    try:
        install = env['INSTALLVERSIONEDLIB']
    except KeyError:
        raise SCons.Errors.UserError('Missing INSTALLVERSIONEDLIB construction variable.')

    assert len(target)==len(source), \
           "Installing source %s into target %s: target and source lists must have same length."%(list(map(str, source)), list(map(str, target)))
    for t,s in zip(target,source):
        if hasattr(t.attributes, 'shlibname'):
            tpath = os.path.join(t.get_dir(), t.attributes.shlibname)
        else:
            tpath = t.get_path()
        if install(tpath,s.get_path(),env):
            return 1

    return 0
523419
def _ensure_systemd(version):
    '''
    
    '''
    try:
        version = int(version)
    except ValueError:
        raise CommandExecutionError('Invalid version \'{0}\''.format(version))

    try:
        installed = _sd_version()
        log.debug('nspawn: detected systemd %s', installed)
    except (IndexError, ValueError):
        raise CommandExecutionError('nspawn: Unable to get systemd version')

    if installed < version:
        raise CommandExecutionError(
            'This function requires systemd >= {0} '
            '(Detected version: {1}).'.format(version, installed)
        )
855038
def get_os_dist_info():
    

    distribution = platform.dist()
    dist_name = distribution[0].lower()
    dist_version_str = distribution[1]
    if dist_name and dist_version_str:
        return dist_name, dist_version_str
    else:
        return None, None
926001
def check_install(software='singularity', quiet=True):
    '''
    '''

    cmd = [software, '--version']
    found = False

    try:
        version = run_command(cmd, quiet=True)
    except: # FileNotFoundError
        return found

    if version is not None:
        if version['return_code'] == 0:
            found = True

        if quiet is False:
            version = version['message']
            bot.info("Found %s version %s" % (software.upper(), version))

    return found
191955
def _get_abstract_dist_for(self, req):
        # type: (InstallRequirement) -> DistAbstraction
        
        assert self.require_hashes is not None, (
            "require_hashes should have been set in Resolver.resolve()"
        )

        if req.editable:
            return self.preparer.prepare_editable_requirement(
                req, self.require_hashes, self.use_user_site, self.finder,
            )

        # satisfied_by is only evaluated by calling _check_skip_installed,
        # so it must be None here.
        assert req.satisfied_by is None
        skip_reason = self._check_skip_installed(req)

        if req.satisfied_by:
            return self.preparer.prepare_installed_requirement(
                req, self.require_hashes, skip_reason
            )

        upgrade_allowed = self._is_upgrade_allowed(req)
        abstract_dist = self.preparer.prepare_linked_requirement(
            req, self.session, self.finder, upgrade_allowed,
            self.require_hashes
        )

        # NOTE
        # The following portion is for determining if a certain package is
        # going to be re-installed/upgraded or not and reporting to the user.
        # This should probably get cleaned up in a future refactor.

        # req.req is only avail after unpack for URL
        # pkgs repeat check_if_exists to uninstall-on-upgrade
        # (#14)
        if not self.ignore_installed:
            req.check_if_exists(self.use_user_site)

        if req.satisfied_by:
            should_modify = (
                self.upgrade_strategy != "to-satisfy-only" or
                self.force_reinstall or
                self.ignore_installed or
                req.link.scheme == 'file'
            )
            if should_modify:
                self._set_req_to_reinstall(req)
            else:
                logger.info(
                    'Requirement already satisfied (use --upgrade to upgrade):'
                    ' %s', req,
                )

        return abstract_dist
772998
def get_installed_version(dist_name, working_set=None):
    """"""
    # Create a requirement that we'll look for inside of setuptools.
    req = pkg_resources.Requirement.parse(dist_name)

    if working_set is None:
        # We want to avoid having this cached, so we need to construct a new
        # working set each time.
        working_set = pkg_resources.WorkingSet()

    # Get the installed distribution from our working set
    dist = working_set.find(req)

    # Check to see if we got an installed distribution or not, if we did
    # we want to return it's version.
    return dist.version if dist else None
77429
def check_need_install():
    
    md5_root, md5_dst = list(), list()
    need_install_flag = False
    for root, _, basename_list in os.walk(_ROOT):
        if os.path.basename(root) != "__pycache__":
            for basename in basename_list:
                src = os.path.join(root, basename)
                dst = os.path.join(root.replace(_ROOT, _DST), basename)
                if os.path.exists(dst):
                    if md5_of_file(src) != md5_of_file(dst):
                        return True
                else:
                    return True
    return need_install_flag
1050510
def get_installer_desc(build_context, target) -> tuple:
    """"""
    workspace_dir = build_context.get_workspace('CustomInstaller', target.name)
    target_name = split_name(target.name)
    script_name = basename(target.props.script)
    package_tarball = '{}.tar.gz'.format(join(workspace_dir, target_name))
    return target_name, script_name, package_tarball
1100814
def install(self, version, upgrade=False):
        
        print("Installing version: " + colorize("info", version))

        self.make_lib(version)
        self.make_bin()
        self.make_env()
        self.update_path()

        return 0
774275
def apps_installation_requirements(self, id, **kwargs):
        ""
        api_path = "/api/v2/apps/installations/{id}/requirements.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
658678
def get_installed_version(vcs):
    
    version_path = _get_version_path(vcs)
    if not os.path.exists(version_path):
        raise VersionNotInstalledError
    with open(version_path, 'r') as f:
        return f.read().strip()