Repository: miurahr/aqtinstall

Issue:
Change behavior of `--archives` so that it only affects the base module
Several modules for Qt, Docs, and Examples include archives that do not have the same name as the module. For example:
* Qt 6.2.1 for linux desktop includes the module `qtwaylandcompositor`, which consists of the archive `qtwayland`.
* Documentation for Qt 6.1.0 includes the module `qtlottie`, which consists of the archive `qtlottieanimation`. The archive is called `qtlottie` in most other places.

We already have some code that attempts to make sure that if the user has used both the `--archives` and `--modules` flags, the user should receive the archives that come from the requested archives:
https://github.com/miurahr/aqtinstall/blob/d63bbd146c6852b81caca72ab6abe9aa8c2962f2/aqt/installer.py#L269-L270

This approach will not install modules that include archives with a different name (like the examples listed above), and it won't generate an error message. I think that any user that experiences this situation will see it as a bug, rather than a misuse of `aqt`.

I would like to change the design of this feature, so that the `--archives` flag will only apply to the base Qt module (ie, the PackageUpdate called `qt.qt6.621.clang_64` in https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/qt6_621/Updates.xml), and to the `debug_info` module. We have already changed the design of `--noarchives` so that it only turns off the base Qt module; I think it makes sense to make `--archives` work the same way.

I think it should be simple to implement this in `aqt.archives.QtArchives._parse_update_xml()`. The QtArchives object recieves the list of desired archives as a parameter to `__init__`; it just needs to be told which modules include archives that need to be filtered.

Discussion:
ddalcino: ```
 _______________________________
< Happy Thanksgiving Everybody! >
 -------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
```

Patch:
diff --git a/aqt/archives.py b/aqt/archives.py
index c5c9286..d7bdff9 100644
--- a/aqt/archives.py
+++ b/aqt/archives.py
@@ -143,6 +143,7 @@ class QtArchives:
         self.base: str = posixpath.join(base, "online/qtsdkrepository")
         self.logger = getLogger("aqt.archives")
         self.archives: List[QtPackage] = []
+        self.subarchives: Optional[Iterable[str]] = subarchives
         self.mod_list: Iterable[str] = modules or []
         self.is_include_base_package: bool = is_include_base_package
         self.timeout = timeout
@@ -150,15 +151,21 @@ class QtArchives:
             self._get_archives()
         except ArchiveDownloadError as e:
             self.handle_missing_updates_xml(e)
-        should_install_all_archives = subarchives is None
-        if not should_install_all_archives:
-            self.archives = list(filter(lambda a: a.name in subarchives, self.archives))
 
     def handle_missing_updates_xml(self, e: ArchiveDownloadError):
         msg = f"Failed to locate XML data for Qt version '{self.version}'."
         help_msg = f"Please use 'aqt list-qt {self.os_name} {self.target}' to show versions available."
         raise ArchiveListError(msg, suggested_action=[help_msg]) from e
 
