@@ -60,30 +60,21 @@ def get_nsis_exe():
6060 raise RuntimeError ("NSIS is not installed on this computer." )
6161
6262
63- NSIS_EXE = get_nsis_exe () # NSIS Compiler
64-
65-
6663def get_iscc_exe ():
6764 """Return ISCC executable"""
6865 localdir = str (Path (sys .prefix ).parent .parent )
6966 for drive in get_drives ():
7067 for dirname in (
7168 r"C:\Program Files" ,
7269 r"C:\Program Files (x86)" ,
73- # drive+r'PortableApps\NSISPortableANSI',
74- # drive+r'PortableApps\NSISPortable',
7570 str (Path (localdir ) / "Inno Setup 5" ),
7671 ):
7772 for subdirname in ("." , "App" ):
7873 exe = str (Path (dirname ) / subdirname / "Inno Setup 5" / "iscc.exe" )
7974 if Path (exe ).is_file ():
8075 return exe
8176 else :
82- # raise RuntimeError(
83- print ("Inno Setup 5 is not installed on this computer." )
84-
85-
86- ISCC_EXE = get_iscc_exe () # Inno Setup Compiler (iscc.exe)
77+ raise RuntimeError ("Inno Setup 5 is not installed on this computer." )
8778
8879
8980def get_7zip_exe ():
@@ -100,10 +91,7 @@ def get_7zip_exe():
10091 if Path (exe ).is_file ():
10192 return exe
10293 else :
103- raise RuntimeError ("7-Zip is not installed on this computer." )
104-
105-
106- SEVENZIP_EXE = get_7zip_exe () # Inno Setup Compiler (iscc.exe)
94+ raise RuntimeError ("NSIS is not installed on this computer." )
10795
10896
10997def replace_in_nsis_file (fname , data ):
@@ -171,6 +159,7 @@ def replace_in_7zip_file(fname, data):
171159
172160def build_nsis (srcname , dstname , data ):
173161 """Build NSIS script"""
162+ NSIS_EXE = get_nsis_exe () # NSIS Compiler
174163 portable_dir = str (Path (__file__ ).resolve ().parent / "portable" )
175164 shutil .copy (str (Path (portable_dir ) / srcname ), dstname )
176165 data = [
@@ -264,22 +253,24 @@ def updateExecutableIcon(executablePath, iconPath):
264253
265254
266255def build_shimmy_launcher (launcher_name , command , icon_path ):
267- """Build shimmy script """
268- # access to mkshim.py
269- # define where is mkshim
256+ """Build .exe launcher with mkshim.py and pywin32 """
257+
258+ # define where is mkshim.py
270259 mkshim_program = str (Path (__file__ ).resolve ().parent / "mkshim.py" )
271260 python_program = utils .get_python_executable ()
272261
273- # Create the executable using mkshim
262+ # Create the executable using mkshim.py
274263 mkshim_command = f'{ python_program } "{ mkshim_program } " -f "{ launcher_name } " -c "{ command } "'
275- print ("zzzz Building shimmy :" , mkshim_command )
264+ print ("Building .exe launcher with mkshim.py :" , mkshim_command )
276265 subprocess .run (mkshim_command , shell = True )
277266
278- # Embed the icon pywin32
279- updateExecutableIcon (launcher_name , icon_path )
267+ # Embed the icon with pywin32, if provided
268+ if Path (icon_path ).is_file ():
269+ updateExecutableIcon (launcher_name , icon_path )
280270
281271def build_iss (srcname , dstname , data ):
282272 """Build Inno Setup Script"""
273+ ISCC_EXE = get_iscc_exe () # Inno Setup Compiler (iscc.exe)
283274 portable_dir = str (Path (__file__ ).resolve ().parent / "portable" )
284275 shutil .copy (str (Path (portable_dir ) / srcname ), dstname )
285276 data = [("PORTABLE_DIR" , portable_dir )] + list (data )
@@ -303,6 +294,7 @@ def build_iss(srcname, dstname, data):
303294
304295def build_7zip (srcname , dstname , data ):
305296 """7-Zip Setup Script"""
297+ SEVENZIP_EXE = get_7zip_exe ()
306298 portable_dir = str (Path (__file__ ).resolve ().parent / "portable" )
307299 shutil .copy (str (Path (portable_dir ) / srcname ), dstname )
308300 data = [
@@ -599,38 +591,20 @@ def create_launcher_shimmy(
599591 command = None ,
600592 args = None ,
601593 workdir = r"$EXEDIR\scripts" ,
602- launcher = "launcher_basic.nsi" ,
603594 ):
604- """Create exe launcher with NSIS """
595+ """Create exe launcher with mkshim.py """
605596 assert name .endswith (".exe" )
606597 portable_dir = str (Path (__file__ ).resolve ().parent / "portable" )
607598 icon_fname = str (Path (portable_dir ) / "icons" / icon )
608599 assert Path (icon_fname ).is_file ()
609600
610- # Customizing NSIS script
601+ # prepare mkshim.py script
611602 if command is None :
612603 if args is not None and ".pyw" in args :
613604 command = "${WINPYDIR}\pythonw.exe"
614605 else :
615606 command = "${WINPYDIR}\python.exe"
616- if args is None :
617- args = ""
618- if workdir is None :
619- workdir = ""
620- fname = str (Path (self .winpydir ) / (Path (name ).stem + ".nsi" ))
621-
622- data = [
623- ("WINPYDIR" , f"$EXEDIR\{ self .python_name } " ),
624- ("WINPYVER" , self .winpyver ),
625- ("COMMAND" , command ),
626- ("PARAMETERS" , args ),
627- ("WORKDIR" , workdir ),
628- ("Icon" , icon_fname ),
629- ("OutFile" , name ),
630- ]
631607 iconlauncherfullname = str (Path (self .winpydir ) / name )
632-
633- print ("yyyy Buildin shimmy:" , iconlauncherfullname , command , icon_fname )
634608 true_command = command .replace (r"$SYSDIR\cmd.exe" ,"cmd.exe" )+ " " + args
635609 build_shimmy_launcher (iconlauncherfullname , true_command , icon_fname )
636610
0 commit comments