def _compute_scheme(self, bento_info, options): package_options = PackageOptions.from_string(bento_info) pkg = PackageDescription.from_string(bento_info) scheme = _compute_scheme(package_options) set_scheme_win32(scheme, options, pkg) return scheme
def _run_configure_and_build(self, bento_info, install_prefix): top_node = self.top_node create_fake_package_from_bento_info(top_node, bento_info) context = GlobalContext(None) options = PackageOptions.from_string(bento_info) context.register_package_options(options) cmd_argv = [ "--prefix=%s" % install_prefix, "--exec-prefix=%s" % install_prefix ] conf, configure = prepare_configure(top_node, bento_info, ConfigureYakuContext, cmd_argv) context.register_command("configure", configure) options_context = OptionsContext.from_command(configure) if not context.is_options_context_registered("configure"): context.register_options_context("configure", options_context) context.save_command_argv("configure", cmd_argv) run_command_in_context(conf, configure) bld, build = prepare_build(top_node, bento_info) run_command_in_context(bld, build) return context, conf, configure, bld, build
def _run_configure(self, bentos, bscripts=None, configure_argv=None, build_argv=None): from bento.backends.waf_backend import make_stream_logger from bento.backends.waf_backend import WafBackend top_node = self.top_node bento_info = bentos["bento.info"] package = PackageDescription.from_string(bento_info) package_options = PackageOptions.from_string(bento_info) create_fake_package_from_bento_info(top_node, bento_info) top_node.make_node("bento.info").safe_write(bento_info) global_context = create_global_context(package, package_options, WafBackend()) conf, configure = prepare_command(global_context, "configure", configure_argv, package, top_node) run_command_in_context(conf, configure) bld, build = prepare_command(global_context, "build", build_argv, package, top_node) bld.waf_context.logger = make_stream_logger("build", cStringIO()) return conf, configure, bld, build
def _run_configure_and_build(self, bento_info, install_prefix): top_node = self.top_node create_fake_package_from_bento_info(top_node, bento_info) context = GlobalContext(None) options = PackageOptions.from_string(bento_info) context.register_package_options(options) cmd_argv = ["--prefix=%s" % install_prefix, "--exec-prefix=%s" % install_prefix] conf, configure = prepare_configure(top_node, bento_info, ConfigureYakuContext, cmd_argv) context.register_command("configure", configure) options_context = OptionsContext.from_command(configure) if not context.is_options_context_registered("configure"): context.register_options_context("configure", options_context) context.save_command_argv("configure", cmd_argv) run_command_in_context(conf, configure) bld, build = prepare_build(top_node, bento_info) run_command_in_context(bld, build) return context, conf, configure, bld, build
def test_path_option(self): package_options = PackageOptions.from_string("""\ Name: foo Path: floupi Description: yoyo Default: /yeah """) self._test(package_options, {"floupi": "/yeah"})
def test_simple_from_file(self): fid, filename = tempfile.mkstemp(suffix=".info", text=True) try: os.write(fid, self.simple_text.encode()) opts = PackageOptions.from_file(filename) self._test_simple(opts) finally: os.close(fid) os.remove(filename)
def _execute_build(self, bento_info): create_fake_package_from_bento_info(self.top_node, bento_info) # FIXME: this should be done automatically in create_fake_package_from_bento_info self.top_node.make_node("bento.info").safe_write(bento_info) package = PackageDescription.from_string(bento_info) package_options = PackageOptions.from_string(bento_info) global_context = create_global_context(package, package_options, YakuBackend()) conf, configure = prepare_command(global_context, "configure", [], package, self.run_node) run_command_in_context(conf, configure) bld, build = prepare_command(global_context, "build", [], package, self.run_node) run_command_in_context(bld, build) return bld
def test_simple_waf(self): from bento.backends.waf_backend import make_stream_logger from bento.backends.waf_backend import WafBackend top_node = self.top_node package = PackageDescription.from_string(BENTO_INFO_WITH_EXT) package_options = PackageOptions.from_string(BENTO_INFO_WITH_EXT) create_fake_package_from_bento_info(top_node, BENTO_INFO_WITH_EXT) top_node.make_node("bento.info").safe_write(BENTO_INFO_WITH_EXT) global_context = create_global_context(package, package_options, WafBackend()) conf, configure = prepare_command(global_context, "configure", [], package, top_node) run_command_in_context(conf, configure) bld, build = prepare_command(global_context, "build", [], package, top_node) bld.waf_context.logger = make_stream_logger("build", cStringIO()) run_command_in_context(bld, build)
def __init__(self, attrs=None): if attrs is None: attrs = {} if not "bento_info" in attrs: bento_info = "bento.info" else: bento_info = attrs["bento.info"] self.pkg = PackageDescription.from_file(bento_info) package_options = PackageOptions.from_file(bento_info) attrs = _setup_cmd_classes(attrs) d = pkg_to_distutils_meta(self.pkg) attrs.update(d) Distribution.__init__(self, attrs) self.packages = self.pkg.packages self.py_modules = self.pkg.py_modules if hasattr(self, "entry_points"): if self.entry_points is None: self.entry_points = {} console_scripts = [ e.full_representation() for e in self.pkg.executables.values() ] if "console_scripts" in self.entry_points: self.entry_points["console_scripts"].extend(console_scripts) else: self.entry_points["console_scripts"] = console_scripts source_root = os.getcwd() build_root = os.path.join(source_root, "build") root = create_root_with_source_tree(source_root, build_root) self.top_node = root._ctx.srcnode self.build_node = root._ctx.bldnode self.run_node = root._ctx.srcnode self.global_context = global_context_factory(package_options) mods = set_main(self.pkg, self.top_node, self.build_node) self._setup_hooks(self.pkg, self.global_context, mods)
def __init__(self, attrs=None): if attrs is None: attrs = {} if not "bento_info" in attrs: bento_info = "bento.info" else: bento_info = attrs["bento.info"] self.pkg = PackageDescription.from_file(bento_info) self.package_options = PackageOptions.from_file(bento_info) attrs = _setup_cmd_classes(attrs) d = pkg_to_distutils_meta(self.pkg) attrs.update(d) Distribution.__init__(self, attrs) self.packages = self.pkg.packages self.py_modules = self.pkg.py_modules if hasattr(self, "entry_points"): if self.entry_points is None: self.entry_points = {} console_scripts = [e.full_representation() for e in self.pkg.executables.values()] if "console_scripts" in self.entry_points: self.entry_points["console_scripts"].extend(console_scripts) else: self.entry_points["console_scripts"] = console_scripts source_root = os.getcwd() build_root = os.path.join(source_root, "build") root = create_root_with_source_tree(source_root, build_root) self.top_node = root._ctx.srcnode self.build_node = root._ctx.bldnode self.run_node = root._ctx.srcnode self.global_context = global_context_factory(self.package_options) modules = set_main(self.top_node, self.build_node, self.pkg)
def _raw_to_options(raw): kw = raw_to_options_kw(raw) return PackageOptions(**kw)
def test_simple_from_string(self): s = self.simple_text opts = PackageOptions.from_string(s) self._test_simple(opts)
def test_no_options(self): package_options = PackageOptions.from_string("""\ Name: foo """) self._test(package_options, {})