当前位置: 首页>>代码示例>>Python>>正文


Python ConanInfo.loads方法代码示例

本文整理汇总了Python中conans.model.info.ConanInfo.loads方法的典型用法代码示例。如果您正苦于以下问题:Python ConanInfo.loads方法的具体用法?Python ConanInfo.loads怎么用?Python ConanInfo.loads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在conans.model.info.ConanInfo的用法示例。


在下文中一共展示了ConanInfo.loads方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_search

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def test_search(self):
        """ check the dict is returned by get_packages_info service
        """
        # Creating and saving conans, packages, and conans.vars
        conan_ref2 = ConanFileReference("openssl", "3.0", "lasote", "stable")
        conan_ref3 = ConanFileReference("Assimp", "1.10", "fenix", "stable")
        conan_ref4 = ConanFileReference("assimpFake", "0.1", "phil", "stable")

        package_ref2 = PackageReference(conan_ref2, "12345587754")
        package_ref3 = PackageReference(conan_ref3, "77777777777")

        conan_vars = """
[options]
    use_Qt=%s
"""
        conan_vars1 = conan_vars % "True"
        conan_vars2 = conan_vars % "False"
        conan_vars3 = conan_vars % "True"

        save_files(self.paths.package(self.package_reference), {CONANINFO: conan_vars1})
        save_files(self.paths.package(package_ref2), {CONANINFO: conan_vars2})
        save_files(self.paths.package(package_ref3), {CONANINFO: conan_vars3})
        save_files(self.paths.export(conan_ref4), {"dummy.txt": "//"})

        info = self.service.search()
        expected = {self.conan_reference: {"123123123": ConanInfo.loads("[options]\nuse_Qt=True")},
                    conan_ref2: {"12345587754": ConanInfo.loads("[options]\nuse_Qt=False")},
                    conan_ref3: {"77777777777": ConanInfo.loads("[options]\nuse_Qt=True")},
                    conan_ref4: {}}

        self.assertEqual(expected, info)

        info = self.service.search(pattern="Assimp*", ignorecase=False)
        self.assertEqual(info, {conan_ref3: {"77777777777":
                                           ConanInfo.loads("[options]\nuse_Qt=True")}})
开发者ID:KindDragon,项目名称:conan,代码行数:37,代码来源:service_test.py

示例2: invalid_settings_test4

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def invalid_settings_test4(self):
        content = """
from conans import ConanFile

class SayConan(ConanFile):
    name = "Say"
    version = "0.1"
    settings = "os"
"""

        self.client.save({CONANFILE: content})
        self.client.run("install . -s os=ChromeOS --build missing", ignore_error=True)
        self.assertIn(bad_value_msg("settings.os", "ChromeOS",
                                    ['Android', 'Arduino', 'FreeBSD', 'Linux', 'Macos', 'SunOS', 'Windows',
                                     'WindowsStore', 'iOS', 'tvOS', 'watchOS']),
                      str(self.client.user_io.out))

        # Now add new settings to config and try again
        config = load(self.client.paths.settings_path)
        config = config.replace("Windows:%s" % os.linesep,
                                "Windows:%s    ChromeOS:%s" % (os.linesep, os.linesep))

        save(self.client.paths.settings_path, config)
        self.client.run("install . -s os=ChromeOS --build missing")
        self.assertIn('Generated conaninfo.txt', str(self.client.user_io.out))

        # Settings is None
        content = """
from conans import ConanFile

class SayConan(ConanFile):
    name = "Say"
    version = "0.1"
    settings = None
"""
        self.client.save({CONANFILE: content})
        self.client.run("install . --build missing")
        self.assertIn('Generated conaninfo.txt', str(self.client.user_io.out))
        conan_info = ConanInfo.loads(load(os.path.join(self.client.current_folder, CONANINFO)))
        self.assertEquals(conan_info.settings.dumps(), "")

        # Settings is {}
        content = """
from conans import ConanFile

class SayConan(ConanFile):
    name = "Say"
    version = "0.1"
    settings = {}
"""
        self.client.save({CONANFILE: content})
        self.client.run("install . --build missing")
        self.assertIn('Generated conaninfo.txt', str(self.client.user_io.out))
        conan_info = ConanInfo.loads(load(os.path.join(self.client.current_folder, CONANINFO)))
        self.assertEquals(conan_info.settings.dumps(), "")
