How to use the pybombs.recipe.get_recipe function in PyBOMBS

To help you get started, we’ve selected a few PyBOMBS 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 gnuradio / pybombs / pybombs / package_manager.py View on Github external
"""
        Install the given package. Returns True if successful, False otherwise.
        """
        self.log.debug("install({})".format(name))
        if self.check_package_flag(name, 'forceinstalled'):
            self.log.debug("Package {} is assumed installed.".format(name))
            # TODO maybe we can figure out a version string
            return True
        packagers = self.get_packagers(name)
        if kwargs.get('static'):
            self.log.debug('Package will be built statically.')
            if not self.prefix_available:
                self.log.error('Static builds require source builds.')
                exit(1)
            packagers = [self.src,]
        r = recipe.get_recipe(name)
        for pkgr in packagers:
            self.log.debug("Trying to use packager {}".format(pkgr.name))
            try:
                install_result = pkgr.install(r)
            except PBException as e:
                self.log.error(
                    "Something went wrong while trying to install {} using {}: {}".format(
                        name, pkgr.name, str(e)
                    )
                )
                continue
            if install_result:
                return True
        return False
github gnuradio / pybombs / pybombs / package_manager.py View on Github external
string (if the version string can't be determined, returns True instead).

        ignore_pkg_flag is passed to get_packagers().
        """
        install_type = _get_valid_install_type(install_type)
        if not return_pkgr_name and name in self.pmc.known_installed.get(install_type, {}):
            self.log.trace("{0} has cached installed-status: {1}".format(
                name, self.pmc.known_installed.get(install_type, {}).get(name)
            ))
            return self.pmc.known_installed.get(install_type, {}).get(name)
        self.log.debug("Checking if package {0} is installed...".format(name))
        if self.check_package_flag(name, 'forceinstalled'):
            self.log.debug("Package {0} is forced to state 'installed'.".format(name))
            # TODO maybe we can figure out a version string
            return ['force-installed'] if return_pkgr_name else True
        r = recipe.get_recipe(name)
        pkgrs = []
        for pkgr in self.get_packagers(name, install_type, ignore_pkg_flag):
            pkg_version = pkgr.installed(r)
            if pkg_version is None or not pkg_version:
                continue
            else:
                self.pmc.known_installed[install_type][name] = True
                if return_pkgr_name:
                    pkgrs.append(pkgr.name)
                else:
                    return pkg_version
        if return_pkgr_name and len(pkgrs):
            return pkgrs
        self.pmc.known_installed[install_type][name] = False
        self.log.debug("Package {0} is not installed.".format(name))
        return False
github gnuradio / pybombs / pybombs / package_manager.py View on Github external
def update(self, name):
        """
        Update the given package. Returns True if successful, False otherwise.
        """
        r = recipe.get_recipe(name)
        for pkgr in self.get_packagers(name):
            try:
                update_result = pkgr.update(r)
            except PBException as e:
                self.log.error(
                    "Something went wrong while trying to update {} using {}: {}".format(
                        name, pkgr.name, str(e)
                    )
                )
                continue
            if update_result:
                return True
        return False
github gnuradio / pybombs / pybombs / package_manager.py View on Github external
def _std_package_operation(self, name, operation, pkgrs, verify=False, **kwargs):
        """
        Standard package operation: Try an operation on all packagers.
        """
        rec = recipe.get_recipe(name)
        for pkgr in pkgrs:
            self.log.debug("Using packager {0}".format(pkgr.name))
            try:
                result = getattr(pkgr, operation)(rec, **kwargs)
                if result:
                    if verify and not pkgr.verify(rec):
                        self.log.warn("Package reported successful {0}, but verification failed.".format(operation))
                        continue
                    return True
            except PBException as ex:
                self.log.error(
                    "Something went wrong while trying to {0} {1} using {2}: {3}".format(
                        operation, name, pkgr.name, str(ex).strip()
                    )
                )
        return False
github gnuradio / pybombs / pybombs / commands / prefix.py View on Github external
def _install_sdk_to_prefix(self, sdkname):
        """
        Read recipe for sdkname, and install the SDK to the prefix.
        """
        from pybombs import recipe
        src_dir = self.prefix.src_dir
        cfg_file = self.prefix.cfg_file
        ### Get the recipe
        r = recipe.get_recipe(sdkname, target='sdk')
        try:
            self.log.trace("Switching CWD to {0}".format(src_dir))
            if not op.isdir(src_dir):
                os.mkdir(src_dir)
            os.chdir(src_dir)
        except:
            self.log.error("Source dir required to install SDK.")
            return False
        ### Install the actual SDK file
        self.log.debug("Fetching SDK `{sdk}'".format(sdk=sdkname))
        fetcher.Fetcher().fetch(r)
        self.log.info("Installing SDK `{sdk}'".format(sdk=sdkname))
        # Install command
        cmd = r.var_replace_all(r.get_command('install'))
        if subproc.monitor_process(cmd, shell=True, env=os.environ) == 0:
            self.log.debug("Installation successful")
github gnuradio / pybombs / pybombs / commands / prefix.py View on Github external
def get_prefix_recipe(recipe_name):
    " Return the prefix recipe or None "
    from pybombs import recipe
    return recipe.get_recipe(recipe_name, target='prefix', fail_easy=True)
github gnuradio / pybombs / pybombs / package_manager.py View on Github external
def check_package_flag(self, pkgname, flag):
        """
        See if package 'pkgname' has 'flag' set (return the boolean value
        of that flag if yes, or None otherwise).
        """
        return bool(
            self.cfg.get_package_flags(
                pkgname,
                recipe.get_recipe(pkgname).category
            ).get(flag)
        )
github gnuradio / pybombs / pybombs / commands / rebuild.py View on Github external
self.args.packages,
            lambda x: bool(
                (x in self.args.packages) or \
                (self.args.deps and self.is_installed(x))
            )
        )
        if self.log.getEffectiveLevel() <= 10 or self.args.print_tree:
            print("Rebuild tree:")
            rb_tree.pretty_print()
        ### Recursively rebuild, starting at the leaf nodes
        node_cache = []
        while not rb_tree.empty():
            pkg = rb_tree.pop_leaf_node()
            if pkg in node_cache:
                continue
            rec = recipe.get_recipe(pkg)
            self.log.info("Rebuilding package: {0}".format(pkg))
            if not self.pm.rebuild(
                    rec,
                    make_clean=self.args.clean,
                    nuke_builddir=not (self.args.keep_build or bool(self.cfg.get('keep_builddir', False)))
            ):
                self.log.error("Error rebuilding package {0}. Aborting.".format(pkg))
                return 1
            self.log.info("Rebuild successful.")