# A NSIS Installer for Python Applications

Leo
Examples
Tutorial
Using Leo to create a NSIS installer for a python application
python nsis installer how-to
8/12/2002
draft
C:\testtt\Leo\Examples\Tutorials\D2 A NSIS Installer for Python Applications\
<p>Nullsoft, the makers of the <a href="http://www.winamp.com">Winamp</a>&#160;MP3 software, have released a powerful free installer called NSIS, available <a href="http://www.nullsoft.com/free/nsis/">here</a>. This application allows you to make installation packages for Windows applications.</p><p>You create NSIS packages by writing a NSIS script and then compiling it. Depending on the application, NSIS can often be a better choice than more expensive installation generators, since NSIS installations are easy to create, are small and fast, and yet&#160;can be configured with many&#160;features.</p>

[Empty]

# NSIS

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>When you install Leo, you'll find that it comes with a script for generating an installer for Leo. This script is called <strong>leo.nsi</strong>, and is distributed in the Leo file <strong>nsis.leo</strong> .</p><p>If you have NSIS installed, right-clicking on a <strong>.nsi</strong> file will give you the option of compiling the script to create a package.</p>

pic02.png

# The NSIS script for Leo

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>Since the NSIS script for the Leo installation is included in the Leo distribution in the <strong>nsis.leo</strong> file, it is easy to understand the how the script works. This <strong>.nsi</strong> file creates an installer that packages all of the Leo program files, and creates a desktop shortcut, a Program Menu item, and the file association for <strong>.leo</strong> files.</p>

pic03.png

# The NSIS script is in nsis.leo

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>In this screenshot we're looking at the code that checks to see whether Python has been installed.</p><p>Since Leo is a Python application, modifying this installation&#160;script to create a&#160;script to build a Windows installer for your own Python application is relatively simple. You would leave this section alone, and check other sections for the program name "Leo", and change these to your program name. </p>

pic04.png

# The code that checks for Python installation

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>For example, here is the section that creates a registry entry&#160;for associating the <strong>.leo</strong> extension with Leo. You would change the name "Leo" to the name of your application.</p><p>If you are going to use NSIS to create an installer for something other than a Python application, this .leo file still contains examples of several useful NSIS techniques, which can be easily referred to, since the script is documented in outline form in a Leo file.</p>

pic05.png

# Modifying the script

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com