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


Python PackageReference.loads方法代码示例

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


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

示例1: _check_conaninfo

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def _check_conaninfo(self, client):
        # Check that conaninfo is correct
        ref_debug = PackageReference.loads("Pkg/[email protected]/channel:"
                                           "f3989dcba0ab50dc5ed9b40ede202bdd7b421f09")
        conaninfo = load(os.path.join(client.client_cache.package(ref_debug), "conaninfo.txt"))
        self.assertIn("os=Windows", conaninfo)
        self.assertIn("build_type=Debug", conaninfo)
        self.assertNotIn("Release", conaninfo)

        ref_release = PackageReference.loads("Pkg/[email protected]/channel:"
                                             "ab2e9f86b4109980930cdc685f4a320b359e7bb4")
        conaninfo = load(os.path.join(client.client_cache.package(ref_release), "conaninfo.txt"))
        self.assertIn("os=Windows", conaninfo)
        self.assertIn("build_type=Release", conaninfo)
        self.assertNotIn("Debug", conaninfo)

        ref_debug = PackageReference.loads("Pkg/[email protected]/channel:"
                                           "322de4b4a41f905f6b18f454ab5f498690b39c2a")
        conaninfo = load(os.path.join(client.client_cache.package(ref_debug), "conaninfo.txt"))
        self.assertIn("os=Linux", conaninfo)
        self.assertIn("build_type=Debug", conaninfo)
        self.assertNotIn("Release", conaninfo)

        ref_release = PackageReference.loads("Pkg/[email protected]/channel:"
                                             "24c3aa2d6c5929d53bd86b31e020c55d96b265c7")
        conaninfo = load(os.path.join(client.client_cache.package(ref_release), "conaninfo.txt"))
        self.assertIn("os=Linux", conaninfo)
        self.assertIn("build_type=Release", conaninfo)
        self.assertNotIn("Debug", conaninfo)
开发者ID:19317362,项目名称:conan,代码行数:31,代码来源:build_id_test.py

示例2: _check_conaninfo

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def _check_conaninfo(self, client):
        # Check that conaninfo is correct
        ref_debug = PackageReference.loads("Pkg/[email protected]/channel:"
                                           "5a67a79dbc25fd0fa149a0eb7a20715189a0d988")
        conaninfo = load(os.path.join(client.client_cache.package(ref_debug), "conaninfo.txt"))
        self.assertIn("build_type=Debug", conaninfo)
        self.assertNotIn("Release", conaninfo)

        ref_release = PackageReference.loads("Pkg/[email protected]/channel:"
                                             "4024617540c4f240a6a5e8911b0de9ef38a11a72")
        conaninfo = load(os.path.join(client.client_cache.package(ref_release), "conaninfo.txt"))
        self.assertIn("build_type=Release", conaninfo)
        self.assertNotIn("Debug", conaninfo)
开发者ID:nesono,项目名称:conan,代码行数:15,代码来源:build_id_test.py

