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


Python settings.Settings类代码示例

本文整理汇总了Python中conans.model.settings.Settings的典型用法代码示例。如果您正苦于以下问题:Python Settings类的具体用法?Python Settings怎么用?Python Settings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: basic_test

 def basic_test(self):
     s = Settings({"os": ["Windows", "Linux"]})
     s.os = "Windows"
     with self.assertRaises(ConanException) as cm:
         self.sut.compiler = "kk"
     self.assertEqual(str(cm.exception),
                      bad_value_msg("settings.compiler", "kk", "['Visual Studio', 'gcc']"))
开发者ID:19317362,项目名称:conan,代码行数:7,代码来源:settings_test.py

示例2: test_clean_sh_path

    def test_clean_sh_path(self):

        if platform.system() != "Windows":
            return

        os.environ["PATH"] = os.environ.get("PATH", "") + os.pathsep + self.tempdir
        save(os.path.join(self.tempdir, "sh.exe"), "Fake sh")
        conanfile = ConanFileMock()
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        conanfile.settings = settings

        cmake = CMake(conanfile)
        cmake.configure()
        self.assertIn(self.tempdir, conanfile.path)

        cmake.generator = "MinGW Makefiles"
        cmake.configure()
        self.assertNotIn(self.tempdir, conanfile.path)

        # Automatic gcc
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "gcc"
        settings.compiler.version = "5.4"
        settings.arch = "x86"
        conanfile.settings = settings

        cmake = CMake(conanfile)
        cmake.configure()
        self.assertNotIn(self.tempdir, conanfile.path)
开发者ID:nesono,项目名称:conan,代码行数:34,代码来源:cmake_test.py

示例3: test_none__sub_subsetting

    def test_none__sub_subsetting(self):
        yml = """os:
    None:
        subsystem: [None, cygwin]
    Windows:
"""
        with self.assertRaisesRegexp(ConanException,
                                     "settings.yml: None setting can't have subsettings"):
            Settings.loads(yml)
开发者ID:19317362,项目名称:conan,代码行数:9,代码来源:settings_test.py

示例4: test_os_split

    def test_os_split(self):
        settings = Settings.loads("""os:
    Windows:
    Linux:
    Macos:
        version: [1, 2]
    Android:
""")
        other_settings = Settings.loads("os: [Windows, Linux]")
        settings.os = "Windows"
        other_settings.os = "Windows"
        self.assertEqual(settings.values.sha, other_settings.values.sha)
开发者ID:19317362,项目名称:conan,代码行数:12,代码来源:settings_test.py

示例5: settings

 def settings(self):
     """Returns {setting: [value, ...]} defining all the possible
        settings and their values"""
     if not self._settings:
         if not os.path.exists(self.settings_path):
             save(self.settings_path, default_settings_yml)
             settings = Settings.loads(default_settings_yml)
         else:
             content = load(self.settings_path)
             settings = Settings.loads(content)
         settings.values = self.conan_config.settings_defaults
         self._settings = settings
     return self._settings
开发者ID:WimK,项目名称:conan,代码行数:13,代码来源:paths.py

示例6: settings

 def settings(self):
     """Returns {setting: [value, ...]} defining all the possible
        settings and their values"""
     if not self._settings:
         # TODO: Read default environment settings
         if not os.path.exists(self.settings_path):
             save(self.settings_path, normalize(default_settings_yml))
             settings = Settings.loads(default_settings_yml)
         else:
             content = load(self.settings_path)
             settings = Settings.loads(content)
         self.conan_config.settings_defaults(settings)
         self._settings = settings
     return self._settings
开发者ID:nesono,项目名称:conan,代码行数:14,代码来源:client_cache.py

示例7: test_none_value

 def test_none_value(self):
     yml = "os: [None, Windows]"
     settings = Settings.loads(yml)
     # Same sha as if settings were empty
     self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
     settings.validate()
     self.assertTrue(settings.os == None)
     self.assertEqual("", settings.values.dumps())
     settings.os = "None"
     self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
     settings.validate()
     self.assertTrue(settings.os == "None")
     self.assertEqual("os=None", settings.values.dumps())
     settings.os = "Windows"
     self.assertTrue(settings.os == "Windows")
     self.assertEqual("os=Windows", settings.values.dumps())
