Skip to content

Commit 76b0727

Browse files
bpo-46638: Makes registry virtualisation setting stable when building MSIX packages (GH-31130)
(cherry picked from commit 3a5afc1)
1 parent 0d74efc commit 76b0727

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Ensures registry virtualization is consistently disabled. For 3.10 and
2+
earlier, it remains enabled (some registry writes are protected), while for
3+
3.11 and later it is disabled (registry modifications affect all
4+
applications).

PC/layout/support/appxmanifest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,22 @@ def get_appxmanifest(ns):
412412
if value:
413413
node.text = value
414414

415-
winver = sys.getwindowsversion()[:3]
415+
try:
416+
winver = tuple(int(i) for i in os.getenv("APPX_DATA_WINVER", "").split(".", maxsplit=3))
417+
except (TypeError, ValueError):
418+
winver = ()
419+
420+
# Default "known good" version is 10.0.22000, first Windows 11 release
421+
winver = winver or (10, 0, 22000)
422+
416423
if winver < (10, 0, 17763):
417424
winver = 10, 0, 17763
418425
find_or_add(xml, "m:Dependencies/m:TargetDeviceFamily").set(
419-
"MaxVersionTested", "{}.{}.{}.0".format(*winver)
426+
"MaxVersionTested", "{}.{}.{}.{}".format(*(winver + (0, 0, 0, 0)[:4]))
420427
)
421428

422-
if winver > (10, 0, 17763):
429+
# Only for Python 3.11 and later. Older versions do not disable virtualization
430+
if (VER_MAJOR, VER_MINOR) >= (3, 11) and winver > (10, 0, 17763):
423431
disable_registry_virtualization(xml)
424432

425433
app = add_application(

PC/layout/support/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def _unpack_hexversion():
1616
hexversion = int(os.getenv("PYTHON_HEXVERSION"), 16)
1717
except (TypeError, ValueError):
1818
hexversion = sys.hexversion
19-
return struct.pack(">i", sys.hexversion)
19+
return struct.pack(">i", hexversion)
2020

2121

2222
def _get_suffix(field4):

0 commit comments

Comments
 (0)