Skip to content

Commit

Permalink
Return to simpler process execution method version
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidev committed Jan 8, 2025
1 parent 3169929 commit 40ed004
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions aqt/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,27 +1591,8 @@ def _get_install_command(self, installer_path: Path) -> list[str]:
)
return cmd

def _exec_qt_installer(self, arguments: list[str], working_dir: str) -> None:
"""Execute Qt installer with validated arguments."""
original_cwd = os.getcwd()
os.chdir(working_dir)
try:
if sys.platform == "win32":
os.spawnv(os.P_WAIT, "qt-unified-windows-x64-online.exe", ["qt-unified-windows-x64-online.exe"] + arguments)
else:
pid = os.fork()
if pid == 0: # Child process
if self.os_name == "mac":
os.execv("qt-unified-macOS-x64-online.dmg", ["qt-unified-macOS-x64-online.dmg"] + arguments)
elif self.os_name == "linux":
os.execv("qt-unified-linux-x64-online.run", ["qt-unified-linux-x64-online.run"] + arguments)
sys.exit(1)
else: # Parent process
_, status = os.waitpid(pid, 0)
if status != 0:
raise RuntimeError(f"Qt installation failed with status {status}")
finally:
os.chdir(original_cwd) # Restore original working directory
def _exec_qt_installer(self, cmd: list[str], working_dir: str) -> None:
subprocess.run(cmd, shell=False, check=True, cwd=working_dir)

def install(self) -> None:
if (
Expand Down Expand Up @@ -1646,13 +1627,7 @@ def install(self) -> None:
safe_cmd[email_index + 1] = "********"
self.logger.info(f"Running: {' '.join(safe_cmd)}")

target_path = temp_path / self.ALLOWED_INSTALLERS[self.os_name]
if installer_path != target_path:
if target_path.exists():
target_path.unlink()
os.symlink(installer_path, target_path)

self._exec_qt_installer(cmd[1:], temp_dir)
self._exec_qt_installer(cmd, temp_dir)

except subprocess.CalledProcessError as e:
self.logger.error(f"Installation failed with exit code {e.returncode}")
Expand Down

0 comments on commit 40ed004

Please sign in to comment.