开发者ID:19317362,项目名称:conan,代码行数:57,代码来源:other_settings_test.py

示例3: get_package_info_test

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def get_package_info_test(self):
        # Upload a conans
        conan_reference = ConanFileReference.loads("conan3/[email protected]_user/testing")
        self._upload_recipe(conan_reference)

        # Upload an package
        package_reference = PackageReference(conan_reference, "1F23223EFDA")
        conan_info = """[settings]
    arch=x86_64
    compiler=gcc
    os=Linux
[options]
    386=False
[requires]
    Hello
    Bye/2.9
    Say/[email protected]/testing
    Chat/[email protected]/testing:SHA_ABC
"""
        self._upload_package(package_reference, {CONANINFO: conan_info})

        # Get the package info
        info = self.api.get_package_info(package_reference)
        self.assertIsInstance(info, ConanInfo)
        self.assertEquals(info, ConanInfo.loads(conan_info))
开发者ID:nesono,项目名称:conan,代码行数:27,代码来源:rest_api_test.py

示例4: search_packages

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def search_packages(self, reference, query):
        """ Return a dict like this:

                {package_ID: {name: "OpenCV",
                               version: "2.14",
                               settings: {os: Windows}}}
        param conan_ref: ConanFileReference object
        """
        # GET PROPERTIES FROM QUERY
        properties = get_properties_from_query(query)

        logger.debug("SEARCH PACKAGE PROPERTIES: %s" % properties)
        result = {}
        packages_path = self._paths.packages(reference)
        subdirs = self._adapter.list_folder_subdirs(packages_path, level=1)
        for package_id in subdirs:
            try:
                package_reference = PackageReference(reference, package_id)
                info_path = self._adapter.join_paths(self._paths.package(package_reference,
                                                                         short_paths=None),
                                                     CONANINFO)
                if not self._adapter.path_exists(info_path, self._paths.store):
                    raise NotFoundException("")
                conan_info_content = self._adapter.load(info_path)
                conan_vars_info = ConanInfo.loads(conan_info_content)
                if not self._filtered_by_properties(conan_vars_info, properties):
                    result[package_id] = conan_vars_info.serialize_min()
            except Exception as exc:
                logger.error("Package %s has not ConanInfo file" % str(package_reference))
                if str(exc):
                    logger.error(str(exc))

        return result
开发者ID:robertmrk,项目名称:conan,代码行数:35,代码来源:search.py

示例5: complete_build_flow_test

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def complete_build_flow_test(self):
        """In local user folder"""
        client = TestClient()
        command = os.sep.join([".", "bin", "say_hello"])

        for install, lang, static in [("install", 0, True),
                                      ("install -o language=1", 1, True),
                                      ("install -o language=1 -o static=False", 1, False),
                                      ("install -o static=False", 0, False)]:
            dll_export = client.default_compiler_visual_studio and not static
            files = cpp_hello_conan_files("Hello0", "0.1", dll_export=dll_export)
            client.save(files)
            client.run(install)
            time.sleep(1)  # necessary so the conaninfo.txt is flushed to disc
            client.run('build')
            client.runner(command, client.current_folder)
            msg = "Hello" if lang == 0 else "Hola"
            self.assertIn("%s Hello0" % msg, client.user_io.out)
            conan_info_path = os.path.join(client.current_folder, CONANINFO)
            conan_info = ConanInfo.loads(load(conan_info_path))
            self.assertTrue(conan_info.full_options.language == lang)
            if static:
                self.assertTrue(conan_info.full_options.static)
            else:
                self.assertFalse(conan_info.full_options.static)
开发者ID:samarjeet,项目名称:conan,代码行数:27,代码来源:basic_build_test.py

示例6: search_test

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def search_test(self):
        # Upload a conan1
        conan_name1 = "HelloOnly/[email protected]_user/testing"
        conan_reference1 = ConanFileReference.loads(conan_name1)
        self._upload_recipe(conan_reference1)

        # Upload a package
        conan_info = """[settings]
    arch=x86_64
    compiler=gcc
    os=Linux
[options]
    386=False
[requires]
    Hello
    Bye/2.9
    Say/[email protected]/testing
    Chat/[email protected]/testing:SHA_ABC
"""
        package_reference = PackageReference(conan_reference1, "1F23223EFDA")
        self._upload_package(package_reference, {CONANINFO: conan_info})

        # Upload a conan2
        conan_name2 = "helloonlyToo/[email protected]_user/stable"
        conan_reference2 = ConanFileReference.loads(conan_name2)
        self._upload_recipe(conan_reference2)

        # Get the info about this ConanFileReference
        info = self.api.search_packages(conan_reference1, None)
        self.assertEqual(ConanInfo.loads(conan_info).serialize_min(), info["1F23223EFDA"])

        # Search packages
        results = self.api.search("HelloOnly*", ignorecase=False)

        self.assertEqual(results, [conan_reference1])
