99 copyfile ,
1010 copytree ,
1111 get_dirs ,
12- get_msix_version ,
1312 get_output_name ,
14- get_sdk_bins ,
1513 rmtree ,
1614 unlink ,
1715)
1816
19- SDK_BINS = get_sdk_bins ()
20-
21- MAKEAPPX = SDK_BINS / "makeappx.exe"
22- MAKEPRI = SDK_BINS / "makepri.exe"
23-
24- for tool in [MAKEAPPX , MAKEPRI ]:
25- if not tool .is_file ():
26- print ("Unable to locate Windows Kit tool" , tool .name , file = sys .stderr )
27- sys .exit (3 )
28-
2917DIRS = get_dirs ()
3018BUILD = DIRS ["build" ]
3119TEMP = DIRS ["temp" ]
3523DIST = DIRS ["dist" ]
3624
3725# Calculate output names (must be after building)
38- NAME = get_output_name (DIRS )
39- VERSION = get_msix_version (DIRS )
40- DIST_MSIX = DIST / f"{ NAME } .msix"
41- DIST_STORE_MSIX = DIST / f"{ NAME } -store.msix"
42- DIST_APPXSYM = DIST / f"{ NAME } -store.appxsym"
43- DIST_MSIXUPLOAD = DIST / f"{ NAME } -store.msixupload"
26+ DIST_MSIX = DIST / get_output_name (LAYOUT )
27+ DIST_STORE_MSIX = DIST_MSIX .with_name (f"{ DIST_MSIX .stem } -store.msix" )
28+ DIST_APPXSYM = DIST_STORE_MSIX .with_suffix (".appxsym" )
29+ DIST_MSIXUPLOAD = DIST_STORE_MSIX .with_suffix (".msixupload" )
4430
4531unlink (DIST_MSIX , DIST_STORE_MSIX , DIST_APPXSYM , DIST_MSIXUPLOAD )
4632
47- # Generate resources info in LAYOUT
48- if not (LAYOUT / "_resources.pri" ).is_file ():
49- run ([MAKEPRI , "new" , "/o" ,
50- "/pr" , LAYOUT ,
51- "/cf" , SRC / "pymanager/resources.xml" ,
52- "/of" , LAYOUT / "_resources.pri" ,
53- "/mf" , "appx" ])
54-
55- # Clean up non-shipping files from LAYOUT
56- preserved = [
57- * LAYOUT .glob ("pyshellext*.dll" ),
58- ]
59-
60- for f in preserved :
61- print ("Preserving" , f , "as" , TEMP / f .name )
62- copyfile (f , TEMP / f .name )
63-
64- unlink (
65- * LAYOUT .rglob ("*.pdb" ),
66- * LAYOUT .rglob ("*.pyc" ),
67- * LAYOUT .rglob ("__pycache__" ),
68- * preserved ,
69- )
70-
7133# Package into DIST
72- run ([MAKEAPPX , "pack " , "/o " , "/d " , LAYOUT , "/p" , DIST_MSIX ])
34+ run ([sys . executable , "-m " , "pymsbuild " , "pack " , "-v" ])
7335
7436print ("Copying appinstaller file to" , DIST )
75- copyfile (LAYOUT / "pymanager.appinstaller" , DIST / "pymanager.appinstaller" )
37+ copyfile (LAYOUT / "python-manager/ pymanager.appinstaller" , DIST / "pymanager.appinstaller" )
7638
7739
7840if os .getenv ("PYMANAGER_APPX_STORE_PUBLISHER" ):
7941 # Clone and update layout for Store build
8042 rmtree (LAYOUT2 )
8143 copytree (LAYOUT , LAYOUT2 )
82- unlink (* LAYOUT2 .glob ("*.appinstaller" ))
44+ unlink (* LAYOUT2 .glob ("python-manager/ *.appinstaller" ))
8345
8446 def patch_appx (source ):
8547 from xml .etree import ElementTree as ET
@@ -116,9 +78,16 @@ def patch_appx(source):
11678 with open (source , "wb" ) as f :
11779 xml .write (f , "utf-8" )
11880
119- patch_appx (LAYOUT2 / "appxmanifest.xml" )
81+ patch_appx (LAYOUT2 / "python-manager/ appxmanifest.xml" )
12082
121- run ([MAKEAPPX , "pack" , "/o" , "/d" , LAYOUT2 , "/p" , DIST_STORE_MSIX ])
83+ run (
84+ [sys .executable , "-m" , "pymsbuild" , "pack" , "-v" ],
85+ env = {
86+ ** os .environ ,
87+ "PYMSBUILD_LAYOUT_DIR" : str (LAYOUT2 ),
88+ "PYMSBUILD_MSIX_NAME" : DIST_STORE_MSIX .name ,
89+ }
90+ )
12291
12392 # Pack symbols
12493 print ("Packing symbols to" , DIST_APPXSYM )
@@ -131,9 +100,3 @@ def patch_appx(source):
131100 with zipfile .ZipFile (DIST_MSIXUPLOAD , "w" ) as zf :
132101 zf .write (DIST_STORE_MSIX , arcname = DIST_STORE_MSIX .name )
133102 zf .write (DIST_APPXSYM , arcname = DIST_APPXSYM .name )
134-
135-
136- for f in preserved :
137- print ("Restoring" , f , "from" , TEMP / f .name )
138- copyfile (TEMP / f .name , f )
139- unlink (TEMP / f .name )
0 commit comments