Skip to content

Commit

Permalink
fix: zip bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
leocov-dev committed Nov 24, 2024
1 parent 64826a0 commit 4651663
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/pyside_app_build/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import re
import shutil
import subprocess
import tarfile
import zipfile
from collections.abc import Callable
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -69,11 +71,11 @@ def _build_standard(self, _: str, **__: Any) -> str:
self.app.display_debug("Packaging App Executable...")
match plat := platform.system():
case "Darwin":
artifact = self._bundle_macos_dmg(app_build_bundle)
artifact = self._bundle_macos(app_build_bundle)
case "Linux":
artifact = self._linux_remove_bin_extension(app_build_bundle)
artifact = self._bundle_linux(app_build_bundle)
case "Windows":
artifact = self._win_copy(app_build_bundle)
artifact = self._bundle_windows(app_build_bundle)
case _:
raise PySideBuildError(f"Unsupported platform: {plat}")

Expand Down Expand Up @@ -133,7 +135,7 @@ def _pyside_deploy(self, spec_file: Path) -> Path:

return Path(app_bundle)

def _bundle_macos_dmg(
def _bundle_macos(
self,
app: Path,
) -> Path:
Expand Down Expand Up @@ -173,19 +175,21 @@ def _bundle_macos_dmg(

return dmg_target

def _linux_remove_bin_extension(
def _bundle_linux(
self,
with_bin: Path,
bundle: Path,
) -> Path:
without_bin = self.config.dist_dir / with_bin.name.removesuffix(".bin")
tar_target = self.config.dist_dir / f"{self.metadata.name}-linux.tar.gz"

shutil.copy(with_bin, without_bin)
with tarfile.open(tar_target, "w:gz") as tar:
tar.add(bundle, arcname=bundle.name.removesuffix(".bin"))

return without_bin
return tar_target

def _win_copy(self, bundle: Path) -> Path:
output = self.config.dist_dir / bundle.name
def _bundle_windows(self, bundle: Path) -> Path:
zip_target = self.config.dist_dir / f"{self.metadata.name}-win.zip"

shutil.copy(bundle, output)
with zipfile.ZipFile(zip_target, "w") as zip:
zip.write(bundle, arcname=bundle.name)

return output
return zip_target

0 comments on commit 4651663

Please sign in to comment.