User Tools

Site Tools


proj:wininstallers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
proj:wininstallers [2019/07/07 03:02]
admin
proj:wininstallers [2019/10/14 00:36] (current)
114.23.208.115 [Create working folders]
Line 3: Line 3:
 [[:​proj:​project | Project]] [[:​proj:​project | Project]]
  
-====== Windows ​NSIS Installer Notes ======+====== Windows Installer Notes ======
  
-===== Make Package =====+===== What Next ===== 
 + 
 +If already set up dev pipeline on machine go straight to "Make Package ​- Overview"​. 
 + 
 +Otherwise, "​Windows Development and Packaging - From Scratch"​ 
 + 
 +===== Make Package - Overview ​=====
  
   * Update sofawin/​licence.txt if necessary   * Update sofawin/​licence.txt if necessary
-  * cd C:​\sofa_dev_win\sofastatistics+  * cd D:​\sofa_dev_win\sofastatistics
   * git pull (SSH passphrase "​matilda loves linux better"​)   * git pull (SSH passphrase "​matilda loves linux better"​)
   * bring across licence.txt if changed   * bring across licence.txt if changed
-  * Copy contents of C:​\sofa_dev_win\sofastatistics\sofastats over top of C:​\sofa_dev_win\packaging\sofastats (leaving behind tests, eclipse project files, __pycache__ folders, and any exes such as convert.exe and wkhtmltopdf.exe)+  * Copy contents of D:​\sofa_dev_win\sofastatistics\sofastats over top of D:​\sofa_dev_win\sofa4packaging\sofastats (leaving behind tests, eclipse project files, __pycache__ folders, and any exes such as convert.exe and wkhtmltopdf.exe)
   * Eliminate debug = True (esp dev_debug = True in home.py)   * Eliminate debug = True (esp dev_debug = True in home.py)
-  * Delete build and dist folders under C:​\sofa_dev_win\packaging\sofastats (to ensure clean build)+  * Delete build and dist folders under D:​\sofa_dev_win\sofa4packaging\sofastats (to ensure clean build)
   * Create executable   * Create executable
  
-  cd C:​\sofa_dev_win\packaging\sofastats\+  cd D:​\sofa_dev_win\sofa4packaging\sofastats\
   pyinstaller sofastats.spec   pyinstaller sofastats.spec
  
-  * Under C:​\sofa_dev_win\packaging\sofastats\ copy everything but __pycache__,​ build, and dist into dist\sofastats. +  * Under D:​\sofa_dev_win\sofa4packaging\sofastats\ copy everything but __pycache__,​ build, and dist into dist\sofastats. 
-  * Change the version at the top of In C:​\sofa_dev_win\1 sofastats.nsi:​+  * Change the version at the top of In D:​\sofa_dev_win\packaging\1 sofastats.nsi:​
  
-  !define SOFA_VERSION "1.5.2"+  !define SOFA_VERSION "1.5.3"
  
-  * In C:​\sofa_dev_win\ right click on  "1 sofastats.nsi"​ and "​compile NSIS script"​ then click on "Test Installer"​ button.+  * In D:​\sofa_dev_win\packaging ​right click on  "1 sofastats.nsi"​ and "​compile NSIS script"​ then click on "Test Installer"​ button.
   * Run SOFA from icon on Desktop   * Run SOFA from icon on Desktop
-  * (Assuming OK) copy sofastats-1.5.2_for_win.exe to the USB for safe-keeping+  * (Assuming OK) copy sofastats-x.x.x_for_win.exe to the USB for safe-keeping
   * Compress to zip folder so sofastats-x.x.x_for_win.zip   * Compress to zip folder so sofastats-x.x.x_for_win.zip
-===== Windows Development and Packaging =====+ 
 +===== Windows Development and Packaging ​- From Scratch ​=====
  
 In short, how we get from a clean Windows machine to a development (to fix Windows-specific bugs) and packaging environment for SOFA. In short, how we get from a clean Windows machine to a development (to fix Windows-specific bugs) and packaging environment for SOFA.