开发者ID:19317362,项目名称:conan,代码行数:16,代码来源:settings_test.py

示例8: vcvars_constrained_test

    def vcvars_constrained_test(self):
        text = """os: [Windows]
compiler:
    Visual Studio:
        version: ["14"]
        """
        settings = Settings.loads(text)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        with self.assertRaisesRegexp(ConanException,
                                     "compiler.version setting required for vcvars not defined"):
            tools.vcvars_command(settings)

        new_out = StringIO()
        tools.set_global_instances(ConanOutput(new_out), None)
        settings.compiler.version = "14"
        with tools.environment_append({"vs140comntools": "path/to/fake"}):
            tools.vcvars_command(settings)
            with tools.environment_append({"VisualStudioVersion": "12"}):
                with self.assertRaisesRegexp(ConanException,
                                             "Error, Visual environment already set to 12"):
                    tools.vcvars_command(settings)

            with tools.environment_append({"VisualStudioVersion": "12"}):
                # Not raising
                tools.vcvars_command(settings, force=True)
开发者ID:19317362,项目名称:conan,代码行数:26,代码来源:tools_test.py

示例9: test_shared

    def test_shared(self):
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        settings.os = "Windows"

        conan_file = ConanFileMock(shared=True)
        conan_file.settings = settings
        cmake = CMake(conan_file)

        self.assertEquals(cmake.definitions["BUILD_SHARED_LIBS"], "ON")

        conan_file = ConanFileMock(shared=False)
        conan_file.settings = settings
        cmake = CMake(conan_file)

        self.assertEquals(cmake.definitions["BUILD_SHARED_LIBS"], "OFF")

        conan_file = ConanFileMock(shared=None)
        conan_file.settings = settings
        cmake = CMake(conan_file)

        self.assertNotIn("BUILD_SHARED_LIBS", cmake.definitions)
开发者ID:nesono,项目名称:conan,代码行数:25,代码来源:cmake_test.py

示例10: test_deprecated_behaviour

    def test_deprecated_behaviour(self):
        """"Remove when deprecate the old settings parameter to CMake and conanfile to configure/build/test"""
        settings = Settings.loads(default_settings_yml)
        settings.os = "Windows"
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"
        settings.os = "Windows"

        dot_dir = "." if sys.platform == 'win32' else "'.'"

        cross = "-DCMAKE_SYSTEM_NAME=\"Windows\" " if platform.system() != "Windows" else ""

        conan_file = ConanFileMock()
        conan_file.settings = settings
        cmake = CMake(settings)
        cmake.configure(conan_file)
        cores = '-DCONAN_CXX_FLAGS="/MP{0}" -DCONAN_C_FLAGS="/MP{0}" '.format(tools.cpu_count())
        self.assertEqual('cd {0} && cmake -G "Visual Studio 12 2013" {1}-DCONAN_EXPORTED="1" '
                         '-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" {2}'
                         '-Wno-dev {0}'.format(dot_dir, cross, cores),
                         conan_file.command)

        cmake.build(conan_file)
        self.assertEqual('cmake --build %s' % dot_dir, conan_file.command)
        cmake.test()
        self.assertEqual('cmake --build %s %s' % (dot_dir, CMakeTest.scape('--target RUN_TESTS')), conan_file.command)
开发者ID:nesono,项目名称:conan,代码行数:27,代码来源:cmake_test.py

