sandbox/morph / Doc / library / msilib.rst

:mod:`msilib` --- Read and write Microsoft Installer files

The :mod:`msilib` supports the creation of Microsoft Installer (.msi) files. Because these files often contain an embedded "cabinet" file (.cab), it also exposes an API to create CAB files. Support for reading .cab files is currently not implemented; read support for the .msi database is possible.

This package aims to provide complete access to all tables in an .msi file, therefore, it is a fairly low-level API. Two primary applications of this package are the :mod:`distutils` command bdist_msi, and the creation of Python installer package itself (although that currently uses a different version of msilib).

The package contents can be roughly split into four parts: low-level CAB routines, low-level MSI routines, higher-level MSI routines, and standard table structures.

Represents entries in the Binary table; inserting such an object using :func:`add_data` reads the file named filename into the table.

Database Objects

View Objects

Summary Information Objects

Record Objects


All wrappers around MSI functions raise :exc:`MsiError`; the string inside the exception will contain more detail.

CAB Objects

The class :class:`CAB` represents a CAB file. During MSI construction, files will be added simultaneously to the Files table, and to a CAB file. Then, when all files have been added, the CAB file can be written, then added to the MSI file.

name is the name of the CAB file in the MSI file.

Directory Objects

Create a new directory in the Directory table. There is a current component at each point in time for the directory, which is either explicitly created through :meth:`start_component`, or implicitly when files are added for the first time. Files are added into the current component, and into the cab file. To create a directory, a base directory object needs to be specified (can be None), the path to the physical directory, and a logical directory name. default specifies the DefaultDir slot in the directory table. componentflags specifies the default flags that new components get.


Add a new record to the Feature table, using the values id,, title, desc, display, level, directory, and attributes. The resulting feature object can be passed to the :meth:`start_component` method of :class:`Directory`.

GUI classes

:mod:`msilib` provides several classes that wrap the GUI tables in an MSI database. However, no standard user interface is provided; use :mod:`bdist_msi` to create MSI files with a user-interface for installing Python packages.

Base class of the dialog controls. dlg is the dialog object the control belongs to, and name is the control's name.

Create a radio button control named name. property is the installer property that gets set when a radio button is selected.

Return a new :class:`Dialog` object. An entry in the Dialog table is made, with the specified coordinates, dialog attributes, title, name of the first, default, and cancel controls.

Precomputed tables

:mod:`msilib` provides a few subpackages that contain only schema and table definitions. Currently, these definitions are based on MSI version 2.0.