Line 34: Line 41:
 ==== Create working folders ==== ==== Create working folders ====
  
-Make C:​\sofa_dev_win+Make D:​\sofa_dev_win
  
 Under that put: Under that put:
  
-  * sofastatistics (actually, don't make it directly - instead, add it when cloning the git repo). This is the code. Make changes here to get SOFA working on Windows and push the changes up into origin. +  ​* **sofastatistics** (actually, don't make it directly - instead, add it when cloning the git repo). This is the code. Can make changes here to get SOFA working on Windows and push the changes up into origin. ​Update this folder then copy across contents to sofa4packaging/​sofastats to keep the version to be packaged up-to-date 
-  * packaging folder ​everything used for packaging ​goes in herePut contents of sofastatistics under the packaging/​sofastats folder and add launch.py, import2run.py,​ and sofastats.spec as well from sofa_dev_win+  * **dependencies** ​binaries such as wkhtmltopdf.exe and specific dependencies of those binaries e.g. delegates.xml (needed by convert.exe) 
-  * store - put junk here to avoid polluting / overcomplicating ​other folders+  * **packaging** - put all the files managing the actual building of packages e.g. spec files, nsi files etc. 
 +  * **sofa4packaging** - put contents of sofastatistics under the packaging/​sofastats folder and add launch.py, import2run.py,​ and sofastats.spec as well from /packaging. Leave behind __pycache__,​ app.fil and sofastats.pot
 +  ​* **store** - put junk here to avoid polluting / over-complicating ​other folders
  
 ==== Python and dependencies installed ==== ==== Python and dependencies installed ====
  