+    def should_filter_archives(self, package_name: str) -> bool:
+        """
+        This tells us, based on the PackageUpdate.Name property, whether or not the `self.subarchives`
+        list should be used to filter out archives that we are not interested in.
+
+        If `package_name` is a base module or a debug_info module, the `subarchives` list will apply to it.
+        """
+        return package_name in self._base_package_names() or "debug_info" in package_name
+
     def _version_str(self) -> str:
         return ("{0.major}{0.minor}" if self.version == Version("5.9.0") else "{0.major}{0.minor}{0.patch}").format(
             self.version
@@ -168,21 +175,31 @@ class QtArchives:
         ext = QtRepoProperty.extension_for_arch(self.arch, self.version >= Version("6.0.0"))
         return ("_" + ext) if ext else ""
 
-    def _base_target_package_name(self) -> str:
+    def _base_module_name(self) -> str:
+        """
+        This is the name for the base Qt module, whose PackageUpdate.Name property would be
+        'qt.123.gcc_64' or 'qt.qt1.123.gcc_64' for Qt 1.2.3, for architecture gcc_64.
+        """
         return "qt_base"
 
+    def _base_package_names(self) -> Iterable[str]:
+        """
+        This is a list of all potential PackageUpdate.Name properties for the base Qt module,
+        which would be 'qt.123.gcc_64' or 'qt.qt1.123.gcc_64' for Qt 1.2.3, for architecture gcc_64,
+        or 'qt.123.src' or 'qt.qt1.123.src' for the source module.
+        """
+        return (
+            f"qt.qt{self.version.major}.{self._version_str()}.{self.arch}",
+            f"qt.{self._version_str()}.{self.arch}",
+        )
+
     def _module_name_suffix(self, module: str) -> str:
         return f"{module}.{self.arch}"
 
     def _target_packages(self) -> ModuleToPackage:
         if self.all_extra:
             return ModuleToPackage({})
-        base_package = {
-            self._base_target_package_name(): [
-                f"qt.qt{self.version.major}.{self._version_str()}.{self.arch}",
-                f"qt.{self._version_str()}.{self.arch}",
-            ]
-        }
+        base_package = {self._base_module_name(): list(self._base_package_names())}
         target_packages = ModuleToPackage(base_package if self.is_include_base_package else {})
         if self.all_extra:
             return target_packages
@@ -228,6 +245,9 @@ class QtArchives:
             downloads_text = packageupdate.find("DownloadableArchives").text
             if not downloads_text:
                 continue
+            # If we asked for `--noarchives`, we don't want the base module
+            if not self.is_include_base_package and pkg_name in self._base_package_names():
+                continue
             # Need to filter archives to download when we want all extra modules
             if self.all_extra:
                 # Check platform
@@ -244,9 +264,12 @@ class QtArchives:
                 target_packages.remove_module_for_package(pkg_name)
             full_version = packageupdate.find("Version").text
             package_desc = packageupdate.find("Description").text
+            should_filter_archives: bool = self.subarchives and self.should_filter_archives(pkg_name)
 
             for archive in downloads_text.split(", "):
                 archive_name = archive.split("-", maxsplit=1)[0]
+                if should_filter_archives and archive_name not in self.subarchives:
+                    continue
                 package_url = posixpath.join(
                     # https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_5150/
                     archive_url,
@@ -276,7 +299,7 @@ class QtArchives:
         base_cmd = f"aqt list-qt {self.os_name} {self.target}"
         arch = f"Please use '{base_cmd} --arch {self.version}' to show architectures available."
         mods = f"Please use '{base_cmd} --modules {self.version} <arch>' to show modules available."
-        has_base_pkg: bool = self._base_target_package_name() in missing_modules
+        has_base_pkg: bool = self._base_module_name() in missing_modules
         has_non_base_pkg: bool = len(list(missing_modules)) > 1 or not has_base_pkg
         messages = []
         if has_base_pkg:
@@ -316,6 +339,7 @@ class SrcDocExamplesArchives(QtArchives):
         subarchives=None,
         modules=None,
         all_extra=False,
+        is_include_base_package: bool = True,
         timeout=(5, 5),
     ):
         self.flavor = flavor
@@ -332,14 +356,19 @@ class SrcDocExamplesArchives(QtArchives):
             subarchives=subarchives,
             modules=modules,
             all_extra=all_extra,
+            is_include_base_package=is_include_base_package,
             timeout=timeout,
         )
 
     def _arch_ext(self) -> str:
         return "_src_doc_examples"
 
-    def _base_target_package_name(self) -> str:
-        return self.flavor
+    def _base_module_name(self) -> str:
+        """
+        This is the name for the base Qt Src/Doc/Example module, whose PackageUpdate.Name
+        property would be 'qt.123.examples' or 'qt.qt1.123.examples' for Qt 1.2.3 examples.
+        """
+        return self.flavor  # src | doc | examples
 
     def _module_name_suffix(self, module: str) -> str:
         return f"{self.flavor}.{module}"
