Building installers

class nsist.InstallerBuilder(appname, version, shortcuts, *, publisher=None, icon='/home/docs/checkouts/readthedocs.org/user_builds/pynsist/checkouts/latest/nsist/glossyorb.ico', packages=None, extra_files=None, py_version='3.6.3', py_bitness=32, py_format='bundled', inc_msvcrt=True, build_dir='build/nsis', installer_name=None, nsi_template=None, exclude=None, pypi_wheel_reqs=None, extra_wheel_sources=None, local_wheels=None, commands=None, license_file=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_wheel_sources (list of Path objects) – Directory paths to find wheels in.

  • local_wheels (list of str) – Glob paths matching wheel files to include

  • 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) – (deprecated) ‘bundled’. Use Pynsist 1.x for ‘installer’ option.

  • inc_msvcrt (bool) – True to include the Microsoft C runtime with ‘bundled’ Python.

  • 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_embeddable()[source]

Fetch the embeddable Windows build for the specified Python version

It will be unpacked into the build directory.

In addition, any *._pth files found therein will have the pkgs path appended to them.

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.