示例3: _capture_verify_manifest

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def _capture_verify_manifest(self, reference, remote="local cache", folder=""):
        self.client.run("install %s --build missing --manifests %s" % (str(reference), folder))
        self.assertIn("Installed manifest for 'Hello/[email protected]/stable' from %s" % remote,
                      self.client.user_io.out)
        self.assertIn("Installed manifest for 'Hello/[email protected]/stable:"
                      "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' from %s" % remote,
                      self.client.user_io.out)

        real_folder = folder or ".conan_manifests"
        output_folder = os.path.join(self.client.current_folder, real_folder)
        paths = SimplePaths(output_folder)
        self.assertTrue(os.path.exists(paths.digestfile_conanfile(self.reference)))
        package_reference = PackageReference.loads("Hello/[email protected]/stable:"
                                                   "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        self.assertTrue(os.path.exists(paths.digestfile_package(package_reference)))

        # again should do nothing
        self.client.run("install %s --build missing --manifests %s"
                        % (str(self.reference), folder))
        self.assertNotIn("manifest", self.client.user_io.out)

        # now verify
        self.client.run("install %s --build missing --verify %s" % (str(self.reference), folder))
        self.assertIn("Manifest for 'Hello/[email protected]/stable': OK", self.client.user_io.out)
        self.assertIn("Manifest for '%s': OK" % str(package_reference), self.client.user_io.out)
开发者ID:nesono,项目名称:conan,代码行数:27,代码来源:manifest_validation_test.py

示例4: upload_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def upload_test(self):
        test_server = TestServer([],  # write permissions
                                 users={"lasote": "mypass"})  # exported users and passwords
        servers = {"default": test_server}
        client = TestClient(servers=servers, users={"default": [("lasote", "mypass")]})
        files = {"conanfile.py": base}
        client.save(files)
        client.run("export . lasote/channel")
        client.run("install lib/[email protected]/channel --build")
        client.run("upload lib/[email protected]/channel --all")
        client.run("remove lib/[email protected]/channel -f")
        client.run("search")
        self.assertIn("There are no packages", client.user_io.out)

        for command in ("install", "download"):
            client2 = TestClient(servers=servers, users={"default": [("lasote", "mypass")]})
            client2.run("%s lib/[email protected]/channel" % command)
            reference = ConanFileReference.loads("lib/[email protected]/channel")
            export_folder = client2.client_cache.export(reference)
            export_files = os.listdir(export_folder)
            self.assertNotIn('conan_export.tgz', export_files)
            package_ref = PackageReference.loads("lib/[email protected]/channel:"
                                                 "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
            package_folder = client2.client_cache.package(package_ref, short_paths=None)
            if platform.system() == "Windows":
                original_folder = client2.client_cache.package(package_ref)
                link = load(os.path.join(original_folder, ".conan_link"))
                self.assertEqual(link, package_folder)

            files = os.listdir(package_folder)
            self.assertIn("myfile.txt", files)
            self.assertIn("myfile2.txt", files)
            self.assertNotIn("conan_package.tgz", files)
开发者ID:19317362,项目名称:conan,代码行数:35,代码来源:path_limit_test.py

示例5: fail_test_package_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def fail_test_package_test(self):
        client = TestClient()
        conanfile = """
from conans import ConanFile

class HelloConan(ConanFile):
    name = "Hello"
    version = "0.1"
    exports = "*"

    def package(self):
        self.copy("*")
"""
        test_conanfile = """
from conans import ConanFile, CMake
import os

class HelloReuseConan(ConanFile):
    requires = "Hello/[email protected]/stable"

    def test(self):
        self.conanfile_directory
"""
        client.save({"conanfile.py": conanfile,
                     "FindXXX.cmake": "Hello FindCmake",
                     "test/conanfile.py": test_conanfile})
        client.run("test_package")
        ref = PackageReference.loads("Hello/[email protected]/stable:"
                                     "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        self.assertEqual("Hello FindCmake",
                         load(os.path.join(client.paths.package(ref), "FindXXX.cmake")))
        client.save({"FindXXX.cmake": "Bye FindCmake"})
        client.run("test_package")
        self.assertEqual("Bye FindCmake",
                         load(os.path.join(client.paths.package(ref), "FindXXX.cmake")))
开发者ID:nesono,项目名称:conan,代码行数:37,代码来源:conan_test_test.py

示例6: basic_disabled_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def basic_disabled_test(self):
        client = TestClient()
        base = '''
from conans import ConanFile

class ConanLib(ConanFile):
    short_paths = True
'''
        client.save({"conanfile.py": base})

        client.run("create . lib/[email protected]/channel")
        package_ref = PackageReference.loads("lib/[email protected]/channel:"
                                             "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        client.run("search")
        self.assertIn("lib/[email protected]/channel", client.user_io.out)
        client.run("search lib/[email protected]/channel")
        self.assertIn("Package_ID: 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9", client.user_io.out)

        if platform.system() == "Windows":
            conan_ref = ConanFileReference.loads("lib/[email protected]/channel")
            source_folder = client.client_cache.source(conan_ref)
            build_folder = client.client_cache.build(package_ref)
            package_folder = client.client_cache.package(package_ref)
            link_source = os.path.join(source_folder, ".conan_link")
            link_build = os.path.join(build_folder, ".conan_link")
            link_package = os.path.join(package_folder, ".conan_link")

            self.assertTrue(os.path.exists(link_source))
            self.assertTrue(os.path.exists(link_build))
            self.assertTrue(os.path.exists(link_package))
开发者ID:19317362,项目名称:conan,代码行数:32,代码来源:path_limit_test.py

示例7: package_files_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def package_files_test(self):
        if platform.system() == "Windows":
            return

        client = TestClient()
        conanfile = """
from conans import ConanFile
class TestConan(ConanFile):
    name = "Hello"
    version = "0.1"

    def package(self):
        self.copy("*", symlinks=True)
    """
        client.save({"recipe/conanfile.py": conanfile})
        file1 = os.path.join(client.current_folder, "file1.txt")
        file2 = os.path.join(client.current_folder, "version1/file2.txt")
        file11 = os.path.join(client.current_folder, "file1.txt.1")
        latest = os.path.join(client.current_folder, "latest")
        save(file1, "Hello1")
        os.symlink("file1.txt", file11)
        save(file2, "Hello2")
        os.symlink("version1", latest)
        client.run("export-pkg ./recipe Hello/[email protected]/stable")
        ref = PackageReference.loads("Hello/[email protected]/stable:"
                                     "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")

        self._check(client, ref, build=False)
开发者ID:19317362,项目名称:conan,代码行数:30,代码来源:symlinks_test.py

示例8: custom_settings_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def custom_settings_test(self):
        settings = """os:
    None:
    Windows:
        subsystem: [None, cygwin]
    Linux:
compiler: [gcc, visual]
"""
        client = TestClient()
        save(client.paths.settings_path, settings)
        save(client.paths.default_profile_path, "")
        conanfile = """from conans import ConanFile
class Pkg(ConanFile):
    settings = "os", "compiler"
"""
        client.save({"conanfile.py": conanfile})
        client.run("create . Pkg/[email protected]/testing -s compiler=gcc")
        self.assertIn("544c1d8c53e9d269737e68e00ec66716171d2704", client.out)
        client.run("search Pkg/[email protected]/testing")
        self.assertNotIn("os: None", client.out)
        package_reference = PackageReference.loads("Pkg/[email protected]/testing:544c1d8c53e9d269737e68e00ec66716171d2704")
        info_path = os.path.join(client.paths.package(package_reference), CONANINFO)
        info = load(info_path)
        self.assertNotIn("os", info)
        # Explicitly specifying None, put it in the conaninfo.txt, but does not affect the hash
        client.run("create . Pkg/[email protected]/testing -s compiler=gcc -s os=None")
        self.assertIn("544c1d8c53e9d269737e68e00ec66716171d2704", client.out)
        client.run("search Pkg/[email protected]/testing")
        self.assertIn("os: None", client.out)
        info = load(info_path)
        self.assertIn("os", info)
开发者ID:19317362,项目名称:conan,代码行数:33,代码来源:other_settings_test.py

示例9: failure_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def failure_test(self):

        base = '''
from conans import ConanFile
from conans.util.files import load, save
import os

class ConanLib(ConanFile):
    name = "lib"
    version = "0.1"
    short_paths = True
    exports = "*"
    generators = "cmake"

    def build(self):
        self.output.info("%s/%s" % (self.conanfile_directory, self.name))
        # print os.listdir(self.conanfile_directory)
        path = os.path.join(self.conanfile_directory, self.name)
        # print "PATH EXISTS ", os.path.exists(path)
        # print os.listdir(path)
        path = os.path.join(path, "myfile.txt")
        # print "PATH EXISTS ", os.path.exists(path)

    def package(self):
        self.copy("*.txt", keep_path=False)
'''

        client = TestClient()
        files = {"conanfile.py": base,
                 "lib/myfile.txt": "Hello world!"}
        client.save(files)
        client.run("export user/channel")
        client.run("install lib/[email protected]/channel --build")
        # print client.paths.store
        package_ref = PackageReference.loads("lib/[email protected]/channel:"
                                             "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        package_folder = client.client_cache.package(package_ref, short_paths=None)
        file1 = load(os.path.join(package_folder, "myfile.txt"))
        self.assertEqual("Hello world!", file1)

        client.run("install lib/[email protected]/channel --build")
        package_ref = PackageReference.loads("lib/[email protected]/channel:"
                                             "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        package_folder = client.client_cache.package(package_ref, short_paths=None)
        file1 = load(os.path.join(package_folder, "myfile.txt"))
        self.assertEqual("Hello world!", file1)
开发者ID:conan-io,项目名称:conan,代码行数:48,代码来源:path_limit_test.py

示例10: basic_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def basic_test(self):
        client = TestClient()
        base = '''
from conans import ConanFile
from conans.util.files import load, save
import os

class ConanLib(ConanFile):
    name = "lib"
    version = "0.1"
    short_paths = True

    def source(self):
        extra_path = "1/" * 108
        os.makedirs(extra_path)
        myfile = os.path.join(extra_path, "myfile.txt")
        # print("File length ", len(myfile))
        save(myfile, "Hello extra path length")

    def build(self):
        extra_path = "1/" * 108
        myfile = os.path.join(extra_path, "myfile2.txt")
        # print("File length ", len(myfile))
        save(myfile, "Hello2 extra path length")

    def package(self):
        self.copy("*.txt", keep_path=False)
'''

        files = {"conanfile.py": base}
        client.save(files)
        client.run("export user/channel")
        client.run("install lib/[email protected]/channel --build")
        package_ref = PackageReference.loads("lib/[email protected]/channel:"
                                             "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        package_folder = client.client_cache.package(package_ref)
        file1 = load(os.path.join(package_folder, "myfile.txt"))
        self.assertEqual("Hello extra path length", file1)
        file2 = load(os.path.join(package_folder, "myfile2.txt"))
        self.assertEqual("Hello2 extra path length", file2)

        if platform.system() == "Windows":
            conan_ref = ConanFileReference.loads("lib/[email protected]/channel")
            source_folder = client.client_cache.source(conan_ref)
            link_source = load(os.path.join(source_folder, ".conan_link"))
            self.assertTrue(os.path.exists(link_source))

            build_folder = client.client_cache.build(package_ref)
            link_build = load(os.path.join(build_folder, ".conan_link"))
            self.assertTrue(os.path.exists(link_build))

            client.run("remove lib* -f")
            self.assertFalse(os.path.exists(link_source))
            self.assertFalse(os.path.exists(link_build))
开发者ID:lasote,项目名称:conan,代码行数:56,代码来源:path_limit_test.py

示例11: test_corrupted_package

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def test_corrupted_package(self):
        self.client.run("install %s --build missing" % str(self.reference))
        package_reference = PackageReference.loads("Hello/[email protected]/stable:"
                                                   "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        package_path = self.client.paths.package(package_reference)
        file_path = os.path.join(package_path, "conaninfo.txt")
        save(file_path, load(file_path) + "RANDOM STRING")

        self.client.run("install %s --build missing --manifests" % str(self.reference),
                        ignore_error=True)
        self.assertIn("%s local cache package is corrupted" % str(package_reference),
                      self.client.user_io.out)
开发者ID:nesono,项目名称:conan,代码行数:14,代码来源:manifest_validation_test.py

示例12: conanfile_capture_verify_manifest_folder_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def conanfile_capture_verify_manifest_folder_test(self):
        files = {"conanfile.txt": "[requires]\nHello/[email protected]/stable"}
        self.client.save(files, clean_first=True)
        folder = "mymanifests"
        self._capture_verify_manifest(".", folder=folder)

        conanfile = """from conans import ConanFile
class ConanFileTest(ConanFile):
    name = "Hello2"
    version = "0.1"
"""
        client = TestClient(base_folder=self.client.base_folder)
        client.save({CONANFILE: conanfile})
        client.run("export lasote/stable")

        files = {"conanfile.txt": "[requires]\nHello2/[email protected]/stable\nHello/[email protected]/stable"}
        self.client.save(files)

        self.client.run("install . --build missing --manifests %s" % folder)

        remote = "local cache"
        package_reference = PackageReference.loads("Hello/[email protected]/stable:"
                                                   "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        self.assertIn("Manifest for 'Hello/[email protected]/stable': OK", self.client.user_io.out)
        self.assertIn("Manifest for '%s': OK" % str(package_reference), self.client.user_io.out)
        self.assertIn("Installed manifest for 'Hello2/[email protected]/stable' from %s" % remote,
                      self.client.user_io.out)
        self.assertIn("Installed manifest for 'Hello2/[email protected]/stable:"
                      "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9' from %s" % remote,
                      self.client.user_io.out)

        output_folder = os.path.join(self.client.current_folder, folder)
        paths = SimplePaths(output_folder)
        self.assertTrue(os.path.exists(paths.digestfile_conanfile(self.reference)))
        self.assertTrue(os.path.exists(paths.digestfile_package(package_reference)))
        package_reference = PackageReference.loads("Hello2/[email protected]/stable:"
                                                   "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        self.assertTrue(os.path.exists(paths.digestfile_package(package_reference)))
开发者ID:nesono,项目名称:conan,代码行数:40,代码来源:manifest_validation_test.py

示例13: __init__

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def __init__(self, value_str, indirect=False):
        """ parse the input into fields name, version...
        """
        ref = PackageReference.loads(value_str)
        self.package = ref
        self.full_name = ref.conan.name
        self.full_version = ref.conan.version
        self.full_user = ref.conan.user
        self.full_channel = ref.conan.channel
        self.full_package_id = ref.package_id

        # sha values
        if indirect:
            self.unrelated_mode()
        else:
            self.semver()
开发者ID:19317362,项目名称:conan,代码行数:18,代码来源:info.py

示例14: basic_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def basic_test(self):
        if platform.system() == "Windows":
            return

        client = TestClient()
        client.save({"conanfile.py": conanfile,
                     "conanfile.txt": test_conanfile})
        client.run("export lasote/stable")
        client.run("install --build -f=conanfile.txt")
        ref = PackageReference.loads("Hello/[email protected]/stable:"
                                     "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")

        self._check(client, ref)

        client.run("install --build -f=conanfile.txt")
        self._check(client, ref)
开发者ID:conan-io,项目名称:conan,代码行数:18,代码来源:symlinks_test.py

示例15: build_test

# 需要导入模块: from conans.model.ref import PackageReference [as 别名]
# 或者: from conans.model.ref.PackageReference import loads [as 别名]
    def build_test(self):
        """ Try to reuse variables loaded from txt generator => deps_cpp_info
        """
        client = TestClient()
        client.save({CONANFILE: conanfile_dep})
        client.run("export lasote/testing")

        client.save({CONANFILE: conanfile_scope_env}, clean_first=True)
        client.run("install --build=missing")

        client.run("build")
        ref = PackageReference.loads("Hello/[email protected]/testing:"
                                     "5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9")
        package_folder = client.paths.package(ref).replace("\\", "/")
        self.assertIn("Project: INCLUDE PATH: %s/include" % package_folder, client.user_io.out)
        self.assertIn("Project: HELLO ROOT PATH: %s" % package_folder, client.user_io.out)
        self.assertIn("Project: HELLO INCLUDE PATHS: %s/include"
                      % package_folder, client.user_io.out)
开发者ID:conan-io,项目名称:conan,代码行数:20,代码来源:build_test.py


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