Try to find information about the installed package from pip.
        This should be wrapped in a try/except.

        :returns: information from pip about ``self.package_name``.
        :rtype: dict
767390
def _find_pip_info(self):
        
        res = {}
        dist = None
        dist_name = self.package_name.replace('_', '-')
        logger.debug('Checking for pip distribution named: %s', dist_name)
        for d in pip.get_installed_distributions():
            if d.project_name == dist_name:
                dist = d
        if dist is None:
            logger.debug('could not find dist matching package_name')
            return res
        logger.debug('found dist: %s', dist)
        self._pip_locations = [dist.location]
        ver, url = self._dist_version_url(dist)
        res['version'] = ver
        res['url'] = url
        # this is a bit of an ugly, lazy hack...
        req = pip.FrozenRequirement.from_dist(dist, [])
        logger.debug('pip FrozenRequirement: %s', req)
        res['requirement'] = str(req.req)
        return res
1070291
def as_dict(self):
        
        return {
            'pip_version': self._pip_version,
            'pip_url': self._pip_url,
            'pip_requirement': self._pip_requirement,
            'pkg_resources_version': self._pkg_resources_version,
            'pkg_resources_url': self._pkg_resources_url,
            'git_tag': self._git_tag,
            'git_commit': self._git_commit,
            'git_remotes': self._git_remotes,
            'git_is_dirty': self._git_is_dirty,
        }
571945
def checkInstalledPip(package, speak=True, speakSimilar=True):
    """"""
    packages = sorted([i.key for i in pip.get_installed_distributions()])
    installed = package in packages
    similar = None

    if not installed:
        similar = [pkg for pkg in packages if package in pkg]

    if speak:
        speakInstalledPackages(package, "pip", installed, similar, speakSimilar)

    return (installed, similar)
614343
def is_package_installed(self, package_name):
        """"""
        if not package_name:
            raise ValueError('package_name required.')

        installed = True
        try:
            Cmd.sh_e('{0} --query {1} --quiet'.format(self.rpm_path,
                                                      package_name))
        except InstallError:
            installed = False
        return installed
212441
def find_path_package(thepath):
    
    pname = find_path_package_name(thepath)
    if not pname:
        return None
    fromlist = b'' if six.PY2 else ''
    return __import__(pname, globals(), locals(), [fromlist])
465862
def find_pip(pip_version=None, python_version=None):
    
    pip_exe = "pip"

    try:
        context = create_context(pip_version, python_version)
    except BuildError as e:
        # fall back on system pip. Not ideal but at least it's something
        from rez.backport.shutilwhich import which

        pip_exe = which("pip")

        if pip_exe:
            print_warning(
                "pip rez package could not be found; system 'pip' command (%s) "
                "will be used instead." % pip_exe)
            context = None
        else:
            raise e

    return pip_exe, context
182429
def get_version(package_name, ignore_cache=False):
    
    if ignore_cache:
        with microcache.temporarily_disabled():
            found = helpers.regex_in_package_file(
                VERSION_SET_REGEX, '_version.py', package_name, return_match=True
            )
    else:
        found = helpers.regex_in_package_file(
            VERSION_SET_REGEX, '_version.py', package_name, return_match=True
        )
    if found is None:
        raise ProjectError('found {}, but __version__ is not defined')
    current_version = found['version']
    return current_version
1029577
def package_version(package_name: str) -> typing.Optional[str]:
    

    try:
        return pkg_resources.get_distribution(package_name).version
    except (pkg_resources.DistributionNotFound, AttributeError):
        return None
328596
def _info(self, args):
        '''
        
        '''
        if len(args) < 2:
            raise SPMInvocationError('A package must be specified')

        package = args[1]

        pkg_info = self._pkgdb_fun('info', package, self.db_conn)
        if pkg_info is None:
            raise SPMPackageError('package {0} not installed'.format(package))
        self.ui.status(self._get_info(pkg_info))
220183
def as_dict(self):
        
        return {
            'name': str(self),
            'modules': [m.as_dict() for m in self.modules],
            'packages': [p.as_dict() for p in self.packages]
        }
518062
def via_find_packages(self):  # type: () -> List[str]
        
        packages = []  # type: List[str]
        source = self.setup_py_source()
        if not source:
            return packages
        for row in source.split("\n"):
            if "find_packages" in row:
                logger.debug(row)
                if "find_packages()" in row:
                    packages = find_packages()
                else:
                    try:
                        value = row.split("(")[1].split(")")[0]
                        packages = find_packages(ast.literal_eval(value))
                        logger.debug(unicode(packages))
                    except:
                        logger.debug(source)
                        # raise

        return packages
1274128
def package_info(self, package, abspath=True):
        """"""
        return self._call_and_parse(['info', package, '--json'],
                                    abspath=abspath)
755387
def get_dependency_package(
        self, package_name: str
    ) -> "Package":  # type: ignore # noqa: F821
        
        self._validate_name(package_name)
        return self.build_dependencies.get(package_name)
940770
def version_info(self):
        

        # Retrive and show local version info
        package = pkg.get_distribution('git-up')
        local_version_str = package.version
        local_version = package.parsed_version

        print('GitUp version is: ' + colored('v' + local_version_str, 'green'))

        if not self.settings['updates.check']:
            return

        # Check for updates
        print('Checking for updates...', end='')

        try:
            # Get version information from the PyPI JSON API
            reader = codecs.getreader('utf-8')
            details = json.load(reader(urlopen(PYPI_URL)))
            online_version = details['info']['version']
        except (HTTPError, URLError, ValueError):
            recent = True  # To not disturb the user with HTTP/parsing errors
        else:
            recent = local_version >= pkg.parse_version(online_version)

        if not recent:
            # noinspection PyUnboundLocalVariable
            print(
                '\rRecent version is: '
                + colored('v' + online_version, color='yellow', attrs=['bold'])
            )
            print('Run \'pip install -U git-up\' to get the update.')
        else:
            # Clear the update line
            sys.stdout.write('\r' + ' ' * 80 + '\n')
1256937
def _get_version_info():
    
    if os.environ.get('VERSIONCHECK_DEBUG', '') != 'true':
        for lname in ['versionfinder', 'pip', 'git']:
            l = logging.getLogger(lname)
            l.setLevel(logging.CRITICAL)
            l.propagate = True
    try:
        vinfo = find_version('awslimitchecker')
        dirty = ''
        if vinfo.git_is_dirty:
            dirty = '*'
        tag = vinfo.git_tag
        if tag is not None:
            tag += dirty
        commit = vinfo.git_commit
        if commit is not None:
            if len(commit) > 7:
                commit = commit[:8]
            commit += dirty
        return AWSLimitCheckerVersion(
            vinfo.version,
            vinfo.url,
            tag=tag,
            commit=commit
        )
    except Exception:
        logger.exception("Error checking installed version; this installation "
                         "may not be in compliance with the AGPLv3 license:")
    # fall back to returning just the hard-coded release information
    return AWSLimitCheckerVersion(_VERSION, _PROJECT_URL)
994803
def determine_extra_packages(self, packages):
        

        args = [
            "pip",
            "freeze",
        ]
        installed = subprocess.check_output(args, universal_newlines=True)

        installed_list = set()
        lines = installed.strip().split('\n')
        for (package, version) in self._parse_requirements(lines):
            installed_list.add(package)

        package_list = set()
        for (package, version) in self._parse_requirements(packages.readlines()):
            package_list.add(package)

        removal_list = installed_list - package_list
        return tuple(removal_list)
467441
def get_version(package):
    
    init_py = readfile(os.path.join(package, '__init__.py'))
    return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)