Development¶
The application is written in python. The following dependencies are required:
Dependencies¶
- python 2.6 or higher - http://www/python.org:
- PyQt4 - bindings to QT - http://www.riverbankcomputing.co.uk/software/pyqt/
- pyqwt5 - graphical plotting - http://pyqwt.sourceforge.net/
- numpy - numerical python - http://www.numpy.org/
- Scipy - scientific computing
- Argparse - arguments parsing
- Reportlab - export to PDF files
In the case of interest in development do not hesitate to contact us.
Feature request¶
We appreciate any help regarding the developing and testing the CTGViewerLite. The following things are planned to be implemented (when time allows):
- view clinical information in one table
- improve documentation
- test under Mac OS
- show progress bar when converting files
Reported bugs¶
- none reported
Building Windows executables¶
Introduction¶
There are several ways to build windows executables from python scripts the most known are:
It is difficult to choose between them since there is no clear sure fire method. For the current project I have found the py2exe unsuitable since it is not multi-platform and might have problems with numpy package (see py2exe/WorkingWithVariousPackagesAndModules). I don’t remember the reason why I’ve preferred cx_Freeze over pyinstaller. I guess I’ve found cx_Freeze more easy to get started with.
When having the windows executables it is convinient to make a single installer file that unpack the executables to desired location and handles the possible dependent files. For this purpose I have found Inno setup simple and easy to use.
In summary the CTGViewerLite installer is based on cx_Freeze plus Inno setup.
Useful links¶
There are plenty of manuals and tutorials on cx_Freeze and Inno Setup. My intention here is to offer the final solution since the step by step explanation could be found elsewhere. This manual is based on several resources. I do not list all of them here, just a selection of the best:
- http://cx-freeze.readthedocs.org/en/latest/index.html - documentation for cx_Freeze
- http://www.jrsoftware.org/ishelp/ - documentation for Inno setup
- http://unpythonic.blogspot.cz/2007/07/pygtk-py2exe-and-inno-setup-for-single.html - very nice tutorial. Although it is for py2exe with Inno Setup, it is nice and detailed description.
- http://www.aronhelser.com/2010/09/inno-setup-msvc-vcredist-without.html - Inno Setup MSVC vcredist without bothering users
Manual¶
1. Run file set_version_number.py
This file automatically sets a new software version number in several files (setup.py, AboutUI.ui, setup_inno.iss, conf.py, AboutUI.ui). For the AboutUI.ui it also executes pyuic4 file to make AboutUI.py.
2. Run python setup.py install
In the command prompt run:
python setup.py install
This file executes multiple tasks:
- It first creates the windows executables using the cx_Freeze and place them into a build directory: build/exe.win32-2.6
- It runs the Inno Setup (using the setup_inno.iss) and creates windows installer and places it into a build directory: build
The results is an executables installer file CTGViewerLite_v*.exe placed in the directory build.
Files¶
All required files are available in the CTGViewerLite.zip file (see Downloads).
An example of setup.py file:
# -*- coding: utf-8 -*-
#
# Created on Oct 15, 2013
# @authors: Jiri Spilka
# http://people.ciirc.cvut.cz/~spilkjir
# @2015, CIIRC, Czech Technical University in Prague
#
# Licensed under the terms of the GNU GENERAL PUBLIC LICENSE
# (see CTGViewerLite.py for details)
from cx_Freeze import setup, Executable
import os
import shutil
# general settings
BASE_DIR = os.path.dirname(__file__)
OUT_DIR = os.path.join(BASE_DIR, 'build')
INNO_SCRIPT = 'setup_inno.iss' # the script with Inno setup commands for the CTGViewerLite
INNO_EXECUTABLE = '"c:\\Program Files\\Inno Setup 5\\ISCC.exe"' # path to the installed Inno Setup
# delete output dir
if os.path.exists(OUT_DIR):
shutil.rmtree(OUT_DIR)
# Process the includes, excludes and packages first
includefiles = [os.path.join(BASE_DIR,'win32/vcredist_x86.exe')] # include exe file of vcredist_x86.exe
includes = ["scipy.io.matlab.streams", "numpy.core.multiarray"]
excludes = ['tcl', 'Tkinter']
packages = ["reportlab", "scipy"]
path = []
exeTarget = Executable(
script=os.path.join(BASE_DIR, "CTGViewerLite.py"),
base="Win32GUI",
compress=True,
copyDependentFiles=True,
)
setup(
name="CTGViewerLite",
version="0.3.00",
description="CTGViewerLite application",
author="Jiri Spilka",
author_email='jiri.spilka@ciirc.cvut.cz',
url='http://people.ciirc.cvut.cz/~spilkjir',
options={"build_exe": {"includes": includes,
"include_files": includefiles,
"excludes": excludes,
"packages": packages,
"path": path
}
},
executables=[exeTarget]
)
os.system(INNO_EXECUTABLE + " " + INNO_SCRIPT) # run the Inno Setup
print('Build complete')
An example of setup_inno.iss file:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[ISPP]
#define AppName "CTGViewerLite"
#define AppVersion "0.3.00"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{C6E23BFC-B9C5-4FBE-9413-C95447A3E1AE}}
AppName={#AppName}
AppVersion={#AppVersion}
AppPublisher=Jiri Spilka, Czech Technical University in Prague
AppPublisherURL=http://people.ciirc.cvut.cz/~spilkjir
AppSupportURL=http://people.ciirc.cvut.cz/~spilkjir
AppUpdatesURL=http://people.ciirc.cvut.cz/~spilkjir
DefaultDirName={pf}\CTGViewerLite
DefaultGroupName=CTGViewerLite
AllowNoIcons=yes
LicenseFile=e:\svn_working_copy\iga_brno\python\ctgViewerLite\src\gpl.txt
OutputBaseFilename={#AppName}_v{#AppVersion}_setup
Compression=lzma
; Compression=none
SolidCompression=yes
OutputDir=build
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
; Files to include into installer
[Files]
Source: "E:\svn_working_copy\iga_brno\python\ctgViewerLite\src\build\exe.win32-2.7\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "E:\svn_working_copy\iga_brno\python\ctgViewerLite\src\icons\favicon16.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\svn_working_copy\iga_brno\python\ctgViewerLite\src\icons\favicon32.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\svn_working_copy\iga_brno\python\ctgViewerLite\src\icons\uninstall.ico"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Do not use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\CTGViewerLite"; Filename: "{app}\CTGViewerLite.exe"; IconFilename: "{app}\favicon16.ico"
Name: "{group}\{cm:UninstallProgram,CTGViewerLite}"; Filename: "{uninstallexe}"; IconFilename: "{app}\uninstall.ico"
Name: "{commondesktop}\CTGViewerLite"; Filename: "{app}\CTGViewerLite.exe"; Tasks: desktopicon; IconFilename: "{app}\favicon32.ico"
; The installation of vcredist_x86 should be silent and only if it is not already installed.
[Run]
; Filename: "{app}\win32\vcredist_x86.exe"; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}\win32; StatusMsg: Installing CRT...
Filename: "{app}\vcredist_x86.exe"; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; WorkingDir: {app}; StatusMsg: Installing CRT...
Filename: "{app}\CTGViewerLite.exe"; Description: "{cm:LaunchProgram,CTGViewerLite}"; Flags: nowait postinstall skipifsilent