Load installed packages and export the version map.

    This function may be called multiple times, but the counters will
    be increased each time. Since Prometheus counters are never
    decreased, the aggregated results will not make sense.
543059
def LoadInstallations(counter):
    
    process = subprocess.Popen(["pip", "list", "--format=json"],
                               stdout=subprocess.PIPE)
    output, _ = process.communicate()
    installations = json.loads(output)
    for i in installations:
        counter.labels(i["name"], i["version"]).inc()
1192600
def densely_packed_versions
      if @densely_packed_versions.nil?
        @densely_packed_versions = DenselyPackedSet.new(versions.map{|pkg_version| pkg_version.version})
        Debug.log.debug { "Package Versions for '#{@name}' :" }
        versions.each do |v|
          Debug.log.debug { "    #{v.to_s(true)}" }
        end
      end
      @densely_packed_versions
    end
312529
def multiple_packaged_versions(package_name):
    
    dist_files = os.listdir('dist')
    versions = set()
    for filename in dist_files:
        version = funcy.re_find(r'{}-(.+).tar.gz'.format(package_name), filename)
        if version:
            versions.add(version)
    return len(versions) > 1
1348009
def snapshot(self, mode):
        '''
        
        '''
        self._init_env()

        self._save_cfg_packages(self._get_changed_cfg_pkgs(self._get_cfg_pkgs()))
        self._save_payload(*self._scan_payload())
70246
def _get_available_versions(self):
        '''
        
        '''
        solvables = self.zypper.nolock.xml.call('se', '-xv', self.name).getElementsByTagName('solvable')
        if not solvables:
            raise CommandExecutionError('No packages found matching \'{0}\''.format(self.name))

        return sorted(set([slv.getAttribute(self._attr_solvable_version)
                           for slv in solvables if slv.getAttribute(self._attr_solvable_version)]))
