8000 switch from NSIS to INNO installer · ericpre/winpython@938fa61 · GitHub
[go: up one dir, main page]

Skip to content

Commit 938fa61

Browse files
committed
switch from NSIS to INNO installer
1 parent 05ae7eb commit 938fa61

8 files changed

+238
-17
lines changed

generate_a_winpython_distro.bat

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ rem to launch from a winpython package directory, where 'make.py' is
22
@echo on
33
rem this is initialised per the calling .bat
44
rem set my_original_path=%path%
5-
rem set my_buildenv=C:\winpython-64bit-3.4.3.7Qt5
5+
rem set my_buildenv=C:\WinPython-64bit-3.4.3.7Qt5
66
rem set my_root_dir_for_builds=D:\Winp
77

88
rem set my_python_target=34
@@ -29,12 +29,14 @@ if %my_python_target%==27 set my_release=2
2929

3030
if %my_python_target%==34 set my_release=8
3131

32-
if %my_python_target%==35 set my_release=2
32+
if %my_python_target%==35 set my_release=3
3333

3434
if %my_python_target%==36 set my_release=0
3535

3636
if %my_python_target%==37 set my_release=0
3737

38+
rem **** 2018-10-30 create_installer **
39+
if "%my_create_installer%"=="" set my_create_installer=True
3840
rem ***********************************************************
3941

4042
rem set my_flavor=Slim
@@ -119,8 +121,8 @@ call %my_buildenv%\scripts\env.bat
119121

120122
rem build with this
121123
cd /D %~dp0
122-
echo python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', requirements=r'%my_requirements%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%')">>%my_archive_log%
123-
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', requirements=r'%my_requirements%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%')">>%my_archive_log%
124+
echo python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', requirements=r'%my_requirements%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%', create_installer=%my_create_installer%)">>%my_archive_log%
125+
python.exe -c "from make import *;make_all(%my_release%, '%my_release_level%', pyver='%my_pyver%', basedir=r'%my_basedir%', verbose=True, architecture=%my_arch%, flavor='%my_flavor%', requirements=r'%my_requirements%', install_options=r'%my_install_options%', find_links=r'%my_find_links%', source_dirs=r'%my_source_dirs%', toolsdirs=r'%my_toolsdirs%', docsdirs=r'%my_docsdirs%', create_installer=%my_create_installer%)">>%my_archive_log%
124126

125127
echo ===============>>%my_archive_log%
126128
echo END OF creation>>%my_archive_log%

generate_winpython_distros37_qt5.bat

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
rem this replace running manually from spyder the make.py
2+
rem to launch from a winpython module 'make' directory
3+
4+
set my_original_path=%path%
5+
set my_buildenv=C:\winpython-64bit-3.4.3.7Qt5
6+
7+
set my_root_dir_for_builds=C:\Winp
8+
set my_python_target=37
9+
set my_pyver=3.7
10+
11+
set my_flavor=
12+
13+
set my_release=0
14+
15+
set my_release_level=
16+
17+
set my_install_options=--no-index --pre --trusted-host=None
18+
set my_find_links=C:\Winp\packages.srcreq
19+
set my_docsdirs=C:\Winp\bd37\docs
20+
21+
22+
set tmp_reqdir=%my_root_dir_for_builds%\bd%my_python_target%
23+
24+
set my_arch=32
25+
set my_requirements=C:\Winp\bd37\Qt5_requirements.txt
26+
set my_source_dirs=C:\Winp\bd37\packages.win32.Qt5
27+
set my_toolsdirs=C:\Winp\bd37\Tools
28+
29+
set my_preclear_build_directory=Yes
30+
call %~dp0\generate_a_winpython_distro.bat
31+
32+
set my_arch=64
33+
set my_requirements=C:\Winp\bd37\Qt5_requirements64.txt
34+
set my_source_dirs=C:\Winp\bd37\packages.win-amd64.Qt5
35+
set my_toolsdirs=C:\Winp\bd37\Tools64
36+
37+
set my_preclear_build_directory=No
38+
39+
40+
call %~dp0\generate_a_winpython_distro.bat
41+
42+
43+
pause

make.py

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5978
def 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

94146
class 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):
676743
echo dict:>>%tmp_pyz%
677744
echo name = 'Python'>>%tmp_pyz%
678745
echo exe = '.\\python.exe'>>%tmp_pyz%
679-
echo ipython = 'yes'>>%tmp_pyz%
746+
echo ipython = 'no'>>%tmp_pyz%
680747
echo 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):
11661233
if "%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):
11841249
if "%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):
12001263
if "%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

portable/config.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;!@Install@!UTF-8!
2+
Title="WinPython"
3+
BeginPrompt="Do you want to install WinPython?"
4+
InstallPath="."
5+
;!@InstallEnd@!

portable/images/installer_logo.bmp

6.8 KB
Binary file not shown.