diff --git a/aqt/installer.py b/aqt/installer.py
index 102fc1e..e1441a7 100644
--- a/aqt/installer.py
+++ b/aqt/installer.py
@@ -850,7 +850,8 @@ class Cli:
         subparser.add_argument(
             "--archives",
             nargs="*",
-            help="Specify subset packages to install (Default: all standard and extra modules).",
+            help="Specify subset of archives to install. Affects the base module and the debug_info module. "
+            "(Default: all archives).",
         )
 
     def _set_common_arguments(self, subparser, *, is_legacy: bool, is_target_deprecated: bool = False):
diff --git a/ci/generate_azure_pipelines_matrices.py b/ci/generate_azure_pipelines_matrices.py
index fb99f33..6e0307c 100644
--- a/ci/generate_azure_pipelines_matrices.py
+++ b/ci/generate_azure_pipelines_matrices.py
@@ -33,6 +33,7 @@ class BuildJob:
         spec=None,
         mingw_variant: str = "",
         tool_options: Optional[Dict[str, str]] = None,
+        check_output_cmd: Optional[str] = None,
     ):
         self.command = command
         self.qt_version = qt_version
@@ -49,6 +50,7 @@ class BuildJob:
         # `steps.yml` assumes that qt_version is the highest version that satisfies spec
         self.spec = spec
         self.output_dir = output_dir
+        self.check_output_cmd = check_output_cmd
 
     def qt_bindir(self, *, sep='/') -> str:
         out_dir = f"$(Build.BinariesDirectory){sep}Qt" if not self.output_dir else self.output_dir
@@ -201,15 +203,23 @@ linux_build_jobs.extend(
             subarchives="qtbase qttools qt icu",
         ),
         BuildJob(
-            "install-src", "6.1.0", "linux", "desktop", "gcc_64", "gcc_64", subarchives="qtlottie"
+            "install-src", "6.1.0", "linux", "desktop", "gcc_64", "gcc_64", subarchives="qtlottie",
+            # Fail the job if this path does not exist:
+            check_output_cmd="ls -lh ./6.1.0/Src/qtlottie/",
         ),
+        # Should install the `qtlottie` module, even though the archive `qtlottieanimation` is not specified:
         BuildJob(
             "install-doc", "6.1.0", "linux", "desktop", "gcc_64", "gcc_64",
-            subarchives="qtdoc qtlottieanimation", module="qtlottie"
+            subarchives="qtdoc", module="qtlottie",
+            # Fail the job if these paths do not exist:
+            check_output_cmd="ls -lh ./Docs/Qt-6.1.0/qtdoc/ ./Docs/Qt-6.1.0/qtlottieanimation/",
         ),
+        # Should install the `qtcharts` module, even though the archive `qtcharts` is not specified:
         BuildJob(
             "install-example", "6.1.0", "linux", "desktop", "gcc_64", "gcc_64",
-            subarchives="qtdoc qtcharts", module="qtcharts"
+            subarchives="qtdoc", module="qtcharts",
+            # Fail the job if these paths do not exist:
+            check_output_cmd="ls -lh ./Examples/Qt-6.1.0/charts/ ./Examples/Qt-6.1.0/demos/ ./Examples/Qt-6.1.0/tutorials/",
         ),
         # test for list commands
         BuildJob('list', '5.15.2', 'linux', 'desktop', 'gcc_64', '', spec="<6", list_options={
@@ -368,6 +378,7 @@ for platform_build_job in all_platform_build_jobs:
                 ("TOOL2_ARGS", build_job.tool_options.get("TOOL2_ARGS", "")),
                 ("LIST_TOOL2_CMD", build_job.tool_options.get("LIST_TOOL2_CMD", "")),
                 ("TEST_TOOL2_CMD", build_job.tool_options.get("TEST_TOOL2_CMD", "")),
+                ("CHECK_OUTPUT_CMD", build_job.check_output_cmd or "")
             ]
         )
 