1315566
function installVersion(version) {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    if (!INSTALL_VERSIONS_CACHE[version]) return [3 /*break*/, 2];
                    return [4 /*yield*/, INSTALL_VERSIONS_CACHE[version]];
                case 1:
                    _a.sent();
                    return [2 /*return*/, false];
                case 2:
                    INSTALL_VERSIONS_CACHE[version] = _installVersion(version);
                    return [4 /*yield*/, INSTALL_VERSIONS_CACHE[version]];
                case 3:
                    _a.sent();
                    return [2 /*return*/, true];
            }
        });
    });
}
598370
def repository_data(self, repo):
        
        sum_pkgs, size, unsize, last_upd = 0, [], [], ""
        for line in (Utils().read_file(
                self.meta.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()):
            if line.startswith("PACKAGES.TXT;"):
                last_upd = line[14:].strip()
            if line.startswith("PACKAGE NAME:"):
                sum_pkgs += 1
            if line.startswith("PACKAGE SIZE (compressed):  "):
                size.append(line[28:-2].strip())
            if line.startswith("PACKAGE SIZE (uncompressed):  "):
                unsize.append(line[30:-2].strip())
        if repo in ["salix", "slackl"]:
            log = Utils().read_file(
                self.meta.log_path + "{0}/ChangeLog.txt".format(repo))
            last_upd = log.split("\n", 1)[0]
        return [sum_pkgs, size, unsize, last_upd]
290867
def installed_packages(self):
        
        packages = []
        CMDLINE = [sys.executable, "-mpip", "freeze"]
        try:
            for package in subprocess.check_output(CMDLINE) \
                    .decode('utf-8'). \
                    splitlines():
                for comparator in ["==", ">=", "<=", "<", ">"]:
                    if comparator in package:
                        # installed package names usually look like Pillow==2.8.1
                        # ignore others, like external packages that pip show
                        # won't understand
                        name = package.partition(comparator)[0]
                        packages.append(name)
        except RuntimeError as e:
            if logger.isEnabledFor(logging.DEBUG):
                logger.debug("Exception checking existing packages.")
                logger.debug("cmdline: %s", CMDLINE)
                ex_type, ex, tb = sys.exc_info()
                traceback.print_tb(tb)
                logger.debug()
        return packages
272815
def determine_packages_to_sync(self):
        
        # In case we don't find any changes we will stay on the currently
        # synced serial.
        self.target_serial = self.synced_serial
        self.packages_to_sync = {}
        logger.info(f"Current mirror serial: {self.synced_serial}")

        if self.todolist.exists():
            # We started a sync previously and left a todo list as well as the
            # targetted serial. We'll try to keep going through the todo list
            # and then mark the targetted serial as done.
            logger.info("Resuming interrupted sync from local todo list.")
            saved_todo = iter(open(self.todolist, encoding="utf-8"))
            self.target_serial = int(next(saved_todo).strip())
            for line in saved_todo:
                package, serial = line.strip().split()
                self.packages_to_sync[package] = int(serial)
        elif not self.synced_serial:
            logger.info("Syncing all packages.")
            # First get the current serial, then start to sync. This makes us
            # more defensive in case something changes on the server between
            # those two calls.
            self.packages_to_sync.update(self.master.all_packages())
            self.target_serial = max(
                [self.synced_serial] + list(self.packages_to_sync.values())
            )
        else:
            logger.info("Syncing based on changelog.")
            self.packages_to_sync.update(
                self.master.changed_packages(self.synced_serial)
            )
            self.target_serial = max(
                [self.synced_serial] + list(self.packages_to_sync.values())
            )
            # We can avoid downloading the main index page if we don't have
            # anything todo at all during a changelog-based sync.
            self.need_index_sync = bool(self.packages_to_sync)

        self._filter_packages()
        logger.info(f"Trying to reach serial: {self.target_serial}")
        pkg_count = len(self.packages_to_sync)
        logger.info(f"{pkg_count} packages to sync.")
604012
def get_package_versions(package_name):
    
    package_manager = _get_package_manager()
    pkg = package_manager.get_package_version(package_name, None)
    return pkg.package_versions()
677665
def package_releases(self, package, url_fmt=lambda u: u):
        
        return [{
            'name': package,
            'version': version,
            'urls': [self.get_urlhash(f, url_fmt) for f in files]
        } for version, files in self.storage.get(package, {}).items()]
16575
def versions(constraints, elm_version, should_update, only_update)
      if repository.cloned? &&
         !repository.fetched &&
         should_update &&
         (!only_update || only_update == package_name)
        # Get updates from upstream
        Logger.arrow "Getting updates for: #{package_name.bold}"
        repository.fetch
      end

      case @branch
      when Branch::Just
        [identifier.version(fetch(@branch.ref))]
      when Branch::Nothing
        matching_versions constraints, elm_version
      end
    end
121802
function getPackageMetaFile(answers) {
    const packageFields = ['name', 'version', 'license', 'category'];
    const packageObject = merge(pick(packageFields, answers),
        { dependencies: { 'rung-cli': '1.0.0' } });

    return {
        filename: path.join(answers.name, 'package.json'),
        content: JSON.stringify(packageObject, null, 2)
    };
}
362897
def versions_from_archive(self):
        
        py_vers = versions_from_trove(self.classifiers)
        return [ver for ver in py_vers if ver != self.unsupported_version]
686298
def _import_packages(packages, optional=None):
    
    if not optional:
        optional = []

    package_references = set()

    # Check all reqiured packages
    failures = set()
    for package_name in packages:
        try:
            package_reference = __import__(package_name, globals(), locals(), [], 0)
            package_references.add(package_reference)
        except ImportError:
            failures.add(package_name)

    # Report aggregated list of import failures (save a developer time when building a new frozen environment)
    if failures:
        raise ImportError(u"Unable to find required packages: {0}".format(u", ".join(failures)))

    # Check all optional packages (and warn if some aren't found)
    failures = set()
    for package_name in optional:
        try:
            package_reference = __import__(package_name, globals(), locals(), [], 0)
            package_references.add(package_reference)
        except ImportError:
            failures.add(package_name)

    # Warn user which optional packages weren't found
    for failure in failures:
        warn(ImportWarning(u"Unable to import {0}".format(failure)))

    return package_references
1361510
def clone(self):
		
		snapshot = DistributionSnapshot(self.distribution(), self.go_version)
		for package in self.builds:
			snapshot.setRpms(package, self.builds[package]["build"], self.builds[package]["build_ts"], self.builds[package]["rpms"])

		return snapshot
892825
def _installed_packages(self) -> Generator[str, None, None]:
        """"""
        with (self._build_dir / 'package.json').open('r') as f:
            packages = json.load(f)
        yield from packages['dependencies'].keys()