From c3d74ba76b7e3ab5e0c6b58c92913f5fc720a312 Mon Sep 17 00:00:00 2001 From: Marcin Raba Date: Mon, 9 Sep 2024 17:34:50 +0200 Subject: [PATCH] SNOW-1055755: windows build debug - ...wix util schema update --- .../packaging/win/snowflake_cli_template_v4.wxs | 3 ++- scripts/packaging/win/wxs_builder.py | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/packaging/win/snowflake_cli_template_v4.wxs b/scripts/packaging/win/snowflake_cli_template_v4.wxs index 7c49928656..6d80246595 100644 --- a/scripts/packaging/win/snowflake_cli_template_v4.wxs +++ b/scripts/packaging/win/snowflake_cli_template_v4.wxs @@ -1,4 +1,5 @@ - + + diff --git a/scripts/packaging/win/wxs_builder.py b/scripts/packaging/win/wxs_builder.py index be6d7a9733..b497d0851a 100644 --- a/scripts/packaging/win/wxs_builder.py +++ b/scripts/packaging/win/wxs_builder.py @@ -11,10 +11,17 @@ WXS_TEMPLATE_FILE = WIN_RES_DIR.joinpath("snowflake_cli_template_v4.wxs") WXS_OUTPUT_FILE = WXS_TEMPLATE_FILE.parent.joinpath("snowflake_cli.wxs") +ns = { + "util": "http://wixtoolset.org/schemas/v4/wxs/util", + "": "http://wixtoolset.org/schemas/v4/wxs", +} +for ns_name, ns_url in ns.items(): + ElementTree.register_namespace(ns_name, ns_url) wxs = ElementTree.parse(WXS_TEMPLATE_FILE) root = wxs.getroot() -snow_files_xpath = ".//{http://wixtoolset.org/schemas/v4/wxs}Component" -snow_files = root.findall(snow_files_xpath) +snow_files = root.find(".//Component", namespaces=ns) +if snow_files is None: + raise ValueError("Component not found in the template") lib_files = list(LIBS.glob("**/*")) @@ -48,10 +55,9 @@ component.append(environment) component.append(file) - snow_files[0].append(component) + snow_files.extend(component) ElementTree.indent(root, space=" ", level=0) -with WXS_OUTPUT_FILE.expanduser().open("wb") as f: - wxs.write(f, encoding="utf-8") +wxs.write(WXS_OUTPUT_FILE, encoding="utf-8", xml_declaration=True)