Skip to content

Commit 660e57e

Browse files
committed
Handle MSIXBundle files
Handle MSIXBundle files to an extent - no support for localisation or listing bundle contents. Also handle passing in files in a subfolder rather than the root.
1 parent 63286c8 commit 660e57e

File tree

8 files changed

+173
-113
lines changed

8 files changed

+173
-113
lines changed

build_exe.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
function Get-ParentPath {
2+
param([string]$path)
3+
4+
# Check if the path is just a file (no backslashes or forward slashes)
5+
if ($path -notmatch '[\\/]') {
6+
return '.' # Return '.' for just a file without a directory
7+
}
8+
9+
# Use Split-Path to get the parent directory
10+
return (Split-Path $path -Parent)
11+
}
12+
113
# Get picked data to get name and icon
214
$paths_py = python -c "import pickle; m = pickle.load(open('extracted/data.pkl', 'rb')); print([a.package_path for a in m])"
315
$paths_py_doublequotes = $paths_py -replace "'", '"'
416
$paths_json = $paths_py_doublequotes | ConvertFrom-Json
517
$main_app_path = $paths_json[0]
6-
$addDataArgs = $paths_json | ForEach-Object { "--add-data `'$($_):.`'" }
18+
$addDataArgs = $paths_json | ForEach-Object {
19+
$parent_path = Get-ParentPath $_
20+
"--add-data `'$($_):$parent_path`'"
21+
}
722
$addDataString = $addDataArgs -replace "`r?`n", ""
823

924
$basename = [System.IO.Path]::GetFileNameWithoutExtension($main_app_path)
@@ -13,4 +28,5 @@ $icon = python -c "import pickle; print(pickle.load(open('extracted/data.pkl', '
1328
# Build command
1429
# This only works when first stored as a string - some powershell string issue for the add-data commands
1530
$command_str = "pyinstaller .\src\msix_global_installer\app.py --add-data 'extracted:extracted' $addDataString --onefile --name $pathexe --icon $icon --noconsole"
31+
Write-Host "Running command: $command_str"
1632
Invoke-Expression $command_str

extract_msix_data.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ def get_metadata(paths: list[str]) -> list[msix.MsixMetadata]:
3838
image.save_image(scaled_image, scaled_image_path)
3939
metadata.scaled_icon_path = scaled_image_path
4040

41+
print(f"\nExtracted: {all_metadata}")
42+
4143
pickler.save_metadata(data_file_path=data_file, metadata_list=all_metadata)

src/msix_global_installer/app.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ def process_event(event: events.Event):
1212
if event.name == events.EventType.REQUEST_MSIX_METADATA:
1313
meta = pickler.load_metadata(config.EXTRACTED_DATA_PATH)
1414
logger.info("Got metadata %s", meta)
15-
metadata_event = events.Event(
16-
name=events.EventType.MSIX_METADATA_RECEIVED, data=meta
17-
)
15+
metadata_event = events.Event(name=events.EventType.MSIX_METADATA_RECEIVED, data=meta)
1816
events.post_event_sync(event=metadata_event, event_queue=events.gui_event_queue)
1917
elif event.name == events.EventType.INSTALL_MSIX:
2018
install_globally = event.data["global"]
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pathlib
22
from msix_global_installer import pyinstaller_helper
33

4-
EXTRACTED_DATA_PATH: pathlib.Path = pyinstaller_helper.resource_path(
5-
"extracted/data.pkl"
6-
)
4+
EXTRACTED_DATA_PATH: pathlib.Path = pyinstaller_helper.resource_path("extracted/data.pkl")
5+
ALLOW_DEPENDENCIES_TO_FAIL_DUE_TO_NEWER_VERSION_INSTALLED = True

src/msix_global_installer/events.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ async def wait_for_queue(timeout_s: int, event_queue: asyncio.Queue) -> None:
7676
current_time = time.monotonic_ns()
7777
await asyncio.sleep(0)
7878
if current_time - initial_time > timeout_ns:
79-
raise TimeoutError(
80-
f"Timed out waiting for event queue to clear. Events: {str(event_queue)}"
81-
)
79+
raise TimeoutError(f"Timed out waiting for event queue to clear. Events: {str(event_queue)}")
8280
elif event_queue.empty():
8381
break
8482

src/msix_global_installer/gui.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ class InfoScreen(ttk.Frame, events.EventHandler):
102102
def __init__(self, parent: tkinter.Tk, *args, **kwargs):
103103
ttk.Frame.__init__(self, parent, *args, **kwargs)
104104
self.parent: tkinter.Tk = parent
105-
post_backend_event(
106-
events.Event(
107-
events.EventType.REQUEST_MSIX_METADATA, data=events.EventData()
108-
)
109-
)
105+
post_backend_event(events.Event(events.EventType.REQUEST_MSIX_METADATA, data=events.EventData()))
110106

111107
self.title = ttk.Label(self, text="Install MSIX Application")
112108
self.title.grid(row=0, column=0, sticky="W")

0 commit comments

Comments
 (0)