Development

The application is written in python. The following dependencies are required:

Dependencies

The source codes are on github: https://github.com/spilkjir/CTGViewer

Feature requests and bugs:

We appreciate any help regarding the developing and testing the CTGViewer.

Please use github: https://github.com/spilkjir/CTGViewer

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 CTGViewer installer is based on cx_Freeze plus Inno setup.

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 CTGViewer_v*.exe placed in the directory build.

Files

All required files are available on github: https://github.com/spilkjir/CTGViewer

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 CTGViewer.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 CTGViewer
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
# include exe file of vcredist_x86.exe
# include _ufuncs, libifcoremd, libmmd otherwise unable to start
# info: http://stackoverflow.com/questions/19633757/using-cx-freeze-with-scipy-scipy-special-ufuncs-py
includefiles = [os.path.join(BASE_DIR, '..\\win32\\vcredist_x86.exe'),
                ('c:\\Python27\\Lib\\site-packages\\scipy\\special\\_ufuncs.pyd', '_ufuncs.pyd'),
                ('c:\\Python27\\Lib\\site-packages\\numpy\\core\\libifcoremd.dll', 'libifcoremd.dll'),
                ('c:\\Python27\\Lib\\site-packages\\numpy\\core\\libmmd.dll', 'libmmd.dll')]
includes = ["scipy.io.matlab.streams", "numpy.core.multiarray"]
excludes = ['tcl', 'Tkinter']
packages = ["reportlab", "scipy"]
path = []

exeTarget = Executable(
    script=os.path.join("CTGViewer.py"),
    base="Win32GUI",
    compress=True,
    copyDependentFiles=True,
    )

setup(
    name="CTGViewer",
    version="0.3.30",
    description="CTGViewer 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 "CTGViewer"
#define AppVersion "0.3.30"

[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}\CTGViewer
DefaultGroupName=CTGViewer
AllowNoIcons=yes
LicenseFile=e:\github\CTGViewer\LICENSE
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:\github\CTGViewer\src\build\exe.win32-2.7\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "E:\github\CTGViewer\icons\favicon16.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\github\CTGViewer\icons\favicon32.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\github\CTGViewer\icons\uninstall.ico"; DestDir: "{app}"; Flags: ignoreversion

; NOTE: Do not use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\CTGViewer"; Filename: "{app}\CTGViewer.exe"; IconFilename: "{app}\favicon16.ico"
Name: "{group}\{cm:UninstallProgram,CTGViewer}"; Filename: "{uninstallexe}"; IconFilename: "{app}\uninstall.ico"
Name: "{commondesktop}\CTGViewer"; Filename: "{app}\CTGViewer.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}\CTGViewer.exe"; Description: "{cm:LaunchProgram,CTGViewer}"; Flags: nowait postinstall skipifsilent