Skip to content

Commit

Permalink
Fix patching
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre 'Kidev' Poumaroux <1204936+Kidev@users.noreply.github.com>
  • Loading branch information
jdpurcell authored and Kidev committed Dec 19, 2024
1 parent 1aa5216 commit 6e785f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
41 changes: 23 additions & 18 deletions aqt/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def run_install_qt(self, args: InstallArgParser):
self.show_aqt_version()
target: str = args.target
os_name: str = args.host
effective_os_name: str = Cli._get_effective_os_name(os_name)
qt_version_or_spec: str = getattr(args, "qt_version", getattr(args, "qt_version_spec", ""))
arch: str = self._set_arch(args.arch, os_name, target, qt_version_or_spec)
keep: bool = args.keep or Settings.always_keep_archives
Expand Down Expand Up @@ -366,16 +367,14 @@ def run_install_qt(self, args: InstallArgParser):

def get_auto_desktop_archives() -> List[QtPackage]:
def to_archives(baseurl: str) -> QtArchives:
# Use host_os instead of os_name for desktop Qt
host_os = os_name
if host_os == "all_os":
if sys.platform.startswith("linux"):
host_os = "linux"
elif sys.platform == "darwin":
host_os = "mac"
else:
host_os = "windows"
return QtArchives(host_os, "desktop", qt_version, cast(str, autodesk_arch), base=baseurl, timeout=timeout)
return QtArchives(
effective_os_name,
"desktop",
qt_version,
cast(str, autodesk_arch),
base=baseurl,
timeout=timeout,
)

if autodesk_arch is not None:
return cast(QtArchives, retry_on_bad_connection(to_archives, base)).archives
Expand Down Expand Up @@ -403,14 +402,15 @@ def to_archives(baseurl: str) -> QtArchives:
)
qt_archives.archives.extend(auto_desktop_archives)
target_config = qt_archives.get_target_config()
target_config.os_name = effective_os_name
with TemporaryDirectory() as temp_dir:
_archive_dest = Cli.choose_archive_dest(archive_dest, keep, temp_dir)
run_installer(qt_archives.get_packages(), base_dir, sevenzip, keep, _archive_dest)

if not nopatch:
Updater.update(target_config, base_path, expect_desktop_archdir)
if autodesk_arch is not None:
d_target_config = TargetConfig(str(_version), "desktop", autodesk_arch, os_name)
d_target_config = TargetConfig(str(_version), "desktop", autodesk_arch, effective_os_name)
Updater.update(d_target_config, base_path, expect_desktop_archdir)
self.logger.info("Finished installation")
self.logger.info("Time elapsed: {time:.8f} second".format(time=time.perf_counter() - start_time))
Expand Down Expand Up @@ -1053,13 +1053,7 @@ def _get_autodesktop_dir_and_arch(
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"
host = Cli._get_effective_os_name(host)

installed_desktop_arch_dir = QtRepoProperty.find_installed_desktop_qt_dir(host, base_path, version, is_msvc=is_msvc)
if installed_desktop_arch_dir:
Expand Down Expand Up @@ -1102,6 +1096,17 @@ def _get_autodesktop_dir_and_arch(
)
return expected_desktop_arch_path.name, None

@staticmethod
def _get_effective_os_name(host: str) -> str:
if host != "all_os":
return host
elif sys.platform.startswith("linux"):
return "linux"
elif sys.platform == "darwin":
return "mac"
else:
return "windows"


def is_64bit() -> bool:
"""check if running platform is 64bit python."""
Expand Down
15 changes: 1 addition & 14 deletions aqt/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,21 +437,8 @@ def dir_for_version(ver: Version) -> str:
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.
Special handling is done for mingw, MSVC and various platform-specific cases.
"""
# If host is all_os and we have a desktop arch (from autodesktop),
# call ourselves again with the correct host based on arch prefix
if host == "all_os":
if arch.startswith("linux_"):
return QtRepoProperty.get_arch_dir_name("linux", arch, version)
elif arch.startswith("win"):
return QtRepoProperty.get_arch_dir_name("windows", arch, version)
elif arch == "clang_64":
return QtRepoProperty.get_arch_dir_name("mac", arch, version)
elif arch in ("wasm_singlethread", "wasm_multithread", "wasm_32"):
return arch

# Rest of the original method
if arch.startswith("win64_mingw"):
return arch[6:] + "_64"
elif arch.startswith("win64_llvm"):
Expand Down

0 comments on commit 6e785f0

Please sign in to comment.