diff --git a/ci/steps.yml b/ci/steps.yml
index d184c9d..91eb879 100644
--- a/ci/steps.yml
+++ b/ci/steps.yml
@@ -117,19 +117,16 @@ steps:
         aqt list-example $(HOST) $(QT_VERSION) --modules                        # print example modules available for host/desktop/version
       fi
       if [[ "$(SUBCOMMAND)" == "install-src" ]]; then
-        python -m aqt $(SUBCOMMAND) $(HOST) $(TARGET) $(QT_VERSION) --archives $(SUBARCHIVES)
-        ls -lh ./$(QT_VERSION)/Src/*/
+        python -m aqt $(SUBCOMMAND) $(HOST) $(QT_VERSION) --archives $(SUBARCHIVES)
+        $(CHECK_OUTPUT_CMD)
       fi
       if [[ "$(SUBCOMMAND)" =~ ^install-(doc|example)$ ]]; then
         opt=""
         if [[ "$(MODULE)" != "" ]]; then
           opt+=" -m $(MODULE)"
         fi
-        python -m aqt $(SUBCOMMAND) $(HOST) $(TARGET) $(QT_VERSION) --archives $(SUBARCHIVES) $opt
-
-        # Docs install to ./Docs/Qt-6.1.0/qtdoc/
-        # Examples install to ./Examples/Qt-6.1.0/demos
-        ls -lh ./*/Qt-$(QT_VERSION)/*/
+        python -m aqt $(SUBCOMMAND) $(HOST) $(QT_VERSION) --archives $(SUBARCHIVES) $opt
+        $(CHECK_OUTPUT_CMD)
       fi
       if [[ "$(SUBCOMMAND)" == "install-tool" ]]; then
         opt=""
diff --git a/docs/cli.rst b/docs/cli.rst
index 891772a..661dfdc 100644
--- a/docs/cli.rst
+++ b/docs/cli.rst
@@ -414,6 +414,7 @@ are described here:
 .. option:: --archives <list of archives>
 
     [Advanced] Specify subset of archives to **limit** installed archives.
+    It will only affect the base Qt installation and the ``debug_info`` module.
     This is advanced option and not recommended to use for general usage.
     Main purpose is speed up CI/CD process by limiting installed modules.
     It can cause broken installation of Qt SDK.
diff --git a/docs/getting_started.rst b/docs/getting_started.rst
index bdeb61c..4deafea 100644
--- a/docs/getting_started.rst
+++ b/docs/getting_started.rst
@@ -436,6 +436,7 @@ of archives that it is downloading, extracting, and installing,
 including ``qtbase``, ``qtmultimedia``, ``qt3d``, and ~25 more items.
 We can use the ``--archives`` flag to choose which of these archives we will
 actually install.
+The ``--archives`` flag can only affect two modules: the base Qt installation and the ``debug_info`` module.
 
 .. note::
     In this documentation, **"modules"**, **"archives"**, and **"the base Qt installation"**
@@ -511,72 +512,38 @@ working Qt installation. We can install these archives using this command:
 Installing Modules With Archives Specified
 ``````````````````````````````````````````
 
-Now let's say we need to install the ``qtcharts`` and ``qtlottie`` modules.
-Let's see what archives are part of these modules:
+As of aqt v2.1.0, the ``--archives`` flag will only apply to
+the base Qt installation and to the ``debug_info`` module.
+Previous versions of aqt required that when installing modules with the ``--archives`` flag,
+the user must specify archives for each module, otherwise they would not be installed.
+This behavior has been changed to prevent such mistakes.
 
-.. code-block:: console
-
-    $ aqt list-qt linux desktop --archives 5.15.2 gcc_64 qtcharts qtlottie
-    qtcharts qtlottie
-
-This time, the command only printed two archives.
-The ``qtcharts`` and ``qtlottie`` modules contain one archive per module.
-
-.. note::
-    This command printed all archives associated with the modules we provided it,
-    and it did not print any of the archives associated with the base Qt installation.
-    This happened because we added a list of modules to the ``--archives`` flag.
-
-    .. code-block:: bash
-
-        # Print archives from the base Qt installation
-        aqt list-qt linux desktop --archives 5.15.2 gcc_64
-
-        # Print archives from the specified modules, but not the base Qt installation
-        aqt list-qt linux desktop --archives 5.15.2 gcc_64 qtcharts qtlottie
-
-
-Now let's install Qt with these modules:
+Let's say that we need to install the bare minimum Qt 5.15.2, with the modules ``qtcharts`` and ``qtlottie``:
 
 .. code-block:: console
 
-    $ aqt install-qt linux desktop 5.15.2 --modules qtcharts qtlottie \
-                                          --archives qtbase qtcharts qtlottie
+    $ aqt install-qt linux desktop 5.15.2 --modules qtcharts qtlottie --archives qtbase
 
-This command will install the bare minimum Qt, along with the modules ``qtcharts`` and ``qtlottie``.
-
-Remember that when using the ``--archives`` flag, you must specify every archive you
-intend to install.
-
-.. code-block:: bash
-
-    # Ways to misuse the `--archives` flag:
-
-    # This command installs modules without a working Qt installation,
-    # because `--archives` is missing `qtbase`.
-    aqt install-qt linux desktop 5.15.2 --modules qtcharts qtlottie \
-                                        --archives qtcharts qtlottie
-
-    # This command skips installation of the specified modules,
-    # because `--archives` is missing `qtcharts` and `qtlottie`.
-    aqt install-qt linux desktop 5.15.2 --modules qtcharts qtlottie \
-                                        --archives qtbase
-
-    # This command installs qtbase, but neither `qtcharts` nor `qtlottie`,
-    # because `--modules` is missing those names.
-    aqt install-qt linux desktop 5.15.2 --archives qtbase qtcharts qtlottie
+This command will successfully install 3 archives: 1 for ``qtbase``, and one each for the two modules.
+If we had tried to use this command with previous versions of aqt, we would not have
+installed the two modules because we did not specify them in the ``--archives`` list.
 
 .. note::
 
-    If you install modules that depend on archives other than ``qtbase``,
-    and you have not specified those archives after the ``--archives`` flag,
-    those modules will not work when you try to use them.
+    You can still misuse the ``--archives`` flag by omitting the ``qtbase`` archive,
+    or by omitting archives that another archive or module is dependent on.
+    You may not notice that there is a problem until you try to compile a program,
+    and compilation fails.
 
 Installing the ``debug_info`` module
 ````````````````````````````````````
 
-Now let's say we need to install the ``debug_info`` module, which is particularly large.
-We do not want to install all of it, so we can use ``aqt list-qt --archives`` again
+Now let's say we need to install the ``debug_info`` module, which is particularly large: around one gigabyte.
+We do not want to install all of it, so we can use ``aqt install-qt --archives``
+to choose which archives we want to install. Remember that the ``--archives`` flag
+
+
+``aqt list-qt --archives``
 to print which archives are part of the ``debug_info`` module:
 
 .. code-block:: console


Test patch:
diff --git a/tests/test_archives.py b/tests/test_archives.py
index af52a9f..4348a3d 100644
--- a/tests/test_archives.py
+++ b/tests/test_archives.py
@@ -4,11 +4,11 @@ import posixpath
 import re
 from itertools import groupby
 from pathlib import Path
-from typing import Dict, Iterable
+from typing import Dict, Iterable, List, Set
 
 import pytest
 
-from aqt.archives import ModuleToPackage, QtArchives, QtPackage, ToolArchives
+from aqt.archives import ModuleToPackage, QtArchives, QtPackage, SrcDocExamplesArchives, ToolArchives
 from aqt.exceptions import ArchiveListError, NoPackageFound
 from aqt.helper import Settings
 from aqt.metadata import Version
@@ -286,3 +286,166 @@ def test_module_to_package():
     for package_name in qtcharts_names:
         assert not mapping.has_package(package_name), "None of the qtcharts packages may remain after removal"
     assert len(mapping) == 0, "There must be no remaining module names"
+
+
+qt_5140_xml_weird_module = """
+<Updates>
+ <PackageUpdate>
+  <Name>qt.qt5.5140.qtcharts.win32_mingw73</Name>
+  <DisplayName>Qt Charts</DisplayName>
+  <Description>blah blah blah</Description>
+  <Version>5.14.0-0-201912110700</Version>
+  <ReleaseDate>2019-12-11</ReleaseDate>
+  <Dependencies>qt.qt5.5140.doc.qtcharts, qt.qt5.5140.examples.qtcharts</Dependencies>
+  <AutoDependOn/>
+  <DownloadableArchives>weird-qtcharts.7z</DownloadableArchives>
+  <UpdateFile CompressedSize="791213" OS="Any" UncompressedSize="8196243"/>
+ </PackageUpdate>
+ <PackageUpdate>
+  <Name>qt.qt5.5140.win32_mingw73</Name>
+  <DisplayName>Mingw 32-bit</DisplayName>
+  <Description>blah blah blah</Description>
+  <Version>5.14.0-0-201912110700</Version>
+  <ReleaseDate>2019-12-11</ReleaseDate>
+  <Dependencies>qt.tools.qtcreator, qt.qt5.5140.doc, qt.qt5.5140.examples</Dependencies>
+  <AutoDependOn/>
+  <DownloadableArchives>qtbase-mingw.7z, other-mingw.7z</DownloadableArchives>
+  <UpdateFile CompressedSize="81303586" OS="Any" UncompressedSize="540178217"/>
+ </PackageUpdate>
+ <PackageUpdate>
+  <Name>qt.qt5.5140.debug_info.win32_mingw73</Name>
+  <DisplayName>Desktop Mingw 32-bit debug information files</DisplayName>
+  <Description>Qt 5.14.0 debug information files for Desktop Mingw 32-bit</Description>
+  <Version>5.14.0-0-201912110700</Version>
+  <ReleaseDate>2019-12-11</ReleaseDate>
+  <AutoDependOn>qt.qt5.5140.debug_info, qt.qt5.5140.win32_mingw73</AutoDependOn>
+  <Dependencies>qt.qt5.5140.win32_mingw73</Dependencies>
+  <DownloadableArchives>qtbase-debug_info.7z, weird-debug_info.7z, somethingELSE-debug_info.7z</DownloadableArchives>
+  <UpdateFile CompressedSize="459720623" OS="Any" UncompressedSize="3579147640"/>
+ </PackageUpdate>
+</Updates>
+"""
+qt_doc_5152_xml_weird_module = """
+<Updates>
+ <PackageUpdate>
+  <Name>qt.qt5.5152.doc.qtcharts</Name>
+  <DisplayName>Documentation for Qt 5.15.2 GPLv3 components (QtCharts)</DisplayName>
+  <Description>Documentation for Qt 5.15.2 GPLv3 components (QtCharts)</Description>
+  <Version>5.15.2-0-202011130724</Version>
+  <ReleaseDate>2020-11-13</ReleaseDate>
+  <DownloadableArchives>weird-qtcharts-docs.7z</DownloadableArchives>
+  <UpdateFile UncompressedSize="16802053" OS="Any" CompressedSize="8714357"/>
+ </PackageUpdate>
+ <PackageUpdate>
+  <Name>qt.qt5.5152.doc</Name>
+  <DisplayName>Qt 5.15.2 Documentation</DisplayName>
+  <Description>Qt 5.15.2 documentation</Description>
+  <Version>5.15.2-0-202011130724</Version>
+  <ReleaseDate>2020-11-13</ReleaseDate>
+  <Dependencies>qt.tools</Dependencies>
+  <DownloadableArchives>tqtc-docs.7z, other-docs.7z</DownloadableArchives>
+  <UpdateFile UncompressedSize="402906410" OS="Any" CompressedSize="134528625"/>
+ </PackageUpdate>
+</Updates>
+"""
+
+
+def make_qt_archives(subarchives, modules, is_include_base) -> QtArchives:
+    return QtArchives(
+        "mac",
+        "desktop",
+        "5.14.0",
+        "win32_mingw73",
+        "www.example.com",
+        subarchives,
+        modules,
+        "all" in modules,
+        is_include_base,
+    )
+
+
+def make_doc_archives(subarchives, modules, is_include_base) -> SrcDocExamplesArchives:
+    return SrcDocExamplesArchives(
+        flavor="doc",
+        os_name="mac",
+        target="desktop",
+        version="5.15.2",
+        base="www.example.com",
+        subarchives=subarchives,
+        modules=modules,
+        all_extra="all" in modules,
+        is_include_base_package=is_include_base,
+    )
+
+
+@pytest.mark.parametrize(
+    "subarchives, modules, is_include_base, xml, make_archives_fn, expect_archives",
+    (
+        (["qtbase"], [], True, qt_5140_xml_weird_module, make_qt_archives, {"qtbase-mingw.7z"}),
+        # --archives should apply to debug_info and base, but not qtcharts module
+        (
+            ["qtbase"],
+            ["all"],
+            True,
+            qt_5140_xml_weird_module,
+            make_qt_archives,
+            {"qtbase-mingw.7z", "qtbase-debug_info.7z", "weird-qtcharts.7z"},
+        ),
+        # don't allow archives from debug_info
+        (
+            ["qtbase"],
+            ["qtcharts"],
+            True,
+            qt_5140_xml_weird_module,
+            make_qt_archives,
+            {"qtbase-mingw.7z", "weird-qtcharts.7z"},
+        ),
+        # don't include anything from base module
+        (["qtbase"], [], False, qt_5140_xml_weird_module, make_qt_archives, set()),
+        # --archives should apply to debug_info
+        (
+            ["qtbase"],
+            ["all"],
+            False,
+            qt_5140_xml_weird_module,
+            make_qt_archives,
+            {"qtbase-debug_info.7z", "weird-qtcharts.7z"},
+        ),
+        # don't allow archives from debug_info
+        (["qtbase"], ["qtcharts"], False, qt_5140_xml_weird_module, make_qt_archives, {"weird-qtcharts.7z"}),
+        (["tqtc"], [], True, qt_doc_5152_xml_weird_module, make_doc_archives, {"tqtc-docs.7z"}),
+        (
+            ["tqtc"],
+            ["all"],
+            True,
+            qt_doc_5152_xml_weird_module,
+            make_doc_archives,
+            {"tqtc-docs.7z", "weird-qtcharts-docs.7z"},
+        ),
+        (
+            ["tqtc"],
+            ["qtcharts"],
+            True,
+            qt_doc_5152_xml_weird_module,
+            make_doc_archives,
+            {"tqtc-docs.7z", "weird-qtcharts-docs.7z"},
+        ),
+        (["tqtc"], [], False, qt_doc_5152_xml_weird_module, make_doc_archives, set()),
+        (["tqtc"], ["all"], False, qt_doc_5152_xml_weird_module, make_doc_archives, {"weird-qtcharts-docs.7z"}),
+        (["tqtc"], ["qtcharts"], False, qt_doc_5152_xml_weird_module, make_doc_archives, {"weird-qtcharts-docs.7z"}),
+    ),
+)
+def test_archives_weird_module_7z_name(
+    monkeypatch,
+    subarchives: List[str],
+    modules: List[str],
+    is_include_base: bool,
+    xml: str,
+    make_archives_fn,
+    expect_archives: Set[str],
+):
+    monkeypatch.setattr("aqt.archives.getUrl", lambda *args: xml)
+
+    qt_archives = make_archives_fn(subarchives, modules, is_include_base)
+    archives = {pkg.archive for pkg in qt_archives.archives}
+    assert archives == expect_archives