@@ -53,8 +53,27 @@ def get_nsis_exe():
53
53
else :
54
54
raise RuntimeError ("NSIS is not installed on this computer." )
55
55
56
- NSIS_EXE = get_nsis_exe ()
56
+ NSIS_EXE = get_nsis_exe () # NSIS Compiler
57
57
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)
58
77
59
78
def replace_in_nsis_file (fname , data ):
60
79
"""Replace text in line starting with *start*, from this position:
@@ -70,6 +89,23 @@ def replace_in_nsis_file(fname, data):
70
89
lines [idx ] = line [:len (start )+ 1 ] + ('"%s"' % text ) + '\n '
71
90
fd = open (fname , 'w' )
72
91
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 )
73
109
print ('nsis for ' , fname , 'is' , lines )
74
110
fd .close ()
75
111
@@ -89,6 +125,22 @@ def build_nsis(srcname, dstname, data):
89
125
except OSError as e :
90
126
print ("Execution failed:" , e , file = sys .stderr )
91
127
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)
92
144
93
145
94
146
class WinPythonDistribution (object ):
@@ -387,6 +439,21 @@ def create_installer(self):
387
439
build_nsis ('installer.nsi' , fname , data)
388
440
self ._print_done ()
389
441
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
+
390
457
def _print (self , text ):
391
458
"""Print action text indicating progress"""
392
459
if self .verbose :
@@ -676,7 +743,7 @@ def _create_batch_scripts_initial(self):
676
743
echo dict:>>%tmp_pyz%
677
744
echo name = 'Python'>>%tmp_pyz%
678
745
echo exe = '.\\python.exe'>>%tmp_pyz%
679
- echo ipython = 'yes '>>%tmp_pyz%
746
+ echo ipython = 'no '>>%tmp_pyz%
680
747
echo gui = 'none'>>%tmp_pyz%
681
748
682
749
:after_pyzo_conf
@@ -814,7 +881,7 @@ def _create_batch_scripts_initial(self):
814
881
dict:| Add-Content -Path $env:tmp_pyz
815
882
name = 'Python'| Add-Content -Path $env:tmp_pyz
816
883
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
818
885
gui = 'none'| Add-Content -Path $env:tmp_pyz
819
886
}
820
887
@@ -1166,8 +1233,6 @@ def _create_batch_scripts(self):
1166
1233
if "%QT_API%"=="pyqt5" (
1167
1234
if exist "%WINPYDIR%\Lib\site-packages\pyqt5-tools\designer.exe" (
1168
1235
"%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" %*
1171
1236
) else (
1172
1237
"%WINPYDIR%\Lib\site-packages\PyQt5\designer.exe" %*
1173
1238
)
@@ -1184,8 +1249,6 @@ def _create_batch_scripts(self):
1184
1249
if "%QT_API%"=="pyqt5" (
1185
1250
if exist "%WINPYDIR%\Lib\site-packages\pyqt5-tools\assistant.exe" (
1186
1251
"%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" %*
1189
1252
) else (
1190
1253
"%WINPYDIR%\Lib\site-packages\PyQt5\assistant.exe" %*
1191
1254
)
@@ -1200,8 +1263,6 @@ def _create_batch_scripts(self):
1200
1263
if "%QT_API%"=="pyqt5" (
1201
1264
if exist "%WINPYDIR%\Lib\site-packages\pyqt5-tools\linguist.exe" (
1202
1265
"%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" %*
1205
1266
) else (
1206
1267
cd/D "%WINPYDIR%\Lib\site-packages\PyQt5"
1207
1268
"%WINPYDIR%\Lib\site-packages\PyQt5\linguist.exe" %*
@@ -1497,7 +1558,8 @@ def make_all(build_number, release_level, pyver, architecture,
1497
1558
my_winpydir = my_winpydir )
1498
1559
# ,find_links=osp.join(basedir, 'packages.srcreq'))
1499
1560
if create_installer and not simulation :
1500
- dist .create_installer ()
1561
+ # dist.create_installer()
1562
+ dist .create_installer_inno ()
1501
1563
return dist
1502
1564
1503
1565
0 commit comments