Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WASM #846

Merged
merged 55 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
de06f45
Rewrite WASM support
Kidev Dec 15, 2024
7ec6970
Add WASM tests to CI, update CI to test more the latest versions, add…
Kidev Dec 15, 2024
1df829a
Fix some mistakes, typos, moved emsdk version function into BuildJob
Kidev Dec 15, 2024
cacabe8
Fix issue related to extensions interfering with wasm on 6.8+
Kidev Dec 15, 2024
11470f9
Fix tests
Kidev Dec 16, 2024
73bc8ad
Remove dep on Version in CI
Kidev Dec 16, 2024
77dff51
Remove safety before patch
Kidev Dec 16, 2024
5d80b7c
handle cases where extensions don't exist.
tsteven4 Dec 14, 2024
001bbc8
for --long-modules assume extension doesn't exist on download error.
tsteven4 Dec 15, 2024
4408ba6
for --modules assume extension doesn't exist for download failures.
tsteven4 Dec 15, 2024
c6955a6
reformat with black
tsteven4 Dec 15, 2024
dfc1d97
fix flake8 regression that doesn't occur locally.
tsteven4 Dec 15, 2024
c8ec8b8
Merge branch 'master_upstream' into wasm
Kidev Dec 16, 2024
44c7762
Fix autodesktop by also updating the OS when searching for a valid de…
Kidev Dec 16, 2024
c40af54
Fix extension issue, reduce the possible retry for getting extensions…
Kidev Dec 17, 2024
0008f42
Fix CI asking for msvc2019 on 6.8+ but its no longer supported
Kidev Dec 17, 2024
592f875
Make CI use C++20 and MSVC2022
Kidev Dec 17, 2024
3f108bc
Fix linux build
Kidev Dec 17, 2024
1aa5216
Update runners to windows-2022
jdpurcell Dec 17, 2024
6e785f0
Fix patching
jdpurcell Dec 18, 2024
356a2b8
Add back the semantic version changes to prevent crashes, add tests f…
Kidev Dec 18, 2024
bbaa833
Update checks
Kidev Dec 19, 2024
29358b1
Cast 'https://mirrors.ustc.edu.cn' to the shadow realm
Kidev Dec 19, 2024
1a52e5f
Again
Kidev Dec 19, 2024
7f695c4
Update settings.ini
Kidev Dec 19, 2024
07ff4ce
Update settings.ini
Kidev Dec 19, 2024
b92d40f
Update settings.ini
Kidev Dec 19, 2024
2c7ba14
Remove one_rep on silent
Kidev Dec 19, 2024
b734cdd
Update settings.ini
Kidev Dec 19, 2024
7a2a41b
Restore master settings, remove hash check
Kidev Dec 19, 2024
2288b1d
ci: Use specific mirror
jdpurcell Dec 19, 2024
3568115
Re enable hash checking
Kidev Dec 20, 2024
7cde90d
Treat read timeout error during download as connection error
jdpurcell Dec 20, 2024
de6e325
Merge branch 'master' into wasm
Kidev Dec 21, 2024
bbd31a9
Add test for modules in WASM with autodesktop
Kidev Dec 20, 2024
2e8abc2
Fix format
Kidev Dec 20, 2024
f014c69
Fix test
Kidev Dec 20, 2024
06a5098
Make '--autodesktop' trigger its own install process, and test it
Kidev Dec 21, 2024
aad5871
Fix older autodesktop tests
Kidev Dec 21, 2024
37ae2fa
Add mock update files for 680 wasm, add test for wasm 680 autodesktop
Kidev Dec 21, 2024
44f1a90
Passes the additional tests
Kidev Dec 21, 2024
84fad94
Fix format
Kidev Dec 21, 2024
f9f1417
Improve coverage, fix format
Kidev Dec 22, 2024
93f05d0
Fix tests and improve logging or install
Kidev Dec 24, 2024
b14f120
Fix format
Kidev Dec 24, 2024
0cd24a0
Merge branch 'master' into wasm
Kidev Dec 24, 2024
c9451c3
Fix regression in other tests
Kidev Dec 24, 2024
4dbb72f
Use flavor
Kidev Dec 24, 2024
eca7ef6
Fix line len
Kidev Dec 25, 2024
a46f3a7
Fix codeql
Kidev Dec 25, 2024
9078341
Fix list-qt for WASM arch on 6.5.x and 6.6.x, restore to original dow…
Kidev Jan 5, 2025
0343d61
Merge branch 'master' into wasm
Kidev Jan 5, 2025
a5a075b
Fix test error
Kidev Jan 5, 2025
08328f2
Revert ci settings URL as it is never used by clients, only in CI
Kidev Jan 5, 2025
3987df3
Add comment for clarity in ci/settings.ini
Kidev Jan 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions aqt/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,14 @@ def _get_archives_base(self, name, target_packages):
arch = "x86_64"
elif self.os_name == "linux_arm64":
arch = "arm64"
for ext in ["qtwebengine", "qtpdf"]:
extensions_target_folder = posixpath.join(
"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))
if self.target != "wasm":
for ext in ["qtwebengine", "qtpdf"]:
extensions_target_folder = posixpath.join(
"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))

self._parse_update_xmls(update_xmls, target_packages)

Expand Down
63 changes: 47 additions & 16 deletions aqt/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,17 @@ def show_aqt_version(self, args=None):

def _set_install_qt_parser(self, install_qt_parser):
install_qt_parser.set_defaults(func=self.run_install_qt)
self._set_common_arguments(install_qt_parser)
self._set_common_options(install_qt_parser)
install_qt_parser.add_argument(
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name"
)
install_qt_parser.add_argument(
"target", choices=["desktop", "winrt", "android", "ios", "wasm", "qt"], help="Target SDK"
)
install_qt_parser.add_argument(
"qt_version_spec",
metavar="(VERSION | SPECIFICATION)",
help='Qt version in the format of "5.X.Y" or SimpleSpec like "5.X" or "<6.X"',
)
install_qt_parser.add_argument(
"arch",
nargs="?",
Expand All @@ -668,8 +677,10 @@ def _set_install_qt_parser(self, install_qt_parser):
"\n win64_msvc2017_winrt_armv7"
"\nandroid: Qt 5.14: android (optional)"
"\n Qt 5.13 or below: android_x86_64, android_arm64_v8a"
"\n android_x86, android_armv7",
"\n android_x86, android_armv7"
"\nall_os/wasm: wasm_singlethread, wasm_multithread",
)
self._set_common_options(install_qt_parser)
self._set_module_options(install_qt_parser)
self._set_archive_options(install_qt_parser)
install_qt_parser.add_argument(
Expand All @@ -688,12 +699,12 @@ def _set_install_qt_parser(self, install_qt_parser):
def _set_install_tool_parser(self, install_tool_parser):
install_tool_parser.set_defaults(func=self.run_install_tool)
install_tool_parser.add_argument(
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name"
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name"
)
install_tool_parser.add_argument(
"target",
default=None,
choices=["desktop", "winrt", "android", "ios"],
choices=["desktop", "winrt", "android", "ios", "wasm", "qt"],
help="Target SDK.",
)
install_tool_parser.add_argument("tool_name", help="Name of tool such as tools_ifw, tools_mingw")
Expand Down Expand Up @@ -741,7 +752,7 @@ def make_parser_sde(cmd: str, desc: str, action, is_add_kde: bool, is_add_module
def make_parser_list_sde(cmd: str, desc: str, cmd_type: str):
parser = subparsers.add_parser(cmd, description=desc)
parser.add_argument(
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name"
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name"
)
parser.add_argument(
"qt_version_spec",
Expand Down Expand Up @@ -782,16 +793,17 @@ def _make_list_qt_parser(self, subparsers: argparse._SubParsersAction):
"$ aqt list-qt mac desktop --arch 5.9.9 # print architectures for 5.9.9/mac/desktop\n"
"$ aqt list-qt mac desktop --arch latest # print architectures for the latest Qt 5\n"
"$ aqt list-qt mac desktop --archives 5.9.0 clang_64 # list archives in base Qt installation\n"
"$ aqt list-qt mac desktop --archives 5.14.0 clang_64 debug_info # list archives in debug_info module\n",
"$ aqt list-qt mac desktop --archives 5.14.0 clang_64 debug_info # list archives in debug_info module\n"
"$ aqt list-qt all_os wasm --arch 6.8.1 # print architectures for Qt WASM 6.8.1\n",
)
list_parser.add_argument(
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name"
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name"
)
list_parser.add_argument(
"target",
nargs="?",
default=None,
choices=["desktop", "winrt", "android", "ios"],
choices=["desktop", "winrt", "android", "ios", "wasm", "qt"],
help="Target SDK. When omitted, this prints all the targets available for a host OS.",
)
list_parser.add_argument(
Expand Down Expand Up @@ -871,13 +883,13 @@ def _make_list_tool_parser(self, subparsers: argparse._SubParsersAction):
"$ aqt list-tool mac desktop ifw --long # print tool variant names with metadata for QtIFW\n",
)
list_parser.add_argument(
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name"
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name"
)
list_parser.add_argument(
"target",
nargs="?",
default=None,
choices=["desktop", "winrt", "android", "ios"],
choices=["desktop", "winrt", "android", "ios", "wasm", "qt"],
help="Target SDK. When omitted, this prints all the targets available for a host OS.",
)
list_parser.add_argument(
Expand Down Expand Up @@ -956,18 +968,18 @@ def _set_common_arguments(self, subparser, *, is_target_deprecated: bool = False
install-src/doc/example commands do not require a "target" argument anymore, as of 11/22/2021
"""
subparser.add_argument(
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64"], help="host os name"
"host", choices=["linux", "linux_arm64", "mac", "windows", "windows_arm64", "all_os"], help="host os name"
)
if is_target_deprecated:
subparser.add_argument(
"target",
choices=["desktop", "winrt", "android", "ios"],
choices=["desktop", "winrt", "android", "ios", "wasm", "qt"],
nargs="?",
help="Ignored. This parameter is deprecated and marked for removal in a future release. "
"It is present here for backwards compatibility.",
)
else:
subparser.add_argument("target", choices=["desktop", "winrt", "android", "ios"], help="target sdk")
subparser.add_argument("target", choices=["desktop", "winrt", "android", "ios", "wasm", "qt"], help="target sdk")
subparser.add_argument(
"qt_version_spec",
metavar="(VERSION | SPECIFICATION)",
Expand Down Expand Up @@ -1026,18 +1038,36 @@ def _get_autodesktop_dir_and_arch(
host == "windows" and target == "desktop" and is_msvc and arch.endswith(("arm64", "arm64_cross_compiled"))
)
if version < Version("6.0.0") or (
target not in ["ios", "android"] and not is_wasm and not is_win_desktop_msvc_arm64
target not in ["ios", "android", "wasm"] and not is_wasm and not is_win_desktop_msvc_arm64
):
# We only need to worry about the desktop directory for Qt6 mobile or wasm installs.
return None, None

# For WASM installations on all_os, we need to choose a default desktop host
if host == "all_os":
if sys.platform.startswith("linux"):
host = "linux"
elif sys.platform == "darwin":
host = "mac"
else:
host = "windows"

installed_desktop_arch_dir = QtRepoProperty.find_installed_desktop_qt_dir(host, base_path, version, is_msvc=is_msvc)
if installed_desktop_arch_dir:
# An acceptable desktop Qt is already installed, so don't do anything.
self.logger.info(f"Found installed {host}-desktop Qt at {installed_desktop_arch_dir}")
return installed_desktop_arch_dir.name, None

default_desktop_arch = MetadataFactory(ArchiveId("qt", host, "desktop")).fetch_default_desktop_arch(version, is_msvc)
try:
default_desktop_arch = MetadataFactory(ArchiveId("qt", host, "desktop")).fetch_default_desktop_arch(
version, is_msvc
)
except ValueError as e:
if "Target 'desktop' is invalid" in str(e):
# Special case for all_os host which doesn't support desktop target
return None, None
raise

desktop_arch_dir = QtRepoProperty.get_arch_dir_name(host, default_desktop_arch, version)
expected_desktop_arch_path = base_path / dir_for_version(version) / desktop_arch_dir

Expand All @@ -1047,6 +1077,7 @@ def _get_autodesktop_dir_and_arch(
qt_type = "Qt6-WASM"
else:
qt_type = target

if should_autoinstall:
# No desktop Qt is installed, but the user has requested installation. Find out what to install.
self.logger.info(
Expand Down
54 changes: 37 additions & 17 deletions aqt/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,17 @@ class ArchiveId:
"mac": ["android", "desktop", "ios"],
"linux": ["android", "desktop"],
"linux_arm64": ["desktop"],
"all_os": ["qt"],
"all_os": ["wasm", "qt"],
}
EXTENSIONS_REQUIRED_ANDROID_QT6 = {"x86_64", "x86", "armv7", "arm64_v8a"}
ALL_EXTENSIONS = {"", "wasm", "src_doc_examples", *EXTENSIONS_REQUIRED_ANDROID_QT6}
ALL_EXTENSIONS = {
"",
"wasm",
"src_doc_examples",
*EXTENSIONS_REQUIRED_ANDROID_QT6,
# "wasm_singlethread",
# "wasm_multithread",
}

def __init__(self, category: str, host: str, target: str):
if category not in ArchiveId.CATEGORIES:
Expand All @@ -232,6 +239,8 @@ def is_tools(self) -> bool:
return self.category == "tools"

def to_os_arch(self) -> str:
if self.host == "all_os":
return "all_os"
return "{os}{arch}".format(
os=self.host,
arch=(
Expand Down Expand Up @@ -269,25 +278,30 @@ def to_url(self) -> str:

def to_folder(self, version: Version, qt_version_no_dots: str, extension: Optional[str] = None) -> str:
if version >= Version("6.8.0"):
return "{category}{major}_{ver}/{category}{major}_{ver}{ext}".format(
category=self.category,
major=qt_version_no_dots[0],
ver=qt_version_no_dots,
ext="_" + extension if extension else "",
)
else:
return "{category}{major}_{ver}{ext}".format(
category=self.category,
major=qt_version_no_dots[0],
ver=qt_version_no_dots,
ext="_" + extension if extension else "",
)
if self.target == "wasm":
# Qt 6.8+ WASM uses a split folder structure
folder = f"qt{version.major}_{qt_version_no_dots}"
if extension:
folder = f"{folder}/{folder}_{extension}"
return folder
elif version >= Version("6.5.0") and self.target == "wasm":
# Qt 6.5-6.7 WASM uses direct wasm_[single|multi]thread folder
if extension:
return f"qt{version.major}_{qt_version_no_dots}_{extension}"
return f"qt{version.major}_{qt_version_no_dots}"
# Pre-6.8 structure for non-WASM or pre-6.5 structure
return "{category}{major}_{ver}{ext}".format(
category=self.category,
Comment on lines +348 to +349
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The category handling is a bit different for >= 6.8.0 non-wasm, category is now assumed to be qt in that case. category is either tools or qt. Is there any case where the directory component is tools{major}_{ver}{ext}, either before or after 6.8.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return is there for the legacy versions. For Qt 6.8 non-WASM, this is returned:

base = f"qt{version.major}_{qt_version_no_dots}"
return f"{base}/{base}"

All tests pass with this to_folder, older and newer versions of Qt, WASM of not

major=qt_version_no_dots[0],
ver=qt_version_no_dots,
ext="_" + extension if extension else "",
)

def all_extensions(self, version: Version) -> List[str]:
if self.target == "desktop" and QtRepoProperty.is_in_wasm_range(self.host, version):
return ["", "wasm"]
elif self.target == "desktop" and QtRepoProperty.is_in_wasm_threaded_range(version):
return ["", "wasm_singlethread", "wasm_multithread"]
elif self.target == "wasm" and QtRepoProperty.is_in_wasm_threaded_range(version):
return ["wasm_singlethread", "wasm_multithread"]
elif self.target == "android" and version >= Version("6.0.0"):
return list(ArchiveId.EXTENSIONS_REQUIRED_ANDROID_QT6)
else:
Expand Down Expand Up @@ -412,6 +426,10 @@ def dir_for_version(ver: Version) -> str:

@staticmethod
def get_arch_dir_name(host: str, arch: str, version: Version) -> str:
"""
Determines the architecture directory name based on host, architecture and version.
Special handling is done for WASM, mingw, MSVC and various platform-specific cases.
"""
if arch.startswith("win64_mingw"):
return arch[6:] + "_64"
elif arch.startswith("win64_llvm"):
Expand All @@ -432,6 +450,8 @@ def get_arch_dir_name(host: str, arch: str, version: Version) -> str:
return "gcc_64"
elif host == "linux_arm64" and arch == "linux_gcc_arm64":
return "gcc_arm64"
elif host == "all_os" and arch in ("wasm_singlethread", "wasm_multithread", "wasm_32"):
return arch
else:
return arch

Expand Down
49 changes: 47 additions & 2 deletions ci/generate_azure_pipelines_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@


class BuildJob:

EMSDK_FOR_QT = {
"6.2": "2.0.14",
"6.3": "3.0.0",
"6.4": "3.1.14",
"6.5": "3.1.25",
"6.6": "3.1.37",
"6.7": "3.1.50",
"6.8": "3.1.56",
}

def __init__(
self,
command,
Expand All @@ -35,7 +46,7 @@ def __init__(
is_autodesktop: bool = False,
tool_options: Optional[Dict[str, str]] = None,
check_output_cmd: Optional[str] = None,
emsdk_version: str = "[email protected]",
emsdk_version: str = "[email protected]", # did not change for safety, created func self.emsdk_version()
autodesk_arch_folder: Optional[str] = None,
):
self.command = command
Expand Down Expand Up @@ -102,6 +113,24 @@ def mingw_tool_name(self) -> str:
else:
return "tools_mingw"

def emsdk_version(self) -> str:
return BuildJob.emsdk_version_for_qt(self.qt_version)

@staticmethod
def emsdk_version_for_qt(version_of_qt: str) -> str:
qt_major_minor = ".".join(version_of_qt.split(".")[:2])

if qt_major_minor in BuildJob.EMSDK_FOR_QT:
return BuildJob.EMSDK_FOR_QT[qt_major_minor]

# Find the latest version using string comparison
latest_version = "0.0"
for version in BuildJob.EMSDK_FOR_QT.keys():
if version > latest_version:
latest_version = version

return BuildJob.EMSDK_FOR_QT[latest_version]


class PlatformBuildJobs:
def __init__(self, platform, build_jobs):
Expand All @@ -111,7 +140,7 @@ def __init__(self, platform, build_jobs):

python_versions = ["3.12"]

qt_versions = ["6.5.3"]
qt_versions = ["6.8.1"]

linux_build_jobs = []
linux_arm64_build_jobs = []
Expand Down Expand Up @@ -239,6 +268,22 @@ def __init__(self, platform, build_jobs):
mingw_variant="win64_mingw900")
)

# WASM post 6.7.x
linux_build_jobs.append(
BuildJob("install-qt", "6.7.3", "all_os", "wasm", "wasm_multithread", "wasm_multithread",
is_autodesktop=True, emsdk_version=f"sdk-{BuildJob.emsdk_version_for_qt("6.7.3")}-64bit", autodesk_arch_folder="gcc_64")
)
for job_queue, host, desk_arch, target, qt_version in (
(linux_build_jobs, "all_os", "gcc_64", "wasm", qt_versions[0]),
(mac_build_jobs, "all_os", "clang_64", "wasm", qt_versions[0]),
(windows_build_jobs, "all_os", "mingw_64", "wasm", qt_versions[0]),
):
for wasm_arch in ("wasm_singlethread", "wasm_multithread"):
job_queue.append(
BuildJob("install-qt", qt_version, host, target, wasm_arch, wasm_arch,
is_autodesktop=True, emsdk_version=f"sdk-{BuildJob.emsdk_version_for_qt(qt_version)}-64bit", autodesk_arch_folder=desk_arch)
)

# mobile SDK
mac_build_jobs.extend(
[
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ commands =
basepython = python3.12
extras = debug
commands =
mprof run --multiprocess python -m aqt install-qt -O /tmp -d /tmp linux desktop 6.2.1
mprof run --multiprocess python -m aqt install-qt -O /tmp -d /tmp linux desktop 6.8.1
mprof plot --output memory-profile.png
deps =
memory_profiler
Expand All @@ -225,7 +225,7 @@ deps =
basepython = python3.12
extras = debug
commands =
fil-profile run -m aqt install-qt -O /tmp -d /tmp linux desktop 6.2.1
fil-profile run -m aqt install-qt -O /tmp -d /tmp linux desktop 6.8.1
deps =
filprofiler

Expand Down
Loading
Loading