コード例 #1
0
ファイル: version_test.py プロジェクト: 19317362/conan
    def simple_test(self):
        v1 = Version("1.2.3")
        self.assertTrue(v1 == "1.2.3")
        self.assertTrue(v1 > "1.1")
        self.assertTrue(v1 > None)
        self.assertTrue(v1 < "1.11")
        self.assertTrue(v1 > "1.2")
        self.assertTrue(v1 > "1.2.2.2")
        self.assertTrue(v1 < "1.2.3.2")
        self.assertEqual(v1.major(), "1.Y.Z")  # 1.X.Y
        self.assertEqual(v1.minor(), "1.2.Z")  # 1.2.Y
        self.assertEqual(v1.patch(), "1.2.3")
        self.assertEqual(v1.pre(), "1.2.3")
        self.assertEqual(v1.build, "")
        self.assertTrue(v1.compatible("1.X"))
        self.assertTrue(v1.compatible("1.2.Y"))
        self.assertFalse(v1.compatible("0.X"))
        v2 = v1.minor()
        self.assertTrue(v2.compatible("1.X"))
        self.assertTrue(v2.compatible("1.2.3.4"))
        self.assertFalse(v2.compatible("1.3.3.4"))

        v1 = Version("1.2.rc1")
        self.assertTrue(v1 < "1.2.0")
        self.assertFalse(v1 < "1.1.9")

        self.assertTrue(Version("1.2.1-dev") < Version("1.2.1"))
        self.assertTrue(Version("1.2.1-dev") < Version("1.2.2"))
        self.assertTrue(Version("1.2.1-dev") < Version("1.3"))
        self.assertTrue(Version("1.2.1-dev") < Version("1.3-alpha"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2.0"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2.alpha"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2-alpha"))
コード例 #2
0
ファイル: version_test.py プロジェクト: 19317362/conan
 def text_test(self):
     v1 = Version("master+build2")
     self.assertEqual(v1.major(), "master")
     self.assertEqual(v1.minor(), "master")
     self.assertEqual(v1.patch(), "master")
     self.assertEqual(v1.pre(), "master")
     self.assertEqual(v1.build, "build2")
     self.assertEqual(v1.stable(), "master")
コード例 #3
0
def get_best_installer(arch, threads, exception, version):

    if arch == "x86":
        arch = "i686"
        
    if exception == "dwarf2":
        exception = "dwarf"

    tools.download(repository_file, "repository.txt", overwrite=True, retry=10)

    installers = []
    with open("repository.txt") as f:
        for line in f.readlines():
            installers.append(Installer(line))

    version = Version(version)
    def params_match(i):
        return arch == i.arch and threads == i.threads and exception == i.exception

    def better_choice(i):
        return not best_match or i.version > best_match.version or (i.version == best_match.version and i.revision > best_match.revision)

    best_match = None
    for i in installers:
        if len(version.as_list) == 1:
            if i.version.major() == version.major() and params_match(i) and better_choice(i):
                best_match = i
        elif len(version.as_list) == 2:
            if i.version.major() == version.major() and i.version.minor() == version.minor() and params_match(i) and better_choice(i):
                best_match = i
        elif len(version.as_list) == 3:
            if i.version == version and params_match(i) and better_choice(i):
                best_match = i

    if not best_match:
        raise Exception("There is no suitable MinGW release for the requested features %s %s %s %s" % (arch, threads, exception, version))
    else:
        return best_match
コード例 #4
0
ファイル: version_test.py プロジェクト: KindDragon/conan
 def simple_test(self):
     v1 = Version("1.2.3")
     self.assertTrue(v1 == "1.2.3")
     self.assertTrue(v1 > "1.1")
     self.assertTrue(v1 > None)
     self.assertTrue(v1 < "1.11")
     self.assertEqual(v1.major(), "1.Y.Z")  # 1.X.Y
     self.assertEqual(v1.minor(), "1.2.Z")  # 1.2.Y
     self.assertTrue(v1.compatible("1.X"))
     self.assertTrue(v1.compatible("1.2.Y"))
     self.assertFalse(v1.compatible("0.X"))
     v2 = v1.minor()
     self.assertTrue(v2.compatible("1.X"))
     self.assertTrue(v2.compatible("1.2.3.4"))
     self.assertFalse(v2.compatible("1.3.3.4"))
コード例 #5
0
ファイル: version_test.py プロジェクト: 19317362/conan
    def patch_test(self):
        v1 = Version("1.2.3-alpha1+build2")
        self.assertEqual(v1.major(), "1.Y.Z")
        self.assertEqual(v1.minor(), "1.2.Z")
        self.assertEqual(v1.patch(), "1.2.3")
        self.assertEqual(v1.pre(), "1.2.3-alpha1")
        self.assertEqual(v1.build, "build2")
        self.assertEqual(v1.stable(), "1.Y.Z")

        v1 = Version("1.2.3+build2")
        self.assertEqual(v1.major(), "1.Y.Z")
        self.assertEqual(v1.minor(), "1.2.Z")
        self.assertEqual(v1.patch(), "1.2.3")
        self.assertEqual(v1.pre(), "1.2.3")
        self.assertEqual(v1.build, "build2")
        self.assertEqual(v1.stable(), "1.Y.Z")

        v1 = Version("0.2.3-alpha1+build2")
        self.assertEqual(v1.major(), "0.Y.Z")
        self.assertEqual(v1.minor(), "0.2.Z")
        self.assertEqual(v1.patch(), "0.2.3")
        self.assertEqual(v1.pre(), "0.2.3-alpha1")
        self.assertEqual(v1.build, "build2")
        self.assertEqual(v1.stable(), "0.2.3-alpha1+build2")
コード例 #6
0
def get_client_version():
    from conans.model.version import Version
    from conans import __version__ as client_version
    # It is a mess comparing dev versions, lets assume that the -dev is the further release
    return Version(client_version.replace("-dev", ""))
コード例 #7
0
ファイル: conanfile.py プロジェクト: yelu/conan-center-index
    def configure(self):
        self.output.warn("[DEPRECATED] Package 'cpp-taskflow/{0}' is being deprecated. Change yours to require 'taskflow/{0}' instead".format(self.version))

        compiler = str(self.settings.compiler)
        compiler_version = tools.Version(self.settings.compiler.version)
        min_req_cppstd = "17" if tools.Version(self.version) <= "2.2.0" else "14"

        if self.settings.compiler.cppstd:
            tools.check_min_cppstd(self, min_req_cppstd)
        else:
            self.output.warn("%s recipe lacks information about the %s compiler"
                             " standard version support" % (self.name, compiler))

        minimal_version = {
            "17": {
                "Visual Studio": "16",
                "gcc": "7.3",
                "clang": "6.0",
                "apple-clang": "10.0"
            },
            "14": {
                "Visual Studio": "15",
                "gcc": "5",
                "clang": "4.0",
                "apple-clang": "8.0"
            }
        }

        if compiler not in minimal_version[min_req_cppstd]:
            self.output.info("%s requires a compiler that supports at least C++%s" % (self.name, min_req_cppstd))
            return

        # Exclude compilers not supported by cpp-taskflow
        if compiler_version < minimal_version[min_req_cppstd][compiler]:
            raise ConanInvalidConfiguration("%s requires a compiler that supports"
                                            " at least C++%s. %s %s is not"
                                            " supported." % (self.name, min_req_cppstd, compiler, Version(self.settings.compiler.version.value)))
コード例 #8
0
 def configure(self):
     if self.settings.os == "Windows":
         if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version.value) <= "12":
             raise ConanInvalidConfiguration("Google Test {} does not support Visual Studio <= 12".format(self.version))
コード例 #9
0
    def run(self):
        client_version = get_client_version()

        if self._config_url:
            ConfigManager(self._conan_api,
                          self.printer).install(url=self._config_url,
                                                args=self._config_args)

        context = tools.no_op()
        compiler = self.settings.get("compiler", None)
        if not self._exclude_vcvars_precommand:
            if compiler == "Visual Studio" and "compiler.version" in self.settings:
                compiler_set = namedtuple("compiler", "version")(
                    self.settings["compiler.version"])
                mock_sets = namedtuple(
                    "mock_settings", "arch compiler get_safe")(
                        self.settings["arch"], compiler_set,
                        lambda x: self.settings.get(x, None))
                context = tools.vcvars(mock_sets)
        with context:
            self.printer.print_rule()
            self.printer.print_profile(tools.load(self._profile_abs_path))

            with self.printer.foldable_output("conan_create"):
                if client_version < Version("1.10.0"):
                    name, version, user, channel = self._reference
                else:
                    name, version, user, channel, _ = self._reference

                if self._build_policy:
                    self._build_policy = [] if self._build_policy == [
                        "all"
                    ] else self._build_policy
                # https://github.com/conan-io/conan-package-tools/issues/184
                with tools.environment_append({"_CONAN_CREATE_COMMAND_": "1"}):
                    params = {
                        "name": name,
                        "version": version,
                        "user": user,
                        "channel": channel,
                        "build_modes": self._build_policy,
                        "profile_name": self._profile_abs_path
                    }
                    self.printer.print_message("Calling 'conan create'")
                    self.printer.print_dict(params)
                    with tools.chdir(self._cwd):
                        if Version(client_version) >= "1.8.0":
                            from conans.errors import ConanInvalidConfiguration
                            exc_class = ConanInvalidConfiguration
                        else:
                            exc_class = None

                        try:
                            if client_version < Version("1.12.0"):
                                self._results = self._conan_api.create(
                                    self._conanfile,
                                    name=name,
                                    version=version,
                                    user=user,
                                    channel=channel,
                                    build_modes=self._build_policy,
                                    profile_name=self._profile_abs_path,
                                    test_folder=self._test_folder,
                                    not_export=self.skip_recipe_export,
                                    update=self._update_dependencies)
                            else:
                                self._results = self._conan_api.create(
                                    self._conanfile,
                                    name=name,
                                    version=version,
                                    user=user,
                                    channel=channel,
                                    build_modes=self._build_policy,
                                    profile_names=[self._profile_abs_path],
                                    test_folder=self._test_folder,
                                    not_export=self.skip_recipe_export,
                                    update=self._update_dependencies,
                                    lockfile=self._lockfile)
                        except exc_class as e:
                            self.printer.print_rule()
                            self.printer.print_message(
                                "Skipped configuration by the recipe: "
                                "%s" % str(e))
                            self.printer.print_rule()
                            return
                        for installed in self._results['installed']:
                            reference = installed["recipe"]["id"]
                            if client_version >= Version("1.10.0"):
                                reference = ConanFileReference.loads(reference)
                                reference = str(reference.copy_clear_rev())
                            if ((reference == str(self._reference)) or \
                               (reference in self._upload_dependencies) or \
                               ("all" in self._upload_dependencies)) and \
                               installed['packages']:
                                package_id = installed['packages'][0]['id']
                                if installed['packages'][0]["built"]:
                                    if "@" not in reference:
                                        reference += "@"
                                    if self._upload_only_recipe:
                                        self._uploader.upload_recipe(
                                            reference, self._upload)
                                    else:
                                        self._uploader.upload_packages(
                                            reference, self._upload,
                                            package_id)
                                else:
                                    self.printer.print_message(
                                        "Skipping upload for %s, "
                                        "it hasn't been built" % package_id)
コード例 #10
0
    def __init__(self,
                 profile_abs_path,
                 reference,
                 conan_api,
                 uploader,
                 exclude_vcvars_precommand=False,
                 build_policy=None,
                 runner=None,
                 cwd=None,
                 printer=None,
                 upload=False,
                 upload_only_recipe=None,
                 test_folder=None,
                 config_url=None,
                 config_args=None,
                 upload_dependencies=None,
                 conanfile=None,
                 skip_recipe_export=False,
                 update_dependencies=False,
                 lockfile=None):

        self.printer = printer or Printer()
        self._cwd = cwd or os.getcwd()
        self._uploader = uploader
        self._upload = upload
        self._conan_api = conan_api
        self._profile_abs_path = profile_abs_path
        self._reference = reference
        self._exclude_vcvars_precommand = exclude_vcvars_precommand
        self._build_policy = build_policy.split(",") if \
                             isinstance(build_policy, str) else \
                             build_policy
        self._runner = PrintRunner(runner or os.system, self.printer)
        self._test_folder = test_folder
        self._config_url = config_url
        self._config_args = config_args
        self._upload_only_recipe = upload_only_recipe
        self._conanfile = conanfile
        self._lockfile = lockfile
        self._upload_dependencies = upload_dependencies.split(",") if \
                                    isinstance(upload_dependencies, str) else \
                                    upload_dependencies
        self._upload_dependencies = self._upload_dependencies or []
        self.skip_recipe_export = skip_recipe_export
        self._update_dependencies = update_dependencies
        self._results = None

        patch_default_base_profile(conan_api, profile_abs_path)
        client_version = get_client_version()

        if client_version < Version("1.12.0"):
            cache = self._conan_api._client_cache
        elif client_version < Version("1.18.0"):
            cache = self._conan_api._cache
        else:
            if not conan_api.app:
                conan_api.create_app()
            cache = conan_api.app.cache

        self._profile = load_profile(profile_abs_path, cache)

        if isinstance(self._test_folder,
                      str) and self._test_folder.lower() == "false":
            self._test_folder = False
コード例 #11
0
    def _make_migrations(self, old_version):
        # ############### FILL THIS METHOD WITH THE REQUIRED ACTIONS ##############
        # VERSION 0.1
        if old_version is None:
            return
        if old_version < Version("1.5.0"):
            old_settings = """
# Only for cross building, 'os_build/arch_build' is the system that runs Conan
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS]
arch_build: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]

# Only for building cross compilation tools, 'os_target/arch_target' is the system for
# which the tools generate code
os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, Arduino]
arch_target: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]

# Rest of the settings are "host" settings:
# - For native building/cross building: Where the library/program will run.
# - For building cross compilation tools: Where the cross compiler will run.
os:
    Windows:
        subsystem: [None, cygwin, msys, msys2, wsl]
    WindowsStore:
        version: ["8.1", "10.0"]
    Linux:
    Macos:
    Android:
        api_level: ANY
    iOS:
        version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", "11.0"]
    watchOS:
        version: ["4.0"]
    tvOS:
        version: ["11.0"]
    FreeBSD:
    SunOS:
    Arduino:
        board: ANY
arch: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]
compiler:
    sun-cc:
        version: ["5.10", "5.11", "5.12", "5.13", "5.14"]
        threads: [None, posix]
        libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
    gcc:
        version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9",
                  "5", "5.1", "5.2", "5.3", "5.4", "5.5",
                  "6", "6.1", "6.2", "6.3", "6.4",
                  "7", "7.1", "7.2", "7.3",
                  "8", "8.1"]
        libcxx: [libstdc++, libstdc++11]
        threads: [None, posix, win32] #  Windows MinGW
        exception: [None, dwarf2, sjlj, seh] # Windows MinGW
    Visual Studio:
        runtime: [MD, MT, MTd, MDd]
        version: ["8", "9", "10", "11", "12", "14", "15"]
        toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp, v140, v140_xp, v140_clang_c2, LLVM-vs2014, LLVM-vs2014_xp, v141, v141_xp, v141_clang_c2]
    clang:
        version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", "5.0", "6.0", "7.0"]
        libcxx: [libstdc++, libstdc++11, libc++]
    apple-clang:
        version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1"]
        libcxx: [libstdc++, libc++]

build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20]
"""
            self._update_settings_yml(old_settings)

        if old_version < Version("1.0"):
            _migrate_lock_files(self.client_cache, self.out)

        if old_version < Version("0.25"):
            from conans.paths import DEFAULT_PROFILE_NAME
            default_profile_path = os.path.join(self.client_cache.conan_folder,
                                                PROFILES_FOLDER,
                                                DEFAULT_PROFILE_NAME)
            if not os.path.exists(default_profile_path):
                self.out.warn(
                    "Migration: Moving default settings from %s file to %s" %
                    (CONAN_CONF, DEFAULT_PROFILE_NAME))
                conf_path = os.path.join(self.client_cache.conan_folder,
                                         CONAN_CONF)

                migrate_to_default_profile(conf_path, default_profile_path)

                self.out.warn("Migration: export_source cache new layout")
                migrate_c_src_export_source(self.client_cache, self.out)
コード例 #12
0
 def configure(self):
     if conan_version < Version("1.21.0"):
         raise ConanInvalidConfiguration(
             "Conan version is lower than 1.21.0")