From ffdc0b842a1de1a05bc3f8236ba2ffd393aae02f Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 28 Apr 2025 22:49:59 +0100 Subject: [PATCH 1/2] Update version calculation and remove unnecessary application for Microsoft Store compatibility --- _msbuild.py | 25 ++++++++++++++++--------- src/pymanager/appxmanifest.xml | 12 ------------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/_msbuild.py b/_msbuild.py index 96e2e77..14bdead 100644 --- a/_msbuild.py +++ b/_msbuild.py @@ -228,17 +228,24 @@ def get_commands(): def _make_xyzw_version(v, sep="."): + """Calculate a suitable x.y.z.w version from our user-friendly version. + + For MSIX in the Store, the fourth field must be 0. + + For MSI, the first field must be <256. + + If the explicit version contains a non-zero field 3, it will override the + one that is calculated from prerelease markers. + """ from packaging.version import parse v = parse(v) - if not v.pre: - return "{0}{4}{1}{4}{2}{4}{3}".format(v.major, v.minor, v.micro, 0xF0, sep) - return "{0}{4}{1}{4}{2}{4}{3}".format( - v.major, - v.minor, - v.micro, - {"a": 0xA0, "b": 0xB0, "rc": 0xC0}.get(v.pre[0].lower(), 0) | v.pre[1], - sep, - ) + micro = 0xF0 + if v.pre: + micro = {"a": 0xA0, "b": 0xB0, "rc": 0xC0}.get(v.pre[0].lower(), 0) | v.pre[1] + if v.micro: + print("[WARNING]Overriding calculated version field 3 with", v) + micro = v.micro + return "{0}{4}{1}{4}{2}{4}{3}".format(v.major, v.minor, micro, 0, sep) def _patch_appx_identity(source, dest, **new): diff --git a/src/pymanager/appxmanifest.xml b/src/pymanager/appxmanifest.xml index 29e7baa..f97b236 100644 --- a/src/pymanager/appxmanifest.xml +++ b/src/pymanager/appxmanifest.xml @@ -49,18 +49,6 @@ Square44x44Logo="_resources/setupx44.png" BackgroundColor="transparent" /> - - - Date: Mon, 28 Apr 2025 23:12:07 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- _msbuild.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_msbuild.py b/_msbuild.py index 14bdead..b8cf388 100644 --- a/_msbuild.py +++ b/_msbuild.py @@ -230,7 +230,7 @@ def get_commands(): def _make_xyzw_version(v, sep="."): """Calculate a suitable x.y.z.w version from our user-friendly version. - For MSIX in the Store, the fourth field must be 0. + For MSIX in the Microsoft Store, the fourth field must be 0. For MSI, the first field must be <256. @@ -245,7 +245,7 @@ def _make_xyzw_version(v, sep="."): if v.micro: print("[WARNING]Overriding calculated version field 3 with", v) micro = v.micro - return "{0}{4}{1}{4}{2}{4}{3}".format(v.major, v.minor, micro, 0, sep) + return sep.join(map(str, (v.major, v.minor, micro, 0))) def _patch_appx_identity(source, dest, **new):