-Set up prerequisites for running SOFA working on Windows at all - install Python 3.7 and all required pip and system dependencies (perhaps PostgreSQL)+Set up prerequisites for running SOFA working on Windows at all - install Python 3.7 (https://​www.python.org/​downloads/​) ​and all required pip and system dependencies (perhaps PostgreSQL). See list of dependencies further down. Allow Python to be set in PATH. No need to specify full path to python exe every time.
  
-Must pip install ​as admin and install into "C:\Program Files (x86)\Python37-32\" e.g. ..\lib\site-packages+Target ​pip installations at the python you will be building against (possibly only one). No need to be admin for pip installations unless Python was installed ​as admin
 + 
 +If installed locally you might find Python somewhere like: 
 + 
 +C:\Users\Giles\AppData\Local\Programs\Python\Python37-32
  
 Run Run
Line 52: Line 65:
 cmd cmd
  
-ctrl-shift Enter to run terminal as admin+ctrl-shift Enter if needing ​to run terminal as admin
  
-  ​"​C:​\Program Files (x86)\Python37-32\python.exe" ​-m pip install requests+  python -m pip install requests
  
 Re: PostgreSQL: use weak password for throw-away PG 11 installation on Win 10. Re: PostgreSQL: use weak password for throw-away PG 11 installation on Win 10.
  
 +==== Binary dependencies ====
 +
 +=== wkhtmltopdf (for HTML to PDF) ===
 +
 +wkhtmltopdf.exe - download installer from https://​wkhtmltopdf.org/​downloads.html then go to installed location e.g. C:\Program Files\wkhtmltopdf and put copy in D:​\sofa_dev_win\store and under D:​\sofa_dev_win\packaging\sofastats
 +
 +=== convert (for PDF to PNG) ===
 +
 +convert.exe - install the PORTABLE version of Imagemagick (ticking the legacy components part or else no convert.exe for you!) - e.g. ImageMagick-7.0.8-67-portable-Q16-x64.zip.
 +
 +  Versions with Q8 in the name are 8 bits-per-pixel component (e.g. 8-bit red, 8-bit green, etc.),
 +  whereas, Q16 in the filename are 16 bits-per-pixel component. A Q16 version permits you to read
 +  or write 16-bit images without losing precision but requires twice as much resources as the Q8
 +  version. Versions with dll in the filename include ImageMagick libraries as dynamic link libraries.
 +  Unless you have a Windows 32-bit OS, we recommend this version of ImageMagick for 64-bit Windows:
 +
 +from https://​imagemagick.org/​script/​download.php
 +
 +Also need delegates.xml
 +
 +=== ghostscript (what convert delegates specific PDF to PNG tasks to) ===
 +
 +gswin64c.exe and gsdll64.dll from https://​www.ghostscript.com/​download/​gsdnld.html
 ==== Get dev toolchain working e.g. eclipse, git ==== ==== Get dev toolchain working e.g. eclipse, git ====
  
-Install git and git bash etc+Install git and git bash etc - https://​gitforwindows.org 
 + 
 +Generate SSH key using Git Bash GUI
  
 Change remote as required so has ssh in it. Change remote as required so has ssh in it.
Line 78: Line 116:
 Click on it, update the password, and execute git pull/push command from your Git bash and it it won't throw any error message. Click on it, update the password, and execute git pull/push command from your Git bash and it it won't throw any error message.
  
-  cd C:​\sofa_dev_win+  cd D:​\sofa_dev_win
   git clone https://​git.launchpad.net/​sofastatistics   git clone https://​git.launchpad.net/​sofastatistics
  
 ==== Get SOFA working on Windows ==== ==== Get SOFA working on Windows ====
  
-  cd "C:​\sofa_dev_win\sofastatistics\sofastats\+  cd "D:​\sofa_dev_win\sofastatistics\sofastats"​ 
-  ​"​C:​\Program Files (x86)\Python37-32\python.exe" -m sofastats.start+  python ​start.py
  
 Iron out inevitable bugs. Iron out inevitable bugs.
  
 The pathlib library is a good start when working with Windows path names (a common source of problems). The pathlib library is a good start when working with Windows path names (a common source of problems).
- 
-Need to Reload() wx.html2 widget after SetPage when on Windows. 
  
 ==== Install pyinstaller ==== ==== Install pyinstaller ====
Line 98: Line 134:
 cmd cmd
  
-ctrl-shift Enter to run terminal as admin+ctrl-shift Enter if needing ​to run terminal as admin
  
-  ​"​C:​\Program Files (x86)\Python37-32\python.exe" ​-m pip install pyinstaller+  python -m pip install pyinstaller
  
 ==== Set launch.py dependency imports ==== ==== Set launch.py dependency imports ====
Line 107: Line 143:
  
   #import CUBRID-Python ## 2014 Python 2 only   #import CUBRID-Python ## 2014 Python 2 only
-  import PIL+  import PIL  ## actually pillow installed
   import PyPDF2   import PyPDF2
   import adodbapi   import adodbapi
Line 115: Line 151:
   #import pgdb  ## part of psycopg2 installation   #import pgdb  ## part of psycopg2 installation
   import psycopg2   import psycopg2
-  import pylab+  import pylab  ## part of matplotlib
   import pymysql   import pymysql
   import requests   import requests
-  import sqlite3 +  import sqlite3 ​ ## part of Python 
-  import win32api +  import win32api ​ ## part of pywin32 
-  import win32com +  import win32com ​ ## part of pywin32 
-  import win32con +  import win32con ​ ## part of pywin32 
-  import wx +  import wx  ## wxPython 
-  import wx.dataview +  import wx.dataview ​ ## part of wxPython 
-  import wx.grid +  import wx.grid ​ ## part of wxPython 
-  import wx.html2 +  import wx.html2 ​ ## part of wxPython 
-  import wx.lib +  import wx.lib ​ ## part of wxPython 
-  import wx.lib.agw +  import wx.lib.agw ​ ## part of wxPython 
-  import wx.lib.agw.hyperlink +  import wx.lib.agw.hyperlink ​ ## part of wxPython 
-  import wx.lib.agw.hypertreelist+  import wx.lib.agw.hypertreelist ​ ## part of wxPython
   ​   ​
   import import2run   import import2run
Line 172: Line 208:
 The actual command: The actual command:
  
-  cd C:​\sofa_dev_win\packaging\sofastats\+  cd D:​\sofa_dev_win\sofa4packaging\sofastats\
   pyinstaller --clean --exclude start --path C:​\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_10.0.17134.1_none_50c6cb8431e7428f launch.py   pyinstaller --clean --exclude start --path C:​\Windows\WinSxS\x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_10.0.17134.1_none_50c6cb8431e7428f launch.py
  
-The binary executable is C:​\sofa_dev_win\packaging\sofastats\dist\launch\launch.exe+The binary executable is D:​\sofa_dev_win\sofa4packaging\sofastats\dist\launch\launch.exe
  
-Shift all C:​\sofa_dev_win\packaging\sofastats\ in (except for __pycache__,​ build, or dist) and rename launch folder to sofastats so calls to sofastats package work.+Shift all D:​\sofa_dev_win\sofa4packaging\sofastats\ in (except for __pycache__,​ build, or dist) and rename launch folder to sofastats so calls to sofastats package work.
  
 ==== Rename, relocate, and edit spec file ==== ==== Rename, relocate, and edit spec file ====
Line 188: Line 224:
  
   binaries=[   binaries=[
-      ('C:/Program Files/​wkhtmltopdf/bin/​wkhtmltopdf.exe',​ '​.'​), ​ ## the docs for 3.4 show the structure as (binary, subfolder) where '​.'​ means the main folder +      ('D:/sofa_dev_win/dependencies/​wkhtmltopdf.exe',​ '​.'​), ​ ## the docs for 3.4 show the structure as (binary, subfolder) where '​.'​ means the main folder 
-      ('C:/​sofa_dev_win/​ImageMagick-7.0.8-44-portable-Q16-x64/​convert.exe',​ '​.'​), ​ ## need portable version +      ('D:/​sofa_dev_win/​dependencies/​convert.exe',​ '​.'​), ​ ## need portable version 
-      ('C:/Program Files (x86)/​gs/​gs9.27/bin/gswin32c.exe', '​.'​),​ +      ('D:/sofa_dev_win/dependencies/gswin64c.exe', '​.'​),​ 
-      ('C:/Program Files (x86)/​gs/​gs9.27/bin/gsdll32.dll', '​.'​),​+      ('D:/sofa_dev_win/dependencies/gsdll64.dll', '​.'​),​
   ],   ],
   datas=[   datas=[
-      ('C:/​sofa_dev_win/​ImageMagick-7.0.8-44-portable-Q16-x64/​delegates.xml',​ '​.'​), ​+      ('D:/​sofa_dev_win/​dependencies/​delegates.xml',​ '​.'​), ​
   ],   ],
  
-exe - icon='C:​\sofa_dev_win\sofa_32x32.ico'​+exe - icon='D:​\sofa_dev_win\packaging\sofa_32x32.ico'​
  
 exe - upx=False exe - upx=False
Line 221: Line 257:
 exe - debug=False exe - debug=False
  
-Put in C:​\sofa_dev_win\packaging\sofastats\ as sofastats.spec. Needs to be in same folder as scripts being packaged i.e. launch.py etc+Put in D:​\sofa_dev_win\sofa4packaging\sofastats\ as sofastats.spec. Needs to be in same folder as scripts being packaged i.e. launch.py etc
  
 ==== Run pyinstaller off spec file ==== ==== Run pyinstaller off spec file ====
  
-  cd C:​\sofa_dev_win\packaging\sofastats\+  cd D:​\sofa_dev_win\sofa4packaging\sofastats\
   pyinstaller sofastats.spec   pyinstaller sofastats.spec
  
-Shift all C:​\sofa_dev_win\packaging\sofastats\ in (except for __pycache__,​ build, or dist). Folder already named sofastats because of spec edits.+Shift all D:​\sofa_dev_win\sofa4packaging\sofastats\ in (except for __pycache__,​ build, or dist). Folder already named sofastats because of spec edits.
  
 ==== Test binary and SOFA code folders on clean machine ==== ==== Test binary and SOFA code folders on clean machine ====
proj/wininstallers.1562482970.txt.gz · Last modified: 2019/07/07 03:02 by admin