@@ -53,8 +53,27 @@ def get_nsis_exe():
5353 else :
5454 raise RuntimeError ("NSIS is not installed on this computer." )
5555
56- NSIS_EXE = get_nsis_exe ()
56+ NSIS_EXE = get_nsis_exe () # NSIS Compiler
5757
58+ def get_iscc_exe ():
59+ """Return ISCC executable"""
60+ localdir = osp .join (sys .prefix , os .pardir , os .pardir )
61+ for drive in get_drives ():
62+ for dirname in (r'C:\Program Files' , r'C:\Program Files (x86)' ,
63+ # drive+r'PortableApps\NSISPortableANSI',
64+ #drive+r'PortableApps\NSISPortable',
65+ # osp.join(localdir, 'NSISPortableANSI'),
66+ osp .join (localdir , 'NSISPortable' ),
67+ ):
68+ for subdirname in ('.' , 'App' ):
69+ exe = osp .join (dirname , subdirname , 'Inno Setup 5' , 'iscc.exe' )
70+ # include = osp.join(dirname, subdirname, 'Inno Setup 5', 'include')
71+ if osp .isfile (exe ):
72+ return exe
73+ else :
74+ raise RuntimeError ("NSIS is not installed on this computer." )
75+
76+ ISCC_EXE = get_iscc_exe () # Inno Setup Compiler (iscc.exe)
5877
5978def replace_in_nsis_file (fname , data ):
6079 """Replace text in line starting with *start*, from this position:
@@ -70,6 +89,23 @@ def replace_in_nsis_file(fname, data):
7089 lines [idx ] = line [:len (start )+ 1 ] + ('"%s"' % text ) + '\n '
7190 fd = open (fname , 'w' )
7291 fd .writelines (lines )
92+ print ('iss for ' , fname , 'is' , lines )
93+ fd .close ()
94+
95+ def replace_in_iss_file (fname , data ):
96+ """Replace text in line starting with *start*, from this position:
97+ data is a list of (start, text) tuples"""
98+ fd = open (fname , 'U' )
99+ lines = fd .readlines ()
100+ fd .close ()
101+ for idx , line in enumerate (lines ):
102+ for start , text in data :
103+ if start not in ('Icon' , 'OutFile' ) and not start .startswith ('!' ):
104+ start = '#define ' + start
105+ if line .startswith (start + ' ' ):
106+ lines [idx ] = line [:len (start )+ 1 ] + ('"%s"' % text ) + '\n '
107+ fd = open (fname , 'w' )
108+ fd .writelines (lines )
73109 print ('nsis for ' , fname , 'is' , lines )
74110 fd .close ()
75111
@@ -89,6 +125,22 @@ def build_nsis(srcname, dstname, data):
89125 except OSError as e :
90126 print ("Execution failed:" , e , file = sys .stderr )
91127 os .remove (dstname )
128+
129+ def build_iss (srcname , dstname , data ):
130+ """Build Inno Setup Script"""
131+ portable_dir = osp .join (osp .dirname (osp .abspath (__file__ )), 'portable' )
132+ shutil .copy (osp .join (portable_dir , srcname ), dstname )
133+ data = [('PORTABLE_DIR' , portable_dir )
134+ ] + list (data )
135+ replace_in_iss_file (dstname , data )
136+ try :
137+ retcode = subprocess .call ('"%s" "%s"' % (ISCC_EXE , dstname ),
138+ shell = True , stdout = sys .stderr )
139+ if retcode < 0 :
140+ print ("Child was terminated by signal" , - retcode , file = sys .stderr )
141+ except OSError as e :
142+ print ("Execution failed:" , e , file = sys .stderr )
143+ # os.remove(dstname)
92144
93145
94146class WinPythonDistribution (object ):
@@ -387,6 +439,21 @@ def create_installer(self):
387439 build_nsis ('installer.nsi' , fname , data )
388440 self ._print_done ()
389441
442+ def create_installer_inno (self ):
443+ """Create installer with INNO"""
444+ self ._print ("Creating WinPython installer INNO" )
445+ portable_dir = osp .join (osp .dirname (osp .abspath (__file__ )), 'portable' )
446+ fname = osp .join (portable_dir , 'installer_INNO-tmp.iss' )
447+ data = (('DISTDIR' , self .winpydir ),
448+ ('ARCH' , self .winpy_arch ),
449+ ('VERSION' , '%s.%d%s' % (self .python_fullversion ,
450+ self .build_number , self .flavor )),
451+ ('VERSION_INSTALL' , '%s%d' % (self .python_fullversion .replace (
452+ '.' , '' ), self .build_number )),
453+ ('RELEASELEVEL' , self .release_level ),)
454+ build_iss ('installer_INNO.iss' , fname , data )
455+ self ._print_done ()
456+
390457 def _print (self , text ):
391458 """Print action text indicating progress"""
392459 if self .verbose :
@@ -676,7 +743,7 @@ def _create_batch_scripts_initial(self):
676743echo dict:>>%tmp_pyz%
677744echo name = 'Python'>>%tmp_pyz%
678745echo exe = '.\\python.exe'>>%tmp_pyz%
679- echo ipython = 'yes '>>%tmp_pyz%
746+ echo ipython = 'no '>>%tmp_pyz%
680747echo gui = 'none'>>%tmp_pyz%
681748
682749:after_pyzo_conf
@@ -814,7 +881,7 @@ def _create_batch_scripts_initial(self):
814881 dict:| Add-Content -Path $env:tmp_pyz
815882 name = 'Python'| Add-Content -Path $env:tmp_pyz
816883 exe = '.\\python.exe'| Add-Content -Path $env:tmp_pyz
817- ipython = 'yes '| Add-Content -Path $env:tmp_pyz
884+ ipython = 'no '| Add-Content -Path $env:tmp_pyz
818885 gui = 'none'| Add-Content -Path $env:tmp_pyz
819886}
820887
@@ -1166,8 +1233,6 @@ def _create_batch_scripts(self):
11661233if "%QT_API%"=="pyqt5" (
11671234 if exist "%WINPYDIR%\Lib\site-packages\pyqt5-tools\designer.exe" (
11681235 "%WINPYDIR%\Lib\site-packages\pyqt5-tools\designer.exe" %*
1169- ) else if exist "%WINPYDIR%\Lib\site-packages\pyqt5_tools\designer.exe" (
1170- "%WINPYDIR%\Lib\site-packages\pyqt5_tools\designer.exe" %*
11711236 ) else (
11721237 "%WINPYDIR%\Lib\site-packages\PyQt5\designer.exe" %*
11731238 )
@@ -1184,8 +1249,6 @@ def _create_batch_scripts(self):
11841249if "%QT_API%"=="pyqt5" (
11851250 if exist "%WINPYDIR%\Lib\site-packages\pyqt5-tools\assistant.exe" (
11861251 "%WINPYDIR%\Lib\site-packages\pyqt5-tools\assistant.exe" %*
1187- ) else if exist "%WINPYDIR%\Lib\site-packages\pyqt5_tools\assistant.exe" (
1188- "%WINPYDIR%\Lib\site-packages\pyqt5_tools\assistant.exe" %*
11891252 ) else (
11901253 "%WINPYDIR%\Lib\site-packages\PyQt5\assistant.exe" %*
11911254 )
@@ -1200,8 +1263,6 @@ def _create_batch_scripts(self):
12001263if "%QT_API%"=="pyqt5" (
12011264 if exist "%WINPYDIR%\Lib\site-packages\pyqt5-tools\linguist.exe" (
12021265 "%WINPYDIR%\Lib\site-packages\pyqt5-tools\linguist.exe" %*
1203- ) else if exist "%WINPYDIR%\Lib\site-packages\pyqt5_tools\linguist.exe" (
1204- "%WINPYDIR%\Lib\site-packages\pyqt5_tools\linguist.exe" %*
12051266 ) else (
12061267 cd/D "%WINPYDIR%\Lib\site-packages\PyQt5"
12071268 "%WINPYDIR%\Lib\site-packages\PyQt5\linguist.exe" %*
@@ -1497,7 +1558,8 @@ def make_all(build_number, release_level, pyver, architecture,
14971558 my_winpydir = my_winpydir )
14981559 # ,find_links=osp.join(basedir, 'packages.srcreq'))
14991560 if create_installer and not simulation :
1500- dist .create_installer ()
1561+ # dist.create_installer()
1562+ dist .create_installer_inno ()
15011563 return dist
15021564
15031565
0 commit comments