@@ -40,20 +40,25 @@ def build_with_pdm_packer():
40
40
print ("Building with pdm-packer..." )
41
41
ensure_dist_dir ()
42
42
os .environ ["PYTHONOPTIMIZE" ] = "2"
43
- result = subprocess .run ([
44
- shutil .which ("pdm" ),
45
- "pack" ,
46
- "-m" , "vcf_generator_lite.__main__:main" ,
47
- "-o" , os .path .join ("dist" , OUTPUT_BASE_NAME_TEMPLATE .format (
48
- version = APP_VERSION ,
49
- platform = PLATFORM_PYTHON ,
50
- distribution = "zipapp"
51
- ) + ".pyzw" ),
52
- "--interpreter" , f"/usr/bin/env python{ PYTHON_VERSION } " ,
53
- "--compile" ,
54
- "--compress" ,
55
- "--no-py" ,
56
- ])
43
+ result = subprocess .run (
44
+ [
45
+ shutil .which ("pdm" ),
46
+ "pack" ,
47
+ "-m" ,
48
+ "vcf_generator_lite.__main__:main" ,
49
+ "-o" ,
50
+ os .path .join (
51
+ "dist" ,
52
+ OUTPUT_BASE_NAME_TEMPLATE .format (version = APP_VERSION , platform = PLATFORM_PYTHON , distribution = "zipapp" )
53
+ + ".pyzw" ,
54
+ ),
55
+ "--interpreter" ,
56
+ f"/usr/bin/env python{ PYTHON_VERSION } " ,
57
+ "--compile" ,
58
+ "--compress" ,
59
+ "--no-py" ,
60
+ ]
61
+ )
57
62
print ("Building finished." )
58
63
return result .returncode
59
64
@@ -66,29 +71,32 @@ def pack_with_innosetup() -> int:
66
71
return result
67
72
68
73
os .environ ["PATH" ] += os .pathsep + "C:\\ Program Files (x86)\\ Inno Setup 6\\ "
69
- result = subprocess .run ([
70
- shutil .which ("iscc" ),
71
- "/D" + f"OutputBaseFilename={ OUTPUT_BASE_NAME_TEMPLATE .format (
74
+ result = subprocess .run (
75
+ [
76
+ shutil .which ("iscc" ),
77
+ "/D"
78
+ + f"OutputBaseFilename={ OUTPUT_BASE_NAME_TEMPLATE .format (
72
79
version = APP_VERSION ,
73
80
platform = PLATFORM_NATIVE ,
74
81
distribution = "setup"
75
82
)} " ,
76
- "/D" + f"MyAppCopyright={ APP_COPYRIGHT } " ,
77
- "/D" + f"MyAppVersion={ APP_VERSION } " ,
78
- os .path .abspath ('setup.iss' ),
79
- ])
83
+ "/D" + f"MyAppCopyright={ APP_COPYRIGHT } " ,
84
+ "/D" + f"MyAppVersion={ APP_VERSION } " ,
85
+ os .path .abspath ("setup.iss" ),
86
+ ]
87
+ )
80
88
print ("Packaging finished." )
81
89
return result .returncode
82
90
83
91
84
92
def pack_with_zipfile ():
85
93
print ("Packaging with ZipFile..." )
86
94
require_pyinstaller_output ()
87
- zip_path = os .path .join ("dist" , OUTPUT_BASE_NAME_TEMPLATE . format (
88
- version = APP_VERSION ,
89
- platform = PLATFORM_NATIVE ,
90
- distribution = "portable"
91
- ) + ".zip" )
95
+ zip_path = os .path .join (
96
+ "dist" ,
97
+ OUTPUT_BASE_NAME_TEMPLATE . format ( version = APP_VERSION , platform = PLATFORM_NATIVE , distribution = "portable" )
98
+ + ".zip" ,
99
+ )
92
100
with ZipFile (zip_path , "w" ) as zip_file :
93
101
for path , dirs , files in os .walk (os .path .join ("dist" , "vcf_generator_lite" )):
94
102
for file_path in [os .path .join (path , file ) for file in files ]:
@@ -99,11 +107,12 @@ def pack_with_zipfile():
99
107
def main () -> int :
100
108
parser = argparse .ArgumentParser ()
101
109
parser .add_argument (
102
- "-t" , "--type" ,
110
+ "-t" ,
111
+ "--type" ,
103
112
type = str ,
104
113
default = "installer" ,
105
114
choices = ["installer" , "portable" , "zipapp" ],
106
- help = "应用打包类型(默认:%(default)s)"
115
+ help = "应用打包类型(默认:%(default)s)" ,
107
116
)
108
117
args = parser .parse_args ()
109
118
0 commit comments