Building installers

class nsist.InstallerBuilder(appname, version, shortcuts, publisher=None, icon='/home/docs/checkouts/readthedocs.org/user_builds/pynsist/checkouts/1.12/nsist/glossyorb.ico', packages=None, extra_files=None, py_version='3.6.1', py_bitness=32, py_format=None, inc_msvcrt=True, build_dir='build/nsis', installer_name=None, nsi_template=None, exclude=None, pypi_wheel_reqs=None, commands=None)[source]

Controls building an installer. This includes three main steps:

  1. Arranging the necessary files in the build directory.
  2. Filling out the template NSI file to control NSIS.
  3. Running makensis to build the installer.
Parameters:
  • appname (str) – Application name
  • version (str) – Application version
  • shortcuts (dict) – Dictionary keyed by shortcut name, containing dictionaries whose keys match the fields of Shortcut sections in the config file
  • publisher (str) – Publisher name
  • icon (str) – Path to an icon for the application
  • packages (list) – List of strings for importable packages to include
  • commands (dict) – Dictionary keyed by command name, containing dicts defining the commands, as in the config file.
  • pypi_wheel_reqs (list) – Package specifications to fetch from PyPI as wheels
  • extra_files (list) – List of 2-tuples (file, destination) of files to include
  • exclude (list) – Paths of files to exclude that would otherwise be included
  • py_version (str) – Full version of Python to bundle
  • py_bitness (int) – Bitness of bundled Python (32 or 64)
  • py_format (str) – ‘installer’ or ‘bundled’. Default ‘bundled’ for Python >= 3.6, ‘installer’ for older versions.
  • inc_msvcrt (bool) – True to include the Microsoft C runtime with ‘bundled’ Python. Ignored when py_format=’installer’.
  • build_dir (str) – Directory to run the build in
  • installer_name (str) – Filename of the installer to produce
  • nsi_template (str) – Path to a template NSI file to use
run(makensis=True)[source]

Run all the steps to build an installer.

fetch_python()[source]

Fetch the MSI for the specified version of Python.

It will be placed in the build directory.

fetch_pylauncher()[source]

Fetch the MSI for PyLauncher (required for Python2.x).

It will be placed in the build directory.

write_script(entrypt, target, extra_preamble='')[source]

Write a launcher script from a ‘module:function’ entry point

py_version and py_bitness are used to write an appropriate shebang line for the PEP 397 Windows launcher.

prepare_shortcuts()[source]

Prepare shortcut files in the build directory.

If entry_point is specified, write the script. If script is specified, copy to the build directory. Prepare target and parameters for these shortcuts.

Also copies shortcut icons

prepare_packages()[source]

Move requested packages into the build directory.

If a pynsist_pkgs directory exists, it is copied into the build directory as pkgs/ . Any packages not already there are found on sys.path and copied in.

copy_extra_files()[source]

Copy a list of files into the build directory, and add them to install_files or install_dirs as appropriate.

write_nsi()[source]

Write the NSI file to define the NSIS installer.

Most of the details of this are in the template and the nsist.nsiswriter.NSISFileWriter class.

run_nsis()[source]

Runs makensis using the specified .nsi file

Returns the exit code.