-
Notifications
You must be signed in to change notification settings - Fork 69
4 Create Installation Package for Windows 10 (python 3 Qt 5 version)
First step is to properly setup the development environment using the suggested setup process. This includes checking out the source code from git repo. This instruction assumes that the source codes are saved into C:\dev\SWMM-EPANET_User_Interface\ directory. After setting up the development environment, please install PyInstaller(*) and tornado python packages in the development environment.
*Note, PyInstaller 3.6 did not work successfully in this process -- possibly due to a bug in that version -- but PyInstaller 3.4 works, so that is the recommended version.
Next, we need to do a few preparations as listed below:
a). Need to create an empty file, pyconfig.h, in the folder C:\OSGeo4W64\apps\Python37\include
b). Remove the following files (hook-PyQt5.QtWebEngineWidgets.py and hook-PyQt5.QtWebKitWidgets.py) from C:\OSGeo4W64\apps\Python37\Lib\site-packages\PyInstaller\hooks\ folder
c). Put the following files into 'C:\OSGeo4W64\apps\Qt5\bin' folder: assistant.exe, Qt5Help.dll
d). Download the src.zip file, unzip it to C:\src folder [NOTE: on windows 10, after download, please right-mouse-click on the zip file and go to 'Properties' and check 'Unblock' checkbox then apply]
Next, change into the directory containing the model-specific main form, remove any previously created package, and run pyinstaller.
For SWMM:
cd SWMM-EPANET_User_Interface\src\ui\SWMM
rmdir /S /Q build dist
pyinstaller --clean frmMainSWMM_py3qt5.spec
For EPANET, these steps are similar:
cd SWMM-EPANET_User_Interface\src\ui\EPANET
rmdir /S /Q build dist
pyinstaller --clean frmMainEPANET_py3qt5.spec
It is expected for there to be a lot of warnings. This will take some time to complete and it will create two folders: build and dist. The build folder can be ignored or deleted. The dist folder contains one folder which has all that is needed to run the software, with the main executable named after the main form. For SWMM, this folder will be SWMM-EPANET_User_Interface\src\ui\SWMM\dist\SWMM-UI, for EPANET it will be SWMM-EPANET_User_Interface\src\ui\EPANET\dist\EPANET-UI, which will be referred to as *-UI folder in the remainder of this document. Copy a few additional items into this folder before proceeding:
- copy
C:\OSGeo4W64\apps\qgis\resources\folder into*-UI\folder
Test by running the executable SWMM-UI.exe or EPANET-UI.exe. When the main application window is displayed, then it is a success.
If the installed version has a side-by-side error, rebuild the package and add --clean to the end of the pyinstaller command. This clears out pyinstaller's cache which may contain stale items.
Optional: Remove any unnecessary libraries included by PyInstaller. Sometimes PyInstaller includes more than the application needs. After removing libraries that seem unnecessary, test all of the features of the application to make sure everything still works.
The dist\SWMM-UI and dist\EPANET-UI folders can be zipped up into an archive and sent to users running 64-bit Windows 10 and they can unzip and run it. (See also the Inno Setup configuration file described below for additional files that are included in the provided packages.)
For user convenience, the additional step can be taken of building an Inno Setup install package from this folder. Inno Setup is a free installer for Windows and is available at:
http://www.jrsoftware.org/isinfo.php
The Inno Setup configuration file for building each package is included in the repository:
https://github.com/USEPA/SWMM-EPANET_User_Interface/blob/master/src/ui/SWMM/SWMM-UI-py3qt5.iss
https://github.com/USEPA/SWMM-EPANET_User_Interface/blob/master/src/ui/EPANET/EPANET-UI_py3qt5.iss