portable/installer_INNO.iss

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
; Script generated by the Inno Setup Script Wizard.
2+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3+
4+
;WinPython Inno Setup Installer script
5+
;Copyright © 2018 WinPython team
6+
;Licensed under the terms of the MIT License
7+
;(see winpython/__init__.py for details)
8+
9+
;================================================================
10+
; These lines are automatically replaced when creating installer:
11+
; (see winpython/make.py)
12+
#define DISTDIR "C:\WinP\bd36\buPs2\winp64-3.6.x.0"
13+
#define ARCH "64bit"
14+
#define VERSION "3.6.7.0Ps2"
15+
; 2018-04-04 need to minimize path length of installation further: remove flavor in install path
16+
#define VERSION_INSTALL "3670"
17+
#define RELEASELEVEL "beta3" ; empty means final release
18+
;================================================================
19+
20+
#define ID "Winpython"
21+
; 2018-04-20 need to minimize path length of installation:
22+
;#define ID_INSTALL "WinPython"
23+
#define ID_INSTALL "WPy"
24+
#define FILE_DESCRIPTION "{#ID} Installer"
25+
#define COMPANY "{#ID}"
26+
#define BRANDING "{#ID}, the portable Python Distribution for Scientists"
27+
#define COPYRIGHT "Copyright © 2018+ WinPython Team"
28+
#define PORTABLE_DIR "C:\WinPython-64bit-3.4.3.7Qt5\winpython_github20181029\portable"
29+
#define MyAppPublisher "WinPython team"
30+
#define MyAppURL "https://winpython.github.io/"
31+
32+
;OutFile "${DISTDIR}\..\${ID}${ARCH}-${VERSION}${RELEASELEVEL}.exe"
33+
#define MyBinaryOutputDir "C:\WinP\bd37\buZero"
34+
; nota: OutputBaseFilename "{#ID}{#ARCH}-{#VERSION}{#RELEASELEVEL}"
35+
#define MyInstallerDir "WPy-3710b3"
36+
37+
[Setup]
38+
;don't write in registery
39+
CreateUninstallRegKey=no
40+
;give choice of install (same logic)
41+
UsePreviousAppDir=no
42+
43+
; if ever wanted FLIPFLAP (see Task section also)
44+
;Uninstallable=not IsTaskSelected('portablemode')
45+
46+
; NOTE: The value of AppId uniquely identifies this application.
47+
; Do not use the same AppId value in installers for other applications.
48+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
49+
AppId={{0012652B-17E7-4C1F-815B-0DE013D47DA0}
50+
AppName={#ID}{#VERSION}
51+
AppVersion={#VERSION} {#COPYRIGHT}
52+
AppVerName={#VERSION_INSTALL}
53+
AppPublisher={#MyAppPublisher}
54+
AppPublisherURL={#MyAppURL}
55+
AppSupportURL={#MyAppURL}
56+
AppUpdatesURL={#MyAppURL}
57+
58+
;non portable mode if ever wanted FLIPFLAP
59+
;DefaultDirName={pf}\{#MyInstallerDir}
60+
;non portable mode
61+
DefaultDirName={src}\{#MyInstallerDir}
62+
63+
DefaultGroupName={#ID}
64+
DisableProgramGroupPage=yes
65+
LicenseFile={#PORTABLE_DIR}\license.txt
66+
;InfoBeforeFile={#PORTABLE_DIR}\licence_info.txt
67+
;OutputDir={#MyBinaryOutputDir}
68+
OutputDir={#DISTDIR}\..
69+
OutputBaseFilename={#ID}{#ARCH}-{#VERSION}{#RELEASELEVEL}
70+
SetupIconFile={#PORTABLE_DIR}\icons\install.ico
71+
72+
; When set to none, Setup will only run with administrative privileges if it
73+
; was started by a member of the Administrators group.
74+
; On pre vista: will *not* run with administrative privileges
75+
PrivilegesRequired = none
76+
77+
; If True, Setup will refresh env/associations in explorer after install
78+
ChangesEnvironment = no
79+
ChangesAssociations = no
80+
81+
; decrepited WizardImageBackColor=$d28b26
82+
WizardImageStretch=no
83+
WizardImageFile={#PORTABLE_DIR}\images\installer_logo.bmp
84+
WizardSmallImageFile={#PORTABLE_DIR}\images\installer_logo.bmp
85+
86+
AllowNoIcons = yes
87+
88+
Compression = lzma2
89+
SolidCompression = yes
90+
;LZMAUseSeparateProcess = yes
91+
;LZMANumBlockThreads = 2
92+
93+
; 2048 = normal; 8192=max ; 4096=ideal
94+
LZMADictionarySize = 4096
95+
96+
;LZMANumFastBytes = 273
97+
98+
[Tasks]
99+
; if ever wanted FLIPFLAP
100+
;Name: portablemode; Description: "Portable Mode"
101+
102+
103+
[Languages]
104+
Name: "english"; MessagesFile: "compiler:Default.isl"
105+
106+
[Files]
107+
Source: {#DISTDIR}\*; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
108+
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
109+

portable/license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ following license agreement.
1313
WinPython License Agreement (MIT License)
1414
-----------------------------------------
1515

16-
Copyright (c) 2012 Pierre Raybaut
16+
Copyright (c) 2012 Pierre Raybaut, 2016+ WinPython team
1717

1818
Permission is hereby granted, free of charge, to any person
1919
obtaining a copy of this software and associated documentation

winpython/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-----------------------------------------
55
66
Copyright (c) 2012-2013 Pierre Raybaut
7-
Copyright (c) 2014-2016 The Winpython development team https://github.com/winpython/
7+
Copyright (c) 2014-2018 The Winpython development team https://github.com/winpython/
88
99
Permission is hereby granted, free of charge, to any person
1010
obtaining a copy of this software and associated documentation
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '1.10.20181020'
31+
__version__ = '1.11.20181031'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

0 commit comments

Comments
 (0)
0