1313 ("templates" , "./templates" ),
1414]
1515
16- if sys .platform .startswith ("win" ):
17- added_data_options = [f"--add-data={ src } ;{ dst } " for src , dst in added_files ]
18- else :
19- added_data_options = [f"--add-data={ src } :{ dst } " for src , dst in added_files ]
20-
2116
2217def build_macos (
2318 one_file : bool ,
19+ bundle_third_party : bool ,
2420):
2521 pyinstaller_options = [
2622 "--noconfirm" ,
@@ -32,7 +28,19 @@ def build_macos(
3228 else :
3329 pyinstaller_options += ["--onedir" ]
3430
35- options = pyinstaller_options + added_data_options
31+ if bundle_third_party :
32+ added_binaries = [
33+ ("/usr/local/bin/wkhtmltopdf" , "." ),
34+ ]
35+ added_binary_options = [
36+ f"--add-binary={ src } :{ dst } " for src , dst in added_binaries
37+ ]
38+ else :
39+ added_binary_options = []
40+
41+ added_data_options = [f"--add-data={ src } :{ dst } " for src , dst in added_files ]
42+
43+ options = pyinstaller_options + added_data_options + added_binary_options
3644
3745 logger .info (f"calling pyinstaller with options: { ' ' .join (options )} " )
3846 subprocess .call (
@@ -55,6 +63,8 @@ def build_linux(
5563 else :
5664 pyinstaller_options += ["--onedir" ]
5765
66+ added_data_options = [f"--add-data={ src } :{ dst } " for src , dst in added_files ]
67+
5868 options = pyinstaller_options + added_data_options
5969
6070 logger .info (f"calling pyinstaller with options: { ' ' .join (options )} " )
@@ -79,6 +89,8 @@ def build_windows(
7989 else :
8090 pyinstaller_options += ["--onedir" ]
8191
92+ added_data_options = [f"--add-data={ src } ;{ dst } " for src , dst in added_files ]
93+
8294 options = pyinstaller_options + added_data_options
8395
8496 logger .info (f"calling pyinstaller with options: { ' ' .join (options )} " )
@@ -95,6 +107,9 @@ def main(
95107 one_file : bool = typer .Option (
96108 False , "--one-file" , "-f" , help = "Build a single file executable"
97109 ),
110+ bundle_third_party : bool = typer .Option (
111+ True , "--bundle-third-party" , "-b" , help = "Bundle third party libraries"
112+ ),
98113):
99114 if install_dir :
100115 logger .info (f"removing app from { install_dir } " )
@@ -110,6 +125,7 @@ def main(
110125 logger .info ("building for macOS" )
111126 build_macos (
112127 one_file = one_file ,
128+ bundle_third_party = bundle_third_party ,
113129 )
114130 elif sys .platform .startswith ("win" ):
115131 logger .info ("building for Windows" )
0 commit comments