Pyinstaller
Pyinstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, Mac OS X, and Solaris and so on.
Download: The latest stable version is https://github.com/pyinstaller/pyinstaller/wiki and run script with
>> python setup.py install
We can install using pip command also:
>> pip pyinstaller install
More details about pyinstaller visit http://pythonhosted.org/PyInstaller/#installing-pyinstaller
Let the script is monitor.py
Desktop\SmartTimeMonitor\
monitor.py
monitor.config
Then,
>> pyinstaller monitor.py
Some folders dist and build will create in SmartTimeMonitor:

Here we will look monitor.exe in the dist\monitor folder. When we will go to create setup file using inno setup, then normal setup will create using exe by pyinstaller.
If we have to need some changes, like at the time of run setup, don’t want to show console window then need to use options with pyinstaller command:
>> pyinstaller monitor.py –w
Where w is used to create exe which will not show the pop up window but script will run in background.
...........................................................................................................................................
Inno Setup
Download: The stable version http://www.jrsoftware.org/isdl.php and install it.
Create new file in Inno setup compiler and use these statements.
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; then did a few changes to make maintenance, move to other folder easier
; define the path to your work folder C:\Users\anupk\Desktop\Monitor
#define BaseFolder "C:\Users\anupk\Desktop\Monitor\dist\monitor"
; get version information from the exe
#define ExeName BaseFolder+"\monitor.exe"
#define AppVersionNo GetFileVersion(ExeName)
#define AppMajorVersionIdx Pos(".", AppVersionNo)
#define AppMinorVersionTemp Copy(AppVersionNo, AppMajorVersionIdx +1)
#define AppMajorVersionNo Copy(AppVersionNo, 1, AppMajorVersionIdx -1)
#define AppMinorVersionNo Copy(AppMinorVersionTemp, 1, Pos(".", AppMinorVersionTemp)-1)
; define some more stuff, mainly to just keep it all at the beginning
#define MyAppName "SmartTime"
#define MyAppPublisher "Smartek Consultancy Services"
#define MyAppURL "http://www.smartek21.com/"
#define MyAppSupportURL "http://www.smartek21.com/support"
#define MyAppUpdatesURL "http://www.smartek21.com/downloads"
#define MyAppExeName "monitor.exe"
#define OutputFileName "MonitorSetup"
[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={{451B698D-E97F-444E-9FA9-B7180E450563}
AppName={#MyAppName}
AppVersion={#AppVersionNo}
AppVerName={#MyAppName} version {#AppMajorVersionNo}.{#AppMinorVersionNo}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppSupportURL}
AppUpdatesURL={#MyAppUpdatesURL}
; Following should probably be something like "{pf}\yourappname" for a real application
; set DefaultDirName to store files after setup done
DefaultDirName=C:\Program Files\MonitorTime
DefaultGroupName=Smart Time
AllowNoIcons=yes
PrivilegesRequired=admin
DisableStartupPrompt=yes
DisableWelcomePage=yes
; AlwaysRestart=yes
OutputBaseFilename={#OutputFileName}_{#AppVersionNo}
; bzip/9 is better by about 400KB over zip/9 and lzma is even better
Compression=lzma/ultra
; Following would reduce size a bit more
; SolidCompression=yes
[Languages]
Name: english; MessagesFile: compiler:Default.isl
[Tasks]
; To create Desktop Icon
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
; To create Quicklaunchicon
Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
[Files]
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\monitor.exe; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\include\*; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\monitor.config; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\base_library.zip; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\_bz2.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\_ctypes.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\_hashlib.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\_lzma.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\_socket.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\_ssl.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\_win32sysloader.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\mfc100u.dll; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\MSVCR100.dll; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\pyexpat.pyd; DestDir: {app}; Flags: ignoreversion
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\MSVCR100.dll; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\python34.dll; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\pythoncom34.dll; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\pywintypes34.dll; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\select.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\unicodedata.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\win32api.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\win32gui.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\win32process.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\win32service.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\win32trace.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\win32ui.pyd; DestDir: {app};
Source: C:\Users\anupk\Desktop\Monitor\dist\monitor\win32wnet.pyd; DestDir: {app};
; Source: C:\Users\anupk\Desktop\Py_script\dist\monitor\pythoncom34.dll; DestDir: {app}; Flags: ignoreversion
; Source: C:\Users\anupk\Desktop\Py_script\dist\monitor\pywintypes34.dll; DestDir: {app}; Flags: ignoreversion
; Source: ..\dist\w9xpopen.exe; DestDir: {app}; Flags: ignoreversion
; Source: C:\Users\anupk\Desktop\Py_script\dist\monitor\base_library\*; DestDir: {app}\lib; Flags: ignoreversion recursesubdirs createallsubdirs
; Source: C:\Users\anupk\Desktop\Py_script\dist\monitor\include\*; DestDir: {app}\include; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}
Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon;
;create uninstall shortcut in start menu
;Name: {group} \ {cm: UninstallProgram, {#MyAppName}}; Filename: {uninstallexe}
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: quicklaunchicon
Name: {commonstartup}\{#MyAppName}; Filename: {app}\{#MyAppExeName};
;[Registry]
;Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: {#MyAppName}; ValueData: {app}\{#MyAppExeName}; Flags: uninsdeletevalue
;Root: HKLM; Subkey: "Software\My Company\My Program"; Flags: uninsdeletekey
[Run]
; Here runhidden flag is used to hide pop up window after setup done
Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#MyAppName}}; Flags: nowait postinstall skipifsilent runhidden
Filename: {sys}\net.exe; Parameters: start {#MyAppName}; Flags: runhidden;
For more details about inno setup visit http://www.jrsoftware.org/ishelp/index.php?topic=wizardpages
Setup file will store in desktop: output/MonitorSetup
And installed file: C:\Program Files\MonitorTime\
Thanks :)

Great tutorial
ReplyDeleteCurrently using py2exe what are the main differences between the two?
ReplyDeleteThere are few differences: http://stackoverflow.com/questions/6235123/python-executables-py2exe-or-pyinstaller
Delete