From c8793b3f065e05b2bd7415a598df210ecf992f56 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 14 Dec 2024 09:16:52 -0700 Subject: [PATCH 1/5] handle cases where extensions don't exist. for example with windows desktop 6.8.1 win64_msvc2022_arm64_cross_compiled both qtwebengine and qtpdf don't exist. --- aqt/archives.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/aqt/archives.py b/aqt/archives.py index 1727e84f..e89f6a8a 100644 --- a/aqt/archives.py +++ b/aqt/archives.py @@ -438,21 +438,33 @@ def _get_archives_base(self, name, target_packages): "online/qtsdkrepository", os_name, "extensions", ext, self._version_str(), arch ) extensions_xml_url = posixpath.join(extensions_target_folder, "Updates.xml") - extensions_xml_text = self._download_update_xml(extensions_xml_url) - update_xmls.append(UpdateXmls(extensions_target_folder, extensions_xml_text)) + # The extension may or may not exist for this version and arch. + try: + extensions_xml_text = self._download_update_xml(extensions_xml_url, True) + except ArchiveDownloadError: + # In case _download_update_xml ignores the hash and tries to get the url. + pass + if extensions_xml_text: + self.logger.info("Found extension {}".format(ext)) + update_xmls.append(UpdateXmls(extensions_target_folder, extensions_xml_text)) self._parse_update_xmls(update_xmls, target_packages) - def _download_update_xml(self, update_xml_path): + def _download_update_xml(self, update_xml_path, silent=False): """Hook for unit test.""" if not Settings.ignore_hash: try: xml_hash = get_hash(update_xml_path, Settings.hash_algorithm, self.timeout) except ChecksumDownloadFailure: - self.logger.warning( - "Failed to download checksum for the file 'Updates.xml'. This may happen on unofficial mirrors." - ) - xml_hash = None + if silent: + return None + else: + self.logger.warning( + "Failed to download checksum for the file '{}'. This may happen on unofficial mirrors.".format( + update_xml_path + ) + ) + xml_hash = None else: xml_hash = None return getUrl(posixpath.join(self.base, update_xml_path), self.timeout, xml_hash) From f70e5b8d6b8f470d377f8a5f6a7613dd05d57f7e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:34:04 -0700 Subject: [PATCH 2/5] for --long-modules assume extension doesn't exist on download error. --- aqt/metadata.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/aqt/metadata.py b/aqt/metadata.py index 25097853..dc6b2b2b 100644 --- a/aqt/metadata.py +++ b/aqt/metadata.py @@ -37,7 +37,7 @@ from semantic_version import Version as SemanticVersion from texttable import Texttable -from aqt.exceptions import ArchiveConnectionError, ArchiveDownloadError, ArchiveListError, CliInputError, EmptyMetadata +from aqt.exceptions import ArchiveConnectionError, ArchiveDownloadError, ArchiveListError, CliInputError, EmptyMetadata, ChecksumDownloadFailure from aqt.helper import Settings, get_hash, getUrl, xml_to_modules @@ -556,6 +556,11 @@ def is_in_wasm_range(host: str, version: Version) -> bool: def is_in_wasm_threaded_range(version: Version) -> bool: return version in SimpleSpec(">=6.5.0") + @staticmethod + def known_extensions(version: Version) -> List[str]: + if version >= Version("6.8.0"): + return ["qtpdf", "qtwebengine"] + return [] class MetadataFactory: """Retrieve metadata of Qt variations, versions, and descriptions from Qt site.""" @@ -930,8 +935,8 @@ def matches_arch(element: Element) -> bool: # Examples: extensions.qtwebengine.680.debug_information # extensions.qtwebengine.680.win64_msvc2022_64 ext_pattern = re.compile(r"^extensions\." + r"(?P[^.]+)\." + qt_ver_str + r"\." + arch + r"$") - if version >= Version("6.8.0"): - for ext in self.fetch_extensions(): + for ext in QtRepoProperty.known_extensions(version): + try: ext_meta = self._fetch_extension_metadata(self.archive_id.to_extension_folder(ext, qt_ver_str, arch)) for key, value in ext_meta.items(): ext_match = ext_pattern.match(key) @@ -939,6 +944,8 @@ def matches_arch(element: Element) -> bool: module = ext_match.group("module") if module is not None: m[module] = value + except (ChecksumDownloadFailure, ArchiveDownloadError): + pass return ModuleData(m) def fetch_modules_sde(self, cmd_type: str, version: Version) -> List[str]: From 6d944b4b80110570279e2720ca8d4725ed63f653 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:43:31 -0700 Subject: [PATCH 3/5] for --modules assume extension doesn't exist for download failures. --- aqt/metadata.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/aqt/metadata.py b/aqt/metadata.py index dc6b2b2b..e3941fa9 100644 --- a/aqt/metadata.py +++ b/aqt/metadata.py @@ -891,9 +891,19 @@ def to_module_arch(name: str) -> Tuple[Optional[str], Optional[str]]: module, _arch = to_module_arch(name) if _arch == arch: modules.add(cast(str, module)) - if version >= Version("6.8.0"): - for ext in self.fetch_extensions(): - modules.add(ext) + + ext_pattern = re.compile(r"^extensions\." + r"(?P[^.]+)\." + qt_ver_str + r"\." + arch + r"$") + for ext in QtRepoProperty.known_extensions(version): + try: + ext_meta = self._fetch_extension_metadata(self.archive_id.to_extension_folder(ext, qt_ver_str, arch)) + for key, value in ext_meta.items(): + ext_match = ext_pattern.match(key) + if ext_match is not None: + module = ext_match.group("module") + if module is not None: + modules.add(ext) + except (ChecksumDownloadFailure, ArchiveDownloadError): + pass return sorted(modules) @staticmethod From a49ca11548dc9e99e56cac1e81ba28b58a0d2557 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 14 Dec 2024 18:48:06 -0700 Subject: [PATCH 4/5] reformat with black --- aqt/metadata.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aqt/metadata.py b/aqt/metadata.py index e3941fa9..a00bea91 100644 --- a/aqt/metadata.py +++ b/aqt/metadata.py @@ -37,7 +37,14 @@ from semantic_version import Version as SemanticVersion from texttable import Texttable -from aqt.exceptions import ArchiveConnectionError, ArchiveDownloadError, ArchiveListError, CliInputError, EmptyMetadata, ChecksumDownloadFailure +from aqt.exceptions import ( + ArchiveConnectionError, + ArchiveDownloadError, + ArchiveListError, + CliInputError, + EmptyMetadata, + ChecksumDownloadFailure, +) from aqt.helper import Settings, get_hash, getUrl, xml_to_modules @@ -562,6 +569,7 @@ def known_extensions(version: Version) -> List[str]: return ["qtpdf", "qtwebengine"] return [] + class MetadataFactory: """Retrieve metadata of Qt variations, versions, and descriptions from Qt site.""" From 7d50defe7ec09eab8164633f06bfad9dfdb4ac0c Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 14 Dec 2024 19:01:04 -0700 Subject: [PATCH 5/5] fix flake8 regression that doesn't occur locally. --- aqt/metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aqt/metadata.py b/aqt/metadata.py index a00bea91..4e7eb87c 100644 --- a/aqt/metadata.py +++ b/aqt/metadata.py @@ -41,9 +41,9 @@ ArchiveConnectionError, ArchiveDownloadError, ArchiveListError, + ChecksumDownloadFailure, CliInputError, EmptyMetadata, - ChecksumDownloadFailure, ) from aqt.helper import Settings, get_hash, getUrl, xml_to_modules