Exemple #1
0
def _setup_options_parser(options_context, package_options):
    """Setup the command options parser, merging standard options as well
    as custom options defined in the bento.info file, if any.
    """
    scheme, scheme_opts_d = get_scheme(sys.platform)

    p = options_context

    # Create default path options
    scheme_opts = {}
    for name, opt_d in list(scheme_opts_d.items()):
        o = opt_d.pop("opts")
        opt = Option(*o, **opt_d)
        scheme_opts[name] = opt

    # Add custom path options (as defined in bento.info) to the path scheme
    for name, f in list(package_options.path_options.items()):
        scheme_opts[name] = \
            Option('--%s' % f.name,
                   help='%s [%s]' % (f.description, f.default_value))

    p.add_group("installation_options", "Installation fine tuning")
    for opt in list(scheme_opts.values()):
        p.add_option(opt, "installation_options")

    flag_opts = {}
    if package_options.flag_options:
        p.add_group("optional_features", "Optional features")
        for name, v in list(package_options.flag_options.items()):
            flag_opts[name] = Option("--%s" % v.name,
                                     help="%s [default=%s]" %
                                     (v.description, v.default_value))
            p.add_option(flag_opts[name], "optional_features")
Exemple #2
0
def _setup_options_parser(options_context, package_options):
    """Setup the command options parser, merging standard options as well
    as custom options defined in the bento.info file, if any.
    """
    scheme, scheme_opts_d = get_scheme(sys.platform)

    p = options_context

    # Create default path options
    scheme_opts = {}
    for name, opt_d in scheme_opts_d.items():
        o = opt_d.pop("opts")
        opt = Option(*o, **opt_d)
        scheme_opts[name] = opt

    # Add custom path options (as defined in bento.info) to the path scheme
    for name, f in package_options.path_options.items():
        scheme_opts[name] = \
            Option('--%s' % f.name,
                   help='%s [%s]' % (f.description, f.default_value))

    p.add_group("installation_options", "Installation fine tuning")
    for opt in scheme_opts.values():
        p.add_option(opt, "installation_options")

    flag_opts = {}
    if package_options.flag_options:
        p.add_group("optional_features", "Optional features")
        for name, v in package_options.flag_options.items():
            flag_opts[name] = Option(
                    "--%s" % v.name,
                    help="%s [default=%s]" % (v.description, v.default_value))
            p.add_option(flag_opts[name], "optional_features")
Exemple #3
0
    def _test(self, package_options, r_scheme):
        self.context.register_package_options(package_options)
        scheme = self.context.retrieve_scheme()

        default_scheme, _ = get_scheme(sys.platform)
        r_scheme.update(default_scheme)
        r_scheme['py_version_short'] = ".".join(str(part) for part in sys.version_info[:2])
        r_scheme['pkgname'] = package_options.name

        self.assertEqual(scheme, r_scheme)
    def __init__(self, files, meta, executables, path_variables=None):
        self.files = files
        self.meta = meta
        if path_variables is None:
            self._path_variables = get_scheme(sys.platform)[0]
        else:
            self._path_variables = path_variables
        self.executables = executables

        self._variables = {"pkgname": self.meta["name"],
                           "py_version_short": ".".join([str(i) for i in sys.version_info[:2]])}
    def _test(self, package_options, r_scheme):
        self.context.register_package_options(package_options)
        scheme = self.context.retrieve_scheme()

        default_scheme, _ = get_scheme(sys.platform)
        r_scheme.update(default_scheme)
        r_scheme['py_version_short'] = ".".join(
            str(part) for part in sys.version_info[:2])
        r_scheme['pkgname'] = package_options.name

        self.assertEqual(scheme, r_scheme)
Exemple #6
0
def _compute_scheme(package_options):
    """Compute path and flags-related options as defined in the script file(s)

    Parameters
    ----------
    package_options: PackageOptions
    """
    scheme, scheme_opts_d = get_scheme(sys.platform)

    # XXX: abstract away those, as it is copied from distutils
    scheme['py_version_short'] = ".".join(str(part) for part in sys.version_info[:2])
    scheme['pkgname'] = package_options.name

    for name, f in package_options.path_options.items():
        scheme[name] = f.default_value
    return scheme
Exemple #7
0
    def add_configuration_options(self, package_options):
        """Add the path and flags-related options as defined in the script file
        to the command.

        Parameters
        ----------
        package_options: PackageOptions
        """
        scheme, scheme_opts_d = get_scheme(sys.platform)

        scheme_opts = {}
        for name, opt_d in scheme_opts_d.items():
            kw = {"help": opt_d["help"]}
            opt = Option(*opt_d["opts"], **kw)
            scheme_opts[name] = opt

        # XXX: abstract away those, as it is copied from distutils
        py_version = sys.version.split()[0]
        scheme['py_version_short'] = py_version[0:3]

        scheme['pkgname'] = package_options.name

        # Add custom path options (as defined in bento.info) to the path scheme
        for name, f in package_options.path_options.items():
            scheme[name] = f.default_value
            scheme_opts[name] = \
                Option('--%s' % f.name,
                       help='%s [%s]' % (f.description, f.default_value))

        install_group = self.parser.add_option_group("Installation fine tuning")
        for opt in scheme_opts.values():
            self.opts.append(opt)
            install_group.add_option(opt)

        flag_opts = {}
        if package_options.flag_options:
            flags_group = self.parser.add_option_group("Optional features")
            for name, v in package_options.flag_options.items():
                flag_opts[name] = Option(
                        "--with-%s" % v.name,
                        help="%s [default=%s]" % (v.description, v.default_value))
                self.opts.append(flag_opts[name])
                flags_group.add_option(flag_opts[name])

        return scheme, flag_opts