示例#1
0
    def _determine_qt_version(qt_version_or_spec: str, host: str, target: str,
                              arch: str) -> Version:
        def choose_highest(x: Optional[Version],
                           y: Optional[Version]) -> Optional[Version]:
            if x and y:
                return max(x, y)
            return x or y

        def opt_version_for_spec(ext: str,
                                 _spec: SimpleSpec) -> Optional[Version]:
            try:
                return MetadataFactory(ArchiveId("qt", host, target, ext),
                                       spec=_spec).getList().latest()
            except AqtException:
                return None

        try:
            return Version(qt_version_or_spec)
        except ValueError:
            pass
        try:
            spec = SimpleSpec(qt_version_or_spec)
        except ValueError as e:
            raise CliInputError(
                f"Invalid version or SimpleSpec: '{qt_version_or_spec}'\n" +
                SimpleSpec.usage()) from e
        else:
            version: Optional[Version] = None
            for ext in QtRepoProperty.possible_extensions_for_arch(arch):
                version = choose_highest(version,
                                         opt_version_for_spec(ext, spec))
            if not version:
                raise CliInputError(
                    f"No versions of Qt exist for spec={spec} with host={host}, target={target}, arch={arch}"
                )
            getLogger("aqt.installer").info(
                f"Resolved spec '{qt_version_or_spec}' to {version}")
            return version
示例#2
0
 def _arch_ext(self) -> str:
     ext = QtRepoProperty.extension_for_arch(self.arch, self.version >= Version("6.0.0"))
     return ("_" + ext) if ext else ""
示例#3
0
def test_list_possible_extension_for_arch(arch: str, expect: List[str]):
    exts = QtRepoProperty.possible_extensions_for_arch(arch)
    assert set(exts) == set(expect)
示例#4
0
def test_list_extension_for_arch(arch: str, version: Version, expect: str):
    ext = QtRepoProperty.extension_for_arch(arch, version >= Version("6.0.0"))
    assert ext == expect