def _add_if_exists(attrib, as_list=False): value = getattr(conanfile, attrib, None) if value: if not as_list: item_data[attrib] = value else: item_data[attrib] = make_tuple(value)
def run_configure_method(conanfile, down_options, down_ref, ref): """ Run all the config-related functions for the given conanfile object """ # Avoid extra time manipulating the sys.path for python with get_env_context_manager(conanfile, without_python=True): if hasattr(conanfile, "config"): conan_v2_error("config() has been deprecated. Use config_options() and configure()") with conanfile_exception_formatter(str(conanfile), "config"): conanfile.config() with conanfile_exception_formatter(str(conanfile), "config_options"): conanfile.config_options() conanfile.options.propagate_upstream(down_options, down_ref, ref) if hasattr(conanfile, "config"): with conanfile_exception_formatter(str(conanfile), "config"): conanfile.config() with conanfile_exception_formatter(str(conanfile), "configure"): conanfile.configure() conanfile.settings.validate() # All has to be ok! conanfile.options.validate() # Recipe provides its own name if nothing else is defined conanfile.provides = make_tuple(conanfile.provides or conanfile.name) if conanfile.deprecated: from six import string_types message = "Recipe '%s' is deprecated" % conanfile.display_name if isinstance(conanfile.deprecated, string_types): message += " in favor of '%s'" % conanfile.deprecated message += ". Please, consider changing your requirements." conanfile.output.warn(message)
def test_generator(self): def items(): for i in [1, 2, 3]: yield i self.assertTupleEqual(make_tuple(items()), (1, 2, 3))
def test_corner_cases(self): self.assertIsNone(make_tuple(None)) self.assertTupleEqual(make_tuple("one"), ("one",))
def test_iterable(self): self.assertTupleEqual(make_tuple([1, 2, 3]), (1, 2, 3)) self.assertTupleEqual(make_tuple(("one", "two")), ("one", "two")) self.assertTupleEqual(make_tuple({1: "a", 2: "b", 3: "c"}.keys()), (1, 2, 3)) self.assertTupleEqual(make_tuple({1: "a", 2: "b", 3: "c"}.values()), ("a", "b", "c"))