Make sure the package version in setuptools matches what we expect it to be
19091
def check_version(component, expected_version):
    """"""

    comp = comp_names[component]

    compath = os.path.realpath(os.path.abspath(comp.path))
    sys.path.insert(0, compath)

    import version

    if version.version != expected_version:
        raise EnvironmentError("Version mismatch during release, expected={}, found={}".format(expected_version, version.version))
745919
def setuptools_entry(dist, keyword, value):
    """"""
    # If 'use_katversion' is False, ignore the rest
    if not value:
        return
    # Enforce the version obtained by katversion, overriding user setting
    version = get_version()
    if dist.metadata.version is not None:
        s = "Ignoring explicit version='{0}' in setup.py, using '{1}' instead"
        warnings.warn(s.format(dist.metadata.version, version))
    dist.metadata.version = version
    # Extend build_py command to bake version string into installed package
    ExistingCustomBuildPy = dist.cmdclass.get('build_py', object)
    class KatVersionBuildPy(AddVersionToInitBuildPy, ExistingCustomBuildPy):
        """First perform existing build_py and then bake in version string."""
    dist.cmdclass['build_py'] = KatVersionBuildPy
    # Extend sdist command to bake version string into source package
    ExistingCustomSdist = dist.cmdclass.get('sdist', object)
    class KatVersionSdist(AddVersionToInitSdist, ExistingCustomSdist):
        """First perform existing sdist and then bake in version string."""
    dist.cmdclass['sdist'] = KatVersionSdist
150227
function compareVersions(installed, required) {

	var a = installed.split('.');
	var b = required.split('.');

	for (var i = 0; i < a.length; ++i) {
		a[i] = Number(a[i]);
	}
	for (var i = 0; i < b.length; ++i) {
		b[i] = Number(b[i]);
	}
	if (a.length == 2) {
		a[2] = 0;
	}

	if (a[0] > b[0]) return true;
	if (a[0] < b[0]) return false;

	if (a[1] > b[1]) return true;
	if (a[1] < b[1]) return false;

	if (a[2] > b[2]) return true;
	if (a[2] < b[2]) return false;

	return true;
}
996891
def get_version():
    """"""
    pkg_dir = get_package_dir()
    with open(os.path.join(pkg_dir, 'nestcheck/_version.py')) as ver_file:
        string = ver_file.read()
    return string.strip().replace('__version__ = ', '').replace('\'', '')
