Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

3 Set up development environment and create install package without setting environment variables

michelleannesimon edited this page Sep 9, 2020 · 4 revisions

Directions

  • Follow these directions if you want to setup a development environment and create an installation package from a command prompt. This can be helpful if you can't easily set environment variables for your user or if you can't easily modify files located directly on C:\ . The instructions below should explain how to do most of this from the command line.

  • First you want to get a development environment set up. You'll do most of the steps listed at https://github.com/USEPA/SWMM-EPANET_User_Interface/wiki/2-Getting-Started-as-a-Developer-in-Python-3 with some modifications.

    set OSGEO4W_ROOT=C:\OSGeo4W64
    set PYCHARM_PATH="C:\Users\cbarr02\AppData\Roaming\JetBrains\PyCharm Community Edition 2019.3.2\bin\pycharm64.exe"
    
    set QGIS=%OSGEO4W_ROOT%\apps\qgis
    set QGIS_PREFIX_PATH=%QGIS%
    
    set PATH=%OSGEO4W_ROOT%\apps\qgis\bin;%OSGEO4W_ROOT%\apps\qgis\python\PyQt5;%OSGEO4W_ROOT%\apps\Python37;%OSGEO4W_ROOT%\apps\Python37\Scripts;%OSGEO4W_ROOT%\apps\Qt5\bin;%OSGEO4W_ROOT%\apps\qt5\plugins;%OSGEO4W_ROOT%\bin;%PYCHARM_HOME%;%PATH%
    
    set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
    set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python;%OSGEO4W_ROOT%\apps\Python37\lib;%OSGEO4W_ROOT%\apps\Python37\DLLs
    
    set QT_QPA_PLATFORM_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\Qt5\plugins\platforms
    set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
    
    
    start "PyCharm aware of QGIS" /B %PYCHARM_PATH% %*
    • I found it more reliable to install the Python packages mentioned in the Wiki from a command prompt. Launch a command prompt in administrator mode and copy the lines from your .bat file that start with set. See this blog post for why you should use python -m pip install instead of pip install. So from the command prompt:
    python -m pip install pandas
    python -m pip install tornado
    python -m pip install pyinstaller==3.4
    
    • Similarly for the SWMM output API, download the wheel then install from the same command prompt using
    python -m pip install /path/to/whl/file/swmm.output-0.4.0.dev2-cp37-cp37m-win_amd64.whl
    
    • You can check that things are working properly from the command prompt. Enter an interactive python session (python -i) then try importing some key libraries (import qgis or import swmm.output).

    • Clone the source code from GitHub as described, checkout the dev-ui-py3qt5 branch, and follow the instructions to get set in PyCharm. You can clone somewhere you have local permissions; you don't need to clone to C:\dev. Make sure you can run frmMainSWMM.py before you proceed.

  • Now that you have a development environment sorted, you can proceed to build the installation packages. You'll basically follow the instructions here: https://github.com/USEPA/SWMM-EPANET_User_Interface/wiki/Create-Installation-Package-for-Windows-10-(python-3-Qt-5-version)

    • Remember that the source code for the GUI refers to what you cloned from GitHub. The src directory, downloaded from the Wiki, is related to OSGeo4W and is placed at C:\src.

    • To create pyconfig.h you can navigate to C:\OSGeo4W64\apps\Python37\include and from your admin command prompt do type nul > pyconfig.h

    • You can delete the hooks from your admin command prompt with del hook-PyQt5.QtWebEngineWidgets.py and del hook-PyQt5.QtWebKitWidgets.py

    • You can copy the files from your admin command prompt with copy path\to\assistant.exe C:\OSGeo4W64\apps\Qt5\bin\assistant.exe and similarly for the help dll and the unzipped src directory.

    • If you are not building at C:\dev, you need to modify the proj_base variable in frmMainSWMM_py3qt5.spec to point to where you have the source code.

    • Build from a normal command prompt, making sure you set the variables first. After it completes check that it worked:

    cd dist\SWMM-UI
    SWMM-UI.exe