How to use the pikaur.version.VersionMatcher function in pikaur

To help you get started, we’ve selected a few pikaur examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github actionless / pikaur / pikaur / install_cli.py View on Github external
def _find_extra_aur_build_deps(self, all_package_builds: Dict[str, PackageBuild]) -> List[str]:
        new_build_deps_found: List[str] = []
        for pkgbuild in all_package_builds.values():
            new_build_deps_found_for_pkg = []
            pkgbuild.get_deps(all_package_builds=all_package_builds, filter_built=False)
            for dep_line in (
                    pkgbuild.new_deps_to_install + pkgbuild.new_make_deps_to_install
            ):
                dep_name = VersionMatcher(dep_line).pkg_name
                if dep_name in self.all_aur_packages_names:
                    continue
                try:
                    PackageDB.find_repo_package(dep_line)
                except PackagesNotFoundInRepo:
                    new_build_deps_found_for_pkg.append(dep_name)
            if new_build_deps_found_for_pkg:
                print_warning(_("New AUR build deps found for {pkg} package: {deps}").format(
                    pkg=bold_line(', '.join(pkgbuild.package_names)),
                    deps=bold_line(', '.join(new_build_deps_found_for_pkg)),
                ))
                if not ask_to_continue():
                    raise SysExit(125)
                new_build_deps_found += new_build_deps_found_for_pkg
        return new_build_deps_found
github actionless / pikaur / pikaur / build.py View on Github external
all_provided_pkgnames: Dict[str, str] = {}
        for pkg_build in all_package_builds.values():
            for pkg_name in pkg_build.package_names:
                srcinfo = SrcInfo(
                    pkgbuild_path=pkg_build.pkgbuild_path, package_name=pkg_name
                )
                all_provided_pkgnames.update({
                    provided_name: pkg_name
                    for provided_name in
                    [pkg_name] + srcinfo.get_values('provides')
                })

        self.built_deps_to_install = {}

        for dep in self.all_deps_to_install:
            dep_name = VersionMatcher(dep).pkg_name
            if dep_name not in all_provided_pkgnames:
                continue
            package_build = all_package_builds[all_provided_pkgnames[dep_name]]
            if package_build == self:
                _mark_dep_resolved(dep)
                continue
            for pkg_name in package_build.package_names:
                if package_build.failed:
                    self.failed = True
                    raise DependencyError()
                if not package_build.built_packages_paths.get(pkg_name):
                    raise DependencyNotBuiltYet()
                self.built_deps_to_install[pkg_name] = \
                    package_build.built_packages_paths[pkg_name]
                _mark_dep_resolved(dep)
github actionless / pikaur / pikaur / aur_deps.py View on Github external
def get_aur_pkg_deps_and_version_matchers(aur_pkg: AURPackageInfo) -> Dict[str, VersionMatcher]:
    deps: Dict[str, VersionMatcher] = {}
    for dep_line in (
            (aur_pkg.depends or []) + (aur_pkg.makedepends or []) + (aur_pkg.checkdepends or [])
    ):
        version_matcher = VersionMatcher(dep_line)
        name = version_matcher.pkg_name
        if name not in deps:
            deps[name] = version_matcher
        else:
            deps[name].add_version_matcher(version_matcher)
    return deps
github actionless / pikaur / pikaur / install_info_fetcher.py View on Github external
# process deps
            pkg_dep_lines = (
                (
                    pkg_install_info.package.depends +
                    pkg_install_info.package.makedepends +
                    pkg_install_info.package.checkdepends
                ) if (
                    isinstance(pkg_install_info.package, AURPackageInfo)
                ) else pkg_install_info.package.depends
            )
            for dep_install_info in all_deps_install_infos:
                for name_and_version in (
                        [dep_install_info.package.name, ] +  # type: ignore
                        (dep_install_info.package.provides or [])
                ):
                    name = VersionMatcher(name_and_version).pkg_name
                    if name in [
                            VersionMatcher(dep_line).pkg_name
                            for dep_line in pkg_dep_lines
                    ]:
                        if not dep_install_info.required_by:
                            dep_install_info.required_by = []
                        dep_install_info.required_by.append(pkg_install_info)

                        # if package marked as provider candidate
                        # is already requested as explicit dep for other package
                        # then remove `provided_by` mark and metadata change
                        if (
                                dep_install_info.provided_by
                        ) and (
                            name_and_version == dep_install_info.package.name
                        ):
github actionless / pikaur / pikaur / srcinfo.py View on Github external
def _get_depends(self, field: str, lines: List[str] = None) -> Dict[str, VersionMatcher]:
        if lines is None:
            lines = self._common_lines + self._package_lines
        carch = MakepkgConfig.get('CARCH')
        dependencies: Dict[str, VersionMatcher] = {}
        for dep_line in (
                self.get_values(field, lines=lines) +
                self.get_values(f'{field}_{carch}', lines=lines)
        ):
            version_matcher = VersionMatcher(dep_line)
            pkg_name = version_matcher.pkg_name
            if pkg_name not in dependencies:
                dependencies[pkg_name] = version_matcher
            else:
                dependencies[pkg_name].add_version_matcher(version_matcher)
        return dependencies
github actionless / pikaur / pikaur / install_info_fetcher.py View on Github external
# iterate each package metadata
        for pkg_install_info in all_install_infos:

            # process providers
            provides = pkg_install_info.package.provides
            providing_for: List[str] = []
            if provides and (
                    pkg_install_info.name not in self.install_package_names
            ) and (
                pkg_install_info.name not in explicit_aur_pkg_names
            ) and (
                pkg_install_info.name not in all_local_pkgnames
            ):
                providing_for = [
                    pkg_name for pkg_name in sum([
                        (lambda vm: [vm.line, vm.pkg_name])(VersionMatcher(prov))
                        for prov in provides
                    ], [])
                    if pkg_name in all_requested_pkg_names
                ]
            if providing_for:
                provided_name = providing_for[0]
                if provided_name in all_provided_pkgs:
                    pkg_install_info.name = provided_name
                    pkg_install_info.provided_by = [
                        provided_dep.package for provided_dep in
                        all_provided_pkgs[provided_name]
                    ]
                    pkg_install_info.new_version = ''

            # process deps
            pkg_dep_lines = (