>>> fetch_package_version('sentry')
163266
def fetch_package_version(dist_name):
    
    try:
        # Importing pkg_resources can be slow, so only import it
        # if we need it.
        import pkg_resources
    except ImportError:
        # pkg_resource is not available on Google App Engine
        raise NotImplementedError('pkg_resources is not available '
                                  'on this Python install')
    dist = pkg_resources.get_distribution(dist_name)
    return dist.version
698012
def get_package_version(self, package):
        # type: (str) -> Tuple[int, ...]
        
        name = "{0}{1}".format(
            pelix.remote.PROP_ENDPOINT_PACKAGE_VERSION_, package
        )
        try:
            # Get the version string
            version = self.__properties[name]

            # Split dots ('.')
            return tuple(version.split("."))
        except KeyError:
            # No version
            return 0, 0, 0
514234
def version(self):
        
        if self.find:
            return self.meta.sp + split_package(self.find)[1]
        return ""
483862
def get_package_version(module_obj, value):
    
    for key in ['version', '__version__']:
        if hasattr(module_obj, key):
            return getattr(module_obj, key)
    parts = value.split('.')
    for index, part in enumerate(parts):
        try:
            return pkg_resources.get_distribution(
                '.'.join(parts[0:index + 1])).version
        except (pkg_resources.DistributionNotFound,
                pkg_resources.RequirementParseError):
            continue
1153571
def version(package, encoding='utf-8'):
    
    path = os.path.join(os.path.dirname(__file__), package, '__init__.py')
    with io.open(path, encoding=encoding) as fp:
        version_info = fp.read()
    version_match = re.search(r"""^__version__ = ['"]([^'"]*)['"]""",
                              version_info, re.M)
    if not version_match:
        raise RuntimeError("Unable to find version string.")
    return version_match.group(1)
738489
def get_upstream_version(package):
    
    import apt_pkg
    cache = apt_cache()
    try:
        pkg = cache[package]
    except Exception:
        # the package is unknown to the current apt cache.
        return None

    if not pkg.current_ver:
        # package is known, but no version is currently installed.
        return None

    return apt_pkg.upstream_version(pkg.current_ver.ver_str)
968857
def get_package_version(self):
        
        output = subprocess.check_output([
            '{}'.format(self.python),
            'setup.py',
            '--version',
        ]).decode()
        return output.rstrip()
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
1000992
def get_version():
    
    _globals = {}
    _locals = {}
    exec(
        compile(
            open(TOP + "/manta/version.py").read(), TOP + "/manta/version.py",
            'exec'), _globals, _locals)
    return _locals["__version__"]
367625
def get_version(self, dependency):
        """"""
        logger.debug("getting installed version for %s", dependency)
        stdout = helpers.logged_exec([self.pip_exe, "show", str(dependency)])
        version = [line for line in stdout if line.startswith('Version:')]
        if len(version) == 1:
            version = version[0].strip().split()[1]
            logger.debug("Installed version of %s is: %s", dependency, version)
            return version
        else:
            logger.error('Fades is having problems getting the installed version. '
                         'Run with -v or check the logs for details')
            return ''
452545
def find_version(
        package_name: str, version_module_name: str = '_version',
        version_variable_name: str = 'VERSION') -> str:
    """"""
    version_module = importlib.import_module(
        '{}.{}'.format(package_name.replace('-', '_'), version_module_name))
    return getattr(version_module, version_variable_name)
785277
def get_package_version():
    """"""
    base = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(base, 'policy', '__init__.py'),
              mode='rt',
              encoding='utf-8') as initf:
        for line in initf:
            m = version.match(line.strip())
            if not m:
                continue
            return m.groups()[0]
979521
def get_version():
    """"""
    contents = read_file(os.path.join('admirarchy', '__init__.py'))
    version = re.search('VERSION = \(([^)]+)\)', contents)
    version = version.group(1).replace(', ', '.').strip()
    return version
461423
def getversion(package):
    
    distribution = get_distribution(package)
    if distribution is None:
        raise RuntimeError("Can't find distribution {0}".format(package))
    repo_type = get_repo_type(distribution.location)
    if repo_type is None:
        return distribution.version

    return repo_type.get_version(distribution.location)
727499
async function _expectPackageVersion(args) {
  const packageVersion = require(
    path.resolve(__dirname, '../../package.json')
  ).version;
  await _expectSuccessMessage(args, `${packageVersion}\n`);
}
86420
def get_version():
    
    try:
        version_file = open(os.path.join(ROOT_DIR, 'mollie', 'api', 'version.py'), encoding='utf=8')
    except TypeError:
        # support python 2
        version_file = open(os.path.join(ROOT_DIR, 'mollie', 'api', 'version.py'))
    contents = version_file.read()
    match = re.search(r'VERSION = [\'"]([^\'"]+)', contents)
    if match:
        return match.group(1)
    else:
        raise RuntimeError("Can't determine package version")
766923
function discoverVersion() {
    // try to understand package name and current version
    // from package.json or bower.json
    let packageFile;
    let packageFileExtension;
    let packageType;
    let results = {
        name: '',
        currentVersion: ''
    };
    let possiblePackageFiles = ['package.json', 'bower.json', 'package.js'];

    for (possiblePackageFile of possiblePackageFiles) {
        if (fs.existsSync(possiblePackageFile)) {
            packageFile = possiblePackageFile;
            break;
        }
    }

    packageFileExtension = packageFile.substr(packageFile.lastIndexOf('.') + 1);

    if (packageFile) {
        let packageData;

        if (packageFileExtension === 'json') {
            packageData = jsonReader(packageFile);
        }
        if (packageFileExtension === 'js') {
            let tmpData = fs.readFileSync(packageFile).toString().split('\n');
            let nameFound = false;
            let versionFound = false;

            packageData = {};

            for (line of tmpData) {
                if (line.indexOf('name:') >= 0) {
                    nameFound = true;
                    packageData.name = line.split(' ').pop().replace(/'/g, '').replace(/,/g, '');
                }
                if (line.indexOf('version:') >= 0) {
                    versionFound = true;
                    packageData.version = line.split(' ').pop().replace(/'/g, '').replace(/,/g, '');
                }

                if (nameFound && versionFound) {
                    break;
                }
            }
        }

        debugLog('Reading packageFile for init:');
        debugLog('Discovered pacakge name: ' + packageData.name + ' - discovered package version ' + packageData.version);

        if (packageData.name) {
            results.name = packageData.name;
        }
        else {
            print('Can\'t discover package name automatically', 'msgWarning', 'spaced22');
        }

        if (packageData.version) {
            results.currentVersion = packageData.version;
        }
        else {
            print('Can\'t discover package\'s currentVersion automatically', 'msgWarning', 'spaced22');
        }
    }
    else {
        print('Can\'t discover package name and/or currentVersion automatically', 'msgWarning', 'spaced22');
        print('Please fill .versionFilesList.json with the missing informations', 'msgWarning', 'spaced22');
    }

    return results;
}