-
Notifications
You must be signed in to change notification settings - Fork 13
Build windows installer
Building a Windows installer of D-Genies is done in two times:
- First, python part of D-Genies is packaged as a standalone executable with
pyinstaller
(this way,python
is not needed on targeted systems) - Second,
Inno Setup
is used to package D-Genies and manage its installation process.
mkdir win_build
cp -rp win32 win_build/
cp -rp src/dgenies/{allowed_extensions.yaml,templates,static,md} win_build/win32/data/dgenies/
cp -p src/bin/dgenies win_build/win32/dgeniesexe.py
In this cookbook, we have used wine-7.0-rc2-staging, but any recent version of wine must be good.
cd win_build
export WINEPREFIX="${PWD}/wine-pyinstall"
WINEARCH="win32" winecfg
In the window that pop up, we check that wine is configured as Windows 7, our minimal target system, and we click OK
Pyinstaller documentation tells we need to include the Visual C++ run-time .dlls. Python 3.5+ needs Visual Studio 2015 run-time
env WINEPREFIX="${PWD}/wine-pyinstall" sh winetricks vcrun2015
TODO:
- Floreal guide seems to use 32 bits python -> switch to x84_64?
- add UPX?
Starting version 3.9, python is only compatible with Windows 8.1+. Python 3.8 is the last compatible with Windows 7, our target. Moreover, python 3.8.11+ has no windows binary. We get the 3.8.10 for x86 (32 bits). In future, we will drop Windows 7.
wget https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe
wget https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe
chmod +x python-3.8.10.exe
For the purpose of automated and silent installation, we create a file called unattend.xml
with following contents. We put it in the same directory that the python installer.
<Options>
<Option Name="InstallAllUsers" Value="1" />
<Option Name="TargetDir" Value="C:\python38" />
<Option Name="DefaultAllUsersTargetDir" Value="C:\python38" />
<Option Name="DefaultJustForMeTargetDir" Value="C:\python38" />
<Option Name="DefaultCustomTargetDir" Value="C:\python38" />
<Option Name="AssociateFiles" Value="0" />
<Option Name="CompileAll" Value="1" />
<Option Name="PrependPath" Value="1" />
<Option Name="Shortcuts" Value="0" />
<Option Name="Include_doc" Value="0" />
<Option Name="Include_debug" Value="0" />
<Option Name="Include_dev" Value="1" />
<Option Name="Include_exe" Value="1" />
<Option Name="Include_launcher" Value="0" />
<Option Name="InstallLauncherAllUsers" Value="0" />
<Option Name="Include_lib" Value="1" />
<Option Name="Include_pip" Value="1" />
<Option Name="Include_symbols" Value="0" />
<Option Name="Include_tcltk" Value="0" />
<Option Name="Include_test" Value="1" />
<Option Name="Include_tools" Value="1" />
<Option Name="LauncherOnly" Value="0" />
<Option Name="SimpleInstall" Value="0" />
<Option Name="SimpleInstallDescription">Python for D-Genies installer builder with wine on Linux</Option>
</Options>
We install then python with following command:
wine ./python-3.8.10.exe /quiet /log python-install.log
For pypi release:
wine "C:\python38\python.exe" -m pip install dgenies --prefer-binary --log ${PWD}/dgenies-install.log
For dev release, build a dist wheel file (.whl), and then use this command:
wine "C:\python38\python.exe" -m pip install </absolute/path/to/dgenies-<version>-py3-none-any.whl> --prefer-binary --log ${PWD}/dgenies-install.log
where you replace </absolute/path/to/dgenies>
with the right path. You can also use the --force-reinstall
option if needed.
We install pyinstaller (version 4.8 when redacting this guide) this way
wine "C:\python38\python.exe" -m pip install pyinstaller --log ${PWD}/pyinstaller-install.log
Done with Inno Setup 6.2
# Last version can be downloaded at https://jrsoftware.org/download.php/is.exe
# We use a stable link here for reproductibility.
wget https://files.jrsoftware.org/is/6/innosetup-6.2.0.exe -O is.exe
chmod +x is.exe
wine ./is.exe /SILENT /ALLUSERS /LOG="innosetup.log" /DIR="C:\innosetup"
cd win32
wine "C:\python38\Scripts\pyinstaller.exe" --icon=data/logo.ico --add-data=data/dgenies:dgenies --clean dgeniesrun.py
wine "C:\innosetup\ISCC.exe" build_setup.iss
Installer is in Output
directory and can be copied where you want:
cp Output/dgenies-*.exe ../
Original author: Floréal Cabanettes (@florealcab)
Download the win32 folder of the repository.
Add in data/dgenies/templates
folder of the win32 folder all files contained in the src/dgenies/templates
folder of the dgenies repository.
Add in data/dgenies/static
folder of the win32 folder all files and folders contained in the src/dgenies/static
folder of the dgenies repository.
Add in data/dgenies/md
folder of the win32 folder all files and folders contained in the src/dgenies/md
folder of the dgenies repository.
Copy the src/bin/dgenies
script from the dgenies repository to the win32 folder and rename it dgeniesexe.py
.
Start by installing dgenies:
pip install dgenies
Then, install pyinstaller, which will create the executable for windows:
pip install pyinstaller
You will also need Inno Setup to build setup file. We use the 5.9 version.
Into the win32 folder, run the following command.
Command:
pyinstaller --icon=data/logo.ico --clean dgeniesrun.py
This will create a dist
folder with inside a dgeniesrun
folder. Other folders will be created, but you can delete them.
Launch build of the build_setup.iss file with InnoSetup. It will create the EXE setup file inside the new Output folder.