开发者ID:nesono,项目名称:conan,代码行数:37,代码来源:rest_api_test.py

示例7: test_conaninfo_filtered

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def test_conaninfo_filtered(self):
        client = TestClient()
        # Try injecting some package level ENV in the install, but without priority
        self._export(client, "A", [], {}, {"VAR1": "900", "VAR2": "23", "VAR3": "-23"})
        self._export(client, "B", ["A"], {}, {"VAR1": "800", "VAR2": "24"})
        self._export(client, "B2", ["A"], {}, {"VAR1": "800_2", "VAR2": "24_2"})
        self._export(client, "C", ["B", "B2"], {"VAR3": "bestvalue"}, {"VAR1": "700"})

        def load_conaninfo(lib):
            # Read the LIB_A conaninfo
            packages_path = client.client_cache.packages(ConanFileReference.loads("LIB_%s/[email protected]/stable" % lib))
            package_path = os.path.join(packages_path, os.listdir(packages_path)[0])
            info = ConanInfo.loads(load(os.path.join(package_path, CONANINFO)))
            return info

        # Test "A" conaninfo, should filter the FAKE_LIB
        client.save({"conanfile.py": reuse})
        client.run("install . --build missing -e LIB_A:VAR3=override "
                   "-e GLOBAL=99 -e FAKE_LIB:VAR1=-90 -e LIB_B:VAR2=222 "
                   "-e LIB_B2:NEWVAR=VALUE -e VAR3=[newappend]")

        info = load_conaninfo("A")
        self.assertEquals(info.env_values.env_dicts("LIB_A"), ({"VAR3": "override", "GLOBAL": "99"}, {}))
        self.assertEquals(info.env_values.env_dicts(""), ({'GLOBAL': '99'}, {'VAR3': ['newappend']}))

        info = load_conaninfo("B")
        self.assertEquals(info.env_values.env_dicts("LIB_A"), ({'GLOBAL': '99', 'VAR3': "override"},
                                                               {'VAR2': ['23'], 'VAR1': ['900']}))

        self.assertEquals(info.env_values.env_dicts("LIB_B"), ({'GLOBAL': '99', "VAR2": "222"},
                                                               {'VAR3': ['newappend', '-23'], 'VAR1': ["900"]}))

        info = load_conaninfo("B2")
        self.assertEquals(info.env_values.env_dicts("LIB_A"), ({'GLOBAL': '99', 'VAR3': 'override'},
                                                               {'VAR2': ['23'], 'VAR1': ['900']}))

        self.assertEquals(info.env_values.env_dicts("LIB_B2"), ({'GLOBAL': '99', 'NEWVAR': "VALUE"},
                                                                {'VAR2': ['23'], 'VAR1': ['900'],
                                                                 'VAR3': ['newappend', '-23']}))

        info = load_conaninfo("C")
        self.assertEquals(info.env_values.env_dicts("LIB_B2"), ({'GLOBAL': '99', 'NEWVAR': "VALUE"},
                                                                {'VAR3': ['newappend', '-23'],
                                                                 'VAR1': ['800', '800_2', '900'],
                                                                 'VAR2': ['24', '24_2', '23']}))
        self.assertEquals(info.env_values.env_dicts("LIB_C"), ({'GLOBAL': '99'},
                                                               {'VAR2': ['24', '24_2', '23'],
                                                                'VAR1': ['800', '800_2', '900'],
                                                                'VAR3': ['newappend', "-23"]}))

        # Now check the info for the project
        info = ConanInfo.loads(load(os.path.join(client.current_folder, CONANINFO)))
        self.assertEquals(info.env_values.env_dicts("PROJECT"), ({'GLOBAL': '99'},
                                                                 {'VAR2': ['24', '24_2', '23'],
                                                                  'VAR1': ['700', '800', '800_2', '900'],
                                                                  'VAR3': ['newappend', 'bestvalue']}))
开发者ID:nesono,项目名称:conan,代码行数:58,代码来源:conan_env_test.py

示例8: settings_as_a_str_test

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def settings_as_a_str_test(self):
        content = """
from conans import ConanFile

class SayConan(ConanFile):
    name = "Say"
    version = "0.1"
    settings = "os"
"""
        self.client.save({CONANFILE: content})
        self.client.run("install -s os=Windows --build missing")
        # Now read the conaninfo and verify that settings applied is only os and value is windows
        conan_info = ConanInfo.loads(load(os.path.join(self.client.current_folder, CONANINFO)))
        self.assertEquals(conan_info.settings.os, "Windows")

        self.client.run("install -s os=Linux --build missing")
        # Now read the conaninfo and verify that settings applied is only os and value is windows
        conan_info = ConanInfo.loads(load(os.path.join(self.client.current_folder, CONANINFO)))
        self.assertEquals(conan_info.settings.os, "Linux")
开发者ID:JustgeekDE,项目名称:conan,代码行数:21,代码来源:other_settings_test.py

示例9: test_serialize

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
 def test_serialize(self):
     info = ConanInfo.loads(info_text)
     min_serial = info.serialize_min()
     expected = {'full_requires':
                 ['bzip2/[email protected]/stable:c6c01ee5ea2cf4af63e7b83b722b0a2d90640641',
                  'zlib/[email protected]/stable:2dec3996ef8de7edb0304eaf4efdd96a0477d3a3'],
                 'options': {'shared': 'False', 'fPIC': 'True', 'header_only': 'False'},
                 'settings': {'arch': 'x86_64', 'compiler.libcxx': 'libstdc++11',
                              'compiler.version': '5.2', 'os': 'Linux',
                              'build_type': 'Debug', 'compiler': 'gcc'}}
     self.assertEquals(min_serial, expected)
开发者ID:lasote,项目名称:conan,代码行数:13,代码来源:info_test.py

示例10: search_test

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def search_test(self):
        # Upload a conan1
        conan_name1 = "HelloOnly/[email protected]_user/testing"
        conan_reference1 = ConanFileReference.loads(conan_name1)
        self._upload_conan(conan_reference1)

        # Upload an package
        conan_info = """[settings]
    arch: x86_64
    compiler: gcc
    os: Linux
[options]
    386: False
[requires]
    Hello
    Bye/2.9
    Say/[email protected]/testing
    Chat/[email protected]/testing:SHA_ABC
"""
        package_reference = PackageReference(conan_reference1, "1F23223EFDA")
        self._upload_package(package_reference, {CONANINFO: conan_info})

        # Upload a conan2
        conan_name2 = "helloonlyToo/[email protected]_user/stable"
        conan_reference2 = ConanFileReference.loads(conan_name2)
        self._upload_conan(conan_reference2)

        # Get the info about this ConanFileReference
        info = self.api.search("helloonly*")
        expected_info1 = {"1F23223EFDA": ConanInfo.loads(conan_info)}
        expected_info2 = {}
        self.assertEqual(expected_info1, info[conan_reference1])
        self.assertEqual(expected_info2, info[conan_reference2])

        # Get the info about this ConanFileReference
        info = self.api.search("HelloOnly*", ignorecase=False)
        expected_info = {"1F23223EFDA": ConanInfo.loads(conan_info)}
        self.assertEqual({conan_reference1: expected_info}, info)
开发者ID:KindDragon,项目名称:conan,代码行数:40,代码来源:rest_api_test.py

示例11: settings_as_a_dict_conanfile_test

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def settings_as_a_dict_conanfile_test(self):
        """Declare settings as a dict"""
        # Now with conanfile as a dict
        content = """
from conans import ConanFile

class SayConan(ConanFile):
    name = "Say"
    version = "0.1"
    settings = {"os": ["Windows"], "arch": ["x86_64"]}
"""
        self.client.save({CONANFILE: content})
        self.client.run("install -s os=Windows --build missing")
        conan_info = ConanInfo.loads(load(os.path.join(self.client.current_folder, CONANINFO)))
        self.assertEquals(conan_info.settings.os,  "Windows")
        self.assertEquals(conan_info.settings.fields, ["arch", "os"])
开发者ID:JustgeekDE,项目名称:conan,代码行数:18,代码来源:other_settings_test.py

示例12: download_packages

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
 def download_packages(self, reference, package_ids):
     assert(isinstance(package_ids, list))
     remote, _ = self._get_remote(reference)
     conanfile_path = self._client_cache.conanfile(reference)
     if not os.path.exists(conanfile_path):
         raise Exception("Download recipe first")
     conanfile = load_conanfile_class(conanfile_path)
     # FIXME: This is a hack to provide a info object in case it fails and raise_package_not_found_error doesnt fail
     conanfile.info = ConanInfo.loads("")
     short_paths = conanfile.short_paths
     self._registry.set_ref(reference, remote)
     output = ScopedOutput(str(reference), self._out)
     for package_id in package_ids:
         package_ref = PackageReference(reference, package_id)
         package_folder = self._client_cache.package(package_ref, short_paths=short_paths)
         self._out.info("Downloading %s" % str(package_ref))
         self._remote_manager.get_package(conanfile, package_ref, package_folder, remote, output, self._recorder)
开发者ID:19317362,项目名称:conan,代码行数:19,代码来源:proxy.py

示例13: install_and_get_info

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
        def install_and_get_info(package_id_text):
            self.client.run("remove * -f")
            self._export("Hello", "1.2.0", package_id_text=package_id_text,
                         channel="user/testing",
                         settings='"os", "os_build", "arch", "arch_build"')
            self.client.run('install Hello/[email protected]/testing '
                            ' -s os="Windows" '
                            ' -s os_build="Linux"'
                            ' -s arch="x86_64"'
                            ' -s arch_build="x86"'
                            ' --build missing')

            ref = ConanFileReference.loads("Hello/[email protected]/testing")
            pkg = os.listdir(self.client.client_cache.packages(ref))
            pid = PackageReference(ref, pkg[0])
            pkg_folder = self.client.client_cache.package(pid)
            return ConanInfo.loads(load(os.path.join(pkg_folder, CONANINFO)))
开发者ID:19317362,项目名称:conan,代码行数:19,代码来源:package_id_test.py

示例14: get_package_info

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
    def get_package_info(self, package_reference):
        """Gets a ConanInfo file from a package"""

        url = "%s/conans/%s/packages/%s/download_urls" % (self._remote_api_url,
                                                          "/".join(package_reference.conan),
                                                          package_reference.package_id)
        urls = self._get_json(url)
        if not urls:
            raise NotFoundException("Package not found!")

        if CONANINFO not in urls:
            raise NotFoundException("Package %s doesn't have the %s file!" % (package_reference,
                                                                              CONANINFO))
        # Get the info (in memory)
        contents = self.download_files({CONANINFO: urls[CONANINFO]})
        # Unroll generator and decode shas (plain text)
        contents = {key: decode_text(value) for key, value in dict(contents).items()}
        return ConanInfo.loads(contents[CONANINFO])
开发者ID:nesono,项目名称:conan,代码行数:20,代码来源:rest_client.py

示例15: _build

# 需要导入模块: from conans.model.info import ConanInfo [as 别名]
# 或者: from conans.model.info.ConanInfo import loads [as 别名]
 def _build(self, cmd, static, pure_c, use_cmake, lang):
     dll_export = self.client.default_compiler_visual_studio and not static
     files = cpp_hello_conan_files("Hello0", "0.1", dll_export=dll_export,
                                   pure_c=pure_c, use_cmake=use_cmake)
     self.client.save(files, clean_first=True)
     self.client.run(cmd)
     time.sleep(1)  # necessary so the conaninfo.txt is flushed to disc
     self.client.run('build')
     ld_path = ("LD_LIBRARY_PATH=$(pwd)"
                if not static and not platform.system() == "Windows" else "")
     self.client.runner("%s %s" % (ld_path, self.command), cwd=self.client.current_folder)
     msg = "Hello" if lang == 0 else "Hola"
     self.assertIn("%s Hello0" % msg, self.client.user_io.out)
     conan_info_path = os.path.join(self.client.current_folder, CONANINFO)
     conan_info = ConanInfo.loads(load(conan_info_path))
     self.assertTrue(conan_info.full_options.language == lang)
     if static:
         self.assertTrue(conan_info.full_options.static)
     else:
         self.assertFalse(conan_info.full_options.static)
开发者ID:robertmrk,项目名称:conan,代码行数:22,代码来源:basic_build_test.py


注:本文中的conans.model.info.ConanInfo.loads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。