示例11: test_arch_override

    def test_arch_override(self):
        if platform.system() != "Windows":
            return
        settings = Settings.loads(default_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'mips64'

        command = tools.vcvars_command(settings, arch='x86')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('x86', command)

        command = tools.vcvars_command(settings, arch='x86_64')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('amd64', command)

        command = tools.vcvars_command(settings, arch='armv7')
        self.assertIn('vcvarsall.bat', command)
        self.assertNotIn('arm64', command)
        self.assertIn('arm', command)

        command = tools.vcvars_command(settings, arch='armv8')
        self.assertIn('vcvarsall.bat', command)
        self.assertIn('arm64', command)

        with self.assertRaises(ConanException):
            tools.vcvars_command(settings, arch='mips')
开发者ID:19317362,项目名称:conan,代码行数:27,代码来源:vcvars_arch_test.py

示例12: loads_default_test

    def loads_default_test(self):
        settings = Settings.loads(default_settings_yml)
        settings.compiler = "Visual Studio"
        settings.compiler.version = "12"
        settings.arch = "x86"

        cmake = CMake(settings)
        self.assertEqual('-G "Visual Studio 12"   -DCONAN_COMPILER="Visual Studio" '
                         '-DCONAN_COMPILER_VERSION="12" -Wno-dev', cmake.command_line)
        self.assertEqual('', cmake.build_config)
        settings.build_type = "Debug"
        self.assertEqual('-G "Visual Studio 12"   -DCONAN_COMPILER="Visual Studio" '
                         '-DCONAN_COMPILER_VERSION="12" -Wno-dev', cmake.command_line)
        self.assertEqual('--config Debug', cmake.build_config)

        settings.arch = "x86_64"
        self.assertEqual('-G "Visual Studio 12 Win64"   -DCONAN_COMPILER="Visual Studio" '
                         '-DCONAN_COMPILER_VERSION="12" -Wno-dev', cmake.command_line)

        settings.os = "Windows"
        settings.compiler = "gcc"
        settings.compiler.version = "4.8"
        self.assertEqual('-G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug  -DCONAN_COMPILER="gcc" '
                         '-DCONAN_COMPILER_VERSION="4.8" -Wno-dev', cmake.command_line)

        settings.os = "Linux"
        settings.arch = "x86"
        self.assertEqual('-G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug  -DCONAN_COMPILER="gcc" '
                         '-DCONAN_COMPILER_VERSION="4.8" -DCONAN_CXX_FLAGS=-m32 '
                         '-DCONAN_SHARED_LINK_FLAGS=-m32 -DCONAN_C_FLAGS=-m32 -Wno-dev',
                         cmake.command_line)
开发者ID:samarjeet,项目名称:conan,代码行数:31,代码来源:cmake_test.py

示例13: test_invalid

    def test_invalid(self):
        if platform.system() != "Windows":
            return

        fake_settings_yml = """
        os:
            WindowsStore:
                version: ["666"]
        arch: [x86]
        compiler:
            Visual Studio:
                runtime: [MD, MT, MTd, MDd]
                version: ["8", "9", "10", "11", "12", "14", "15"]

        build_type: [None, Debug, Release]
        """

        settings = Settings.loads(fake_settings_yml)
        settings.compiler = 'Visual Studio'
        settings.compiler.version = '14'
        settings.arch = 'x86'
        settings.os = 'WindowsStore'
        settings.os.version = '666'

        with self.assertRaises(ConanException):
            tools.vcvars_command(settings)
开发者ID:19317362,项目名称:conan,代码行数:26,代码来源:vcvars_store_test.py

示例14: setUp

 def setUp(self):
     data = {"compiler": {
                         "Visual Studio": {
                                          "version": ["10", "11", "12"],
                                          "runtime": ["MD", "MT"]},
                         "gcc": {
                                "version": ["4.8", "4.9"],
                                "arch": {"x86": {"speed": ["A", "B"]},
                                         "x64": {"speed": ["C", "D"]}}}
                                },
             "os": ["Windows", "Linux"]}
     self.sut = Settings(data)
开发者ID:19317362,项目名称:conan,代码行数:12,代码来源:settings_test.py

示例15: test_none_subsetting

    def test_none_subsetting(self):
        yml = """os:
    None:
    Windows:
        subsystem: [None, cygwin]
"""
        settings = Settings.loads(yml)
        # Same sha as if settings were empty
        self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
        settings.validate()
        self.assertTrue(settings.os == None)
        self.assertEqual("", settings.values.dumps())
        settings.os = "None"
        self.assertEqual(settings.values.sha, Settings.loads("").values.sha)
        settings.validate()
        self.assertTrue(settings.os == "None")
        self.assertEqual("os=None", settings.values.dumps())
        settings.os = "Windows"
        self.assertTrue(settings.os.subsystem == None)
        self.assertEqual("os=Windows", settings.values.dumps())
        settings.os.subsystem = "cygwin"
        self.assertEqual("os=Windows\nos.subsystem=cygwin", settings.values.dumps())
开发者ID:19317362,项目名称:conan,代码行数:22,代码来源:settings_test.py


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