632419
def prepare_files(self, finder, force_root_egg_info=False, bundle=False):
        """"""
        unnamed = list(self.unnamed_requirements)
        reqs = list(self.requirements.values())
        while reqs or unnamed:
            if unnamed:
                req_to_install = unnamed.pop(0)
            else:
                req_to_install = reqs.pop(0)
            req_version = None
            install = True
            best_installed = False
            if not self.ignore_installed and not req_to_install.editable:
                req_to_install.check_if_exists()
                if req_to_install.satisfied_by:
                    if self.upgrade:
                        if not self.force_reinstall:
                            try:
                                url, req_version = finder.find_requirement(
                                    req_to_install, self.upgrade)
                            except BestVersionAlreadyInstalled:
                                best_installed = True
                                install = False
                            else:
                                # Avoid the need to call find_requirement again
                                req_to_install.url = url.url

                        if not best_installed:
                            req_to_install.conflicts_with = req_to_install.satisfied_by
                            req_to_install.satisfied_by = None
                    else:
                        install = False
                if req_to_install.satisfied_by:
                    if best_installed:
                        logger.notify('Requirement already up-to-date: %s'
                                      % req_to_install)
                    else:
                        logger.notify('Requirement already satisfied '
                                      '(use --upgrade to upgrade): %s'
                                      % req_to_install)
            if req_to_install.editable:
                logger.notify('Obtaining %s' % req_to_install)
            elif install:
                if req_to_install.url and req_to_install.url.lower().startswith('file:'):
                    logger.notify('Unpacking %s' % display_path(url_to_path(req_to_install.url)))
                else:
                    logger.notify('Downloading/unpacking %s' % req_to_install)
            logger.indent += 2
            try:
                is_bundle = False
                if req_to_install.editable:
                    if req_to_install.source_dir is None:
                        location = req_to_install.build_location(self.src_dir)
                        req_to_install.source_dir = location
                    else:
                        location = req_to_install.source_dir
                    if not os.path.exists(self.build_dir):
                        _make_build_dir(self.build_dir)
                    req_to_install.update_editable(not self.is_download)
                    if self.is_download:
                        req_to_install.run_egg_info()
                        req_to_install.archive(self.download_dir)
                    else:
                        req_to_install.run_egg_info()
                elif install:
                    ##@@ if filesystem packages are not marked
                    ##editable in a req, a non deterministic error
                    ##occurs when the script attempts to unpack the
                    ##build directory

                    location = req_to_install.build_location(self.build_dir, not self.is_download)
                    ## FIXME: is the existance of the checkout good enough to use it?  I don't think so.
                    unpack = True
                    if not os.path.exists(os.path.join(location, 'setup.py')):
                        ## FIXME: this won't upgrade when there's an existing package unpacked in `location`
                        if req_to_install.url is None:
                            url, req_version = finder.find_requirement(req_to_install, upgrade=self.upgrade)
                        else:
                            ## FIXME: should req_to_install.url already be a link?
                            url = Link(req_to_install.url)
                            assert url
                        if url:
                            try:
                                self.unpack_url(req_to_install, req_version, url, location, self.is_download)
                            except HTTPError:
                                e = sys.exc_info()[1]
                                logger.fatal('Could not install requirement %s because of error %s'
                                             % (req_to_install, e))
                                raise InstallationError(
                                    'Could not install requirement %s because of HTTP error %s for URL %s'
                                    % (req_to_install, e, url))
                        else:
                            unpack = False
                    if unpack:
                        is_bundle = req_to_install.is_bundle
                        url = None
                        if is_bundle:
                            req_to_install.move_bundle_files(self.build_dir, self.src_dir)
                            for subreq in req_to_install.bundle_requirements():
                                reqs.append(subreq)
                                self.add_requirement(subreq)
                        elif self.is_download:
                            req_to_install.source_dir = location
                            if url and url.scheme in vcs.all_schemes:
                                req_to_install.run_egg_info()
                                req_to_install.archive(self.download_dir)
                        else:
                            req_to_install.source_dir = location
                            req_to_install.run_egg_info()
                            if force_root_egg_info:
                                # We need to run this to make sure that the .egg-info/
                                # directory is created for packing in the bundle
                                req_to_install.run_egg_info(force_root_egg_info=True)
                            req_to_install.assert_source_matches_version()
                            #@@ sketchy way of identifying packages not grabbed from an index
                            if bundle and req_to_install.url:
                                self.copy_to_build_dir(req_to_install)
                                install = False
                        # req_to_install.req is only avail after unpack for URL pkgs
                        # repeat check_if_exists to uninstall-on-upgrade (#14)
                        req_to_install.check_if_exists()
                        if req_to_install.satisfied_by:
                            if self.upgrade or self.ignore_installed:
                                req_to_install.conflicts_with = req_to_install.satisfied_by
                                req_to_install.satisfied_by = None
                            else:
                                install = False
                if not is_bundle and not self.is_download:
                    ## FIXME: shouldn't be globally added:
                    finder.add_dependency_links(req_to_install.dependency_links)
                    if (req_to_install.extras):
                        logger.notify("Installing extra requirements: %r" % ','.join(req_to_install.extras))
                    if not self.ignore_dependencies:
                        for req in req_to_install.requirements(req_to_install.extras):
                            try:
                                name = pkg_resources.Requirement.parse(req).project_name
                            except ValueError:
                                e = sys.exc_info()[1]
                                ## FIXME: proper warning
                                logger.error('Invalid requirement: %r (%s) in requirement %s' % (req, e, req_to_install))
                                continue
                            if self.has_requirement(name):
                                ## FIXME: check for conflict
                                continue
                            subreq = InstallRequirement(req, req_to_install)
                            reqs.append(subreq)
                            self.add_requirement(subreq)
                    if req_to_install.name not in self.requirements:
                        self.requirements[req_to_install.name] = req_to_install
                else:
                    self.reqs_to_cleanup.append(req_to_install)
                if install:
                    self.successfully_downloaded.append(req_to_install)
                    if bundle and (req_to_install.url and req_to_install.url.startswith('file:///')):
                        self.copy_to_build_dir(req_to_install)
            finally:
                logger.indent -= 2
218689
function getUnsatisfiedDeps(deps, versions, options) {
	const ownDependencies = getOwnDependencies(options);

	return deps.filter(dep => {
		const required = versions[dep];

		if (required && !semver.validRange(required)) {
			throw new MrmError(
				`Invalid npm version: ${required}. Use proper semver range syntax.`
			);
		}

		const installed = getInstalledVersion(dep);

		// Package isn’t installed yet
		if (!installed) {
			return true;
		}

		// Module is installed but not in package.json dependencies
		if (!ownDependencies[dep]) {
			return true;
		}

		// No required version specified
		if (!required) {
			// Install if the pacakge isn’t installed
			return !installed;
		}

		// Install if installed version doesn't satisfy range
		return !semver.satisfies(installed, required);
	});
}
214447
def _check_apt_get():
    """"""
    check = False
    if 'TESTING' not in os.environ:
        result = exec_command(['dpkg', '-l', 'apio'])
        if result and result.get('returncode') == 0:
            match = re.findall('rc\s+apio', result.get('out')) + \
                    re.findall('ii\s+apio', result.get('out'))
            check = len(match) > 0
    return check
1358101
def cmd_version(unused_conf):
    """"""
    import pkg_resources
    print('This is {} version {}, imported from {}'
          .format(__oneliner__, __version__, __file__))
    if len(Plugin.builders) > 0:
        print('setuptools registered builders:')
    for entry_point in pkg_resources.iter_entry_points('yabt.builders'):
        print('  {0.module_name}.{0.name} (dist {0.dist})'.format(entry_point))
213350
def parse_setup() -> Tuple[PackagesType, PackagesType, Set[str], Set[str]]:
    """"""
    essential_packages: PackagesType = {}
    test_packages: PackagesType = {}
    essential_duplicates: Set[str] = set()
    test_duplicates: Set[str] = set()

    with open('setup.py') as setup_file:
        contents = setup_file.read()

    # Parse out essential packages.
    package_string = re.search(r"""install_requires=\[[\s\n]*['"](.*?)['"],?[\s\n]*\]""",
                               contents, re.DOTALL).groups()[0].strip()
    for package in re.split(r"""['"],[\s\n]+['"]""", package_string):
        module, version = parse_package(package)
        if module in essential_packages:
            essential_duplicates.add(module)
        else:
            essential_packages[module] = version

    # Parse packages only needed for testing.
    package_string = re.search(r"""tests_require=\[[\s\n]*['"](.*?)['"],?[\s\n]*\]""",
                               contents, re.DOTALL).groups()[0].strip()
    for package in re.split(r"""['"],[\s\n]+['"]""", package_string):
        module, version = parse_package(package)
        if module in test_packages:
            test_duplicates.add(module)
        else:
            test_packages[module] = version

    return essential_packages, test_packages, essential_duplicates, test_duplicates
257102
def _prepare_version(self):
        """"""
        if config.VERSION not in self._config:
            self._config[config.VERSION] = __version__
314687
def get_fw_version():
    
    version = 'unknown'
    try:
        pkg = require(get_fw_name())[0]
    except DistributionNotFound:
        # Icetea is not installed. try to read version string from setup.py
        try:
            setup_path = os.path.abspath(os.path.dirname(__file__)+'/../..')
            with open(os.path.join(setup_path, 'setup.py')) as setup_file:
                lines = setup_file.readlines()
                for line in lines:
                    match = re.search(r"VERSION = \"([\S]{5,})\"", line)
                    if match:
                        version = match.group(1)
                        break
        except Exception:  # pylint: disable=broad-except
            pass
    else:
        version = "-rc".join(pkg.version.split("rc"))
    return version
1321429
function getPackageVersion() {
  var packageJson = path.join(process.cwd(), 'package.json'),
    version;
  try {
    version = require(packageJson).version;
  } catch (unused) {
    throw new Error('Could not load package.json, please make sure it exists');
  }
  if (!semver.valid(version)) {
    throw new Error('Invalid version number found in package.json, please make sure it is valid');
  }

  return [ semver.major(version), semver.minor(version), semver.patch(version) ].join('.');
}
1170453
function checkPkg(pkgDir, scopes) {
  var errors;
  try {
    var config = {packageDir: pkgDir};
    if (scopes) {
      config.scopeList = scopes;
    }
    var checked = checkDeps.sync(config);
    if (checked.error.length) {
      errors = checked.error;
    }
  } finally {
    // eslint-disable-next-line no-unsafe-finally
    return errors;
  }
}
290829
def install_build_requires(pkg_targets):
    """"""

    def pip_install(pkg_name, pkg_vers=None):
        pkg_name_version = '%s==%s' % (pkg_name, pkg_vers) if pkg_vers else pkg_name
        print '[WARNING] %s not found, attempting to install using a raw "pip install" call!' % pkg_name_version
        subprocess.Popen('pip install %s' % pkg_name_version, shell=True).communicate()

    def get_pkg_info(pkg):
        """Get package name and version given a build_requires element"""
        pkg_name, pkg_vers = None, None
        if '==' in pkg:
            pkg_name, pkg_vers = pkg.split('==')
        else:
            pkg_name = pkg.replace('>', '').replace('<', '').split('=')[0]
        return pkg_name, pkg_vers

    for pkg in pkg_targets:
        pkg_name, pkg_vers = get_pkg_info(pkg)
        try:
            pkg_name_version = '%s==%s' % (pkg_name, pkg_vers) if pkg_vers else pkg_name
            if pkg_vers:
                version = getattr(importlib.import_module(pkg_name), '__version__')
                if version != pkg_vers:
                    pip_install(pkg_name, pkg_vers)
            else:
                importlib.import_module(pkg_name)
        except ImportError:
            pip_install(pkg_name, pkg_vers)
1360628
def _version_checker(module, minver):
    
    # We could use LooseVersion, but distutils imports imp which is deprecated
    version_regexp = r'[a-z]?((?:\d|\.)+\d+)(?:\.dev[0-9]+)?'
    version_tags = re.match(version_regexp, module.__version__)
    if not version_tags:
        return False
    version_tags = version_tags.group(1).split(".")
    version_tags = tuple(int(x) for x in version_tags)
    return version_tags >= minver
561896
def upgradestep(upgrade_product, version):
    
    def wrap_func(fn):
        def wrap_func_args(context, *args):
            p = getToolByName(context, 'portal_quickinstaller').get(upgrade_product)
            setattr(p, 'installedversion', version)
            return fn(context, *args)
        return wrap_func_args
    return wrap_func
579142
def detect!
      installed = {}
      installed_versions.each do |path, version|
        installed[path] = version
        return path if ENV['CLIVER_NO_VERIFY']
        return path if requirement_satisfied_by?(version)
        strict?
      end

      # dependency not met. raise the appropriate error.
      raise_not_found! if installed.empty?
      raise_version_mismatch!(installed)
    end