def install_pip(self, package, save=True, save_dev=False):
        """Installs a pip package.

        :param save: if `True`, pins the package to the Hydrogen requirements
            YAML file.
        :param save_dev: if `True`, pins the package as a development
            dependency to the Hydrogen requirements YAML file.
        :param return: a **single** :class:`Requirement` object, representing
            the installed version of the given package.
        """
        requirement = Requirement.coerce(package)
        click.echo("pip install " + requirement.package)
        cmd = envoy.run("pip install {}".format(str(requirement)))
        if cmd.status_code == 0:
            installed_packages = get_installed_pypackages()
            package = installed_packages[requirement.package]
            requirement.version = "=={}".format(package.version)
            if save:
                self.requirements["all"].add(requirement)
            if save_dev:
                self.requirements["dev"].add(requirement)
            if save or save_dev:
                self.requirements.save()
            return requirement
        else:
            fatal(cmd.std_err)
def _create_swdb_group(self, group_id, pkg_types, pkgs):
        comps_group = self._base.comps._group_by_id(group_id)
        if not comps_group:
            self._raise_or_warn(self._skip_unavailable, _("Group id '%s' is not available.") % group_id)
            return None

        swdb_group = self._base.history.group.new(group_id, comps_group.name, comps_group.ui_name, pkg_types)

        try:
            for pkg in pkgs:
                name = pkg["name"]
                self._assert_type(name, str, "groups.packages.name", "string")
                installed = pkg["installed"]
                self._assert_type(installed, bool, "groups.packages.installed", "boolean")
                package_type = pkg["package_type"]
                self._assert_type(package_type, str, "groups.packages.package_type", "string")

                try:
                    swdb_group.addPackage(name, installed, libdnf.transaction.stringToCompsPackageType(package_type))
                except libdnf.error.Error as e:
                    raise TransactionError(str(e))

        except KeyError as e:
            raise TransactionError(
                _('Missing object key "{key}" in groups.packages.').format(key=e.args[0])
            )

        return swdb_group