Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | :mod:`msilib` --- Read and write Microsoft Installer files |
| 2 | ========================================================== |
| 3 | |
| 4 | .. module:: msilib |
| 5 | :platform: Windows |
| 6 | :synopsis: Creation of Microsoft Installer files, and CAB files. |
| 7 | .. moduleauthor:: Martin v. Löwis <martin@v.loewis.de> |
| 8 | .. sectionauthor:: Martin v. Löwis <martin@v.loewis.de> |
| 9 | |
| 10 | |
| 11 | .. index:: single: msi |
| 12 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 13 | The :mod:`msilib` supports the creation of Microsoft Installer (``.msi``) files. |
| 14 | Because these files often contain an embedded "cabinet" file (``.cab``), it also |
| 15 | exposes an API to create CAB files. Support for reading ``.cab`` files is |
| 16 | currently not implemented; read support for the ``.msi`` database is possible. |
| 17 | |
| 18 | This package aims to provide complete access to all tables in an ``.msi`` file, |
| 19 | therefore, it is a fairly low-level API. Two primary applications of this |
| 20 | package are the :mod:`distutils` command ``bdist_msi``, and the creation of |
| 21 | Python installer package itself (although that currently uses a different |
| 22 | version of ``msilib``). |
| 23 | |
| 24 | The package contents can be roughly split into four parts: low-level CAB |
| 25 | routines, low-level MSI routines, higher-level MSI routines, and standard table |
| 26 | structures. |
| 27 | |
| 28 | |
| 29 | .. function:: FCICreate(cabname, files) |
| 30 | |
| 31 | Create a new CAB file named *cabname*. *files* must be a list of tuples, each |
| 32 | containing the name of the file on disk, and the name of the file inside the CAB |
| 33 | file. |
| 34 | |
| 35 | The files are added to the CAB file in the order they appear in the list. All |
| 36 | files are added into a single CAB file, using the MSZIP compression algorithm. |
| 37 | |
| 38 | Callbacks to Python for the various steps of MSI creation are currently not |
| 39 | exposed. |
| 40 | |
| 41 | |
Christian Heimes | faf2f63 | 2008-01-06 16:59:19 +0000 | [diff] [blame] | 42 | .. function:: UuidCreate() |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 43 | |
| 44 | Return the string representation of a new unique identifier. This wraps the |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 45 | Windows API functions :c:func:`UuidCreate` and :c:func:`UuidToString`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 46 | |
| 47 | |
| 48 | .. function:: OpenDatabase(path, persist) |
| 49 | |
| 50 | Return a new database object by calling MsiOpenDatabase. *path* is the file |
| 51 | name of the MSI file; *persist* can be one of the constants |
| 52 | ``MSIDBOPEN_CREATEDIRECT``, ``MSIDBOPEN_CREATE``, ``MSIDBOPEN_DIRECT``, |
| 53 | ``MSIDBOPEN_READONLY``, or ``MSIDBOPEN_TRANSACT``, and may include the flag |
| 54 | ``MSIDBOPEN_PATCHFILE``. See the Microsoft documentation for the meaning of |
| 55 | these flags; depending on the flags, an existing database is opened, or a new |
| 56 | one created. |
| 57 | |
| 58 | |
| 59 | .. function:: CreateRecord(count) |
| 60 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 61 | Return a new record object by calling :c:func:`MSICreateRecord`. *count* is the |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 62 | number of fields of the record. |
| 63 | |
| 64 | |
| 65 | .. function:: init_database(name, schema, ProductName, ProductCode, ProductVersion, Manufacturer) |
| 66 | |
Christian Heimes | d3eb5a15 | 2008-02-24 00:38:49 +0000 | [diff] [blame] | 67 | Create and return a new database *name*, initialize it with *schema*, and set |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 68 | the properties *ProductName*, *ProductCode*, *ProductVersion*, and |
| 69 | *Manufacturer*. |
| 70 | |
| 71 | *schema* must be a module object containing ``tables`` and |
| 72 | ``_Validation_records`` attributes; typically, :mod:`msilib.schema` should be |
| 73 | used. |
| 74 | |
| 75 | The database will contain just the schema and the validation records when this |
| 76 | function returns. |
| 77 | |
| 78 | |
Christian Heimes | d3eb5a15 | 2008-02-24 00:38:49 +0000 | [diff] [blame] | 79 | .. function:: add_data(database, table, records) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 80 | |
Christian Heimes | d3eb5a15 | 2008-02-24 00:38:49 +0000 | [diff] [blame] | 81 | Add all *records* to the table named *table* in *database*. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 82 | |
Christian Heimes | d3eb5a15 | 2008-02-24 00:38:49 +0000 | [diff] [blame] | 83 | The *table* argument must be one of the predefined tables in the MSI schema, |
| 84 | e.g. ``'Feature'``, ``'File'``, ``'Component'``, ``'Dialog'``, ``'Control'``, |
| 85 | etc. |
| 86 | |
| 87 | *records* should be a list of tuples, each one containing all fields of a |
| 88 | record according to the schema of the table. For optional fields, |
| 89 | ``None`` can be passed. |
| 90 | |
Serhiy Storchaka | 9594942 | 2013-08-27 19:40:23 +0300 | [diff] [blame] | 91 | Field values can be ints, strings, or instances of the Binary class. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 92 | |
| 93 | |
| 94 | .. class:: Binary(filename) |
| 95 | |
| 96 | Represents entries in the Binary table; inserting such an object using |
| 97 | :func:`add_data` reads the file named *filename* into the table. |
| 98 | |
| 99 | |
| 100 | .. function:: add_tables(database, module) |
| 101 | |
| 102 | Add all table content from *module* to *database*. *module* must contain an |
| 103 | attribute *tables* listing all tables for which content should be added, and one |
| 104 | attribute per table that has the actual content. |
| 105 | |
| 106 | This is typically used to install the sequence tables. |
| 107 | |
| 108 | |
| 109 | .. function:: add_stream(database, name, path) |
| 110 | |
| 111 | Add the file *path* into the ``_Stream`` table of *database*, with the stream |
| 112 | name *name*. |
| 113 | |
| 114 | |
| 115 | .. function:: gen_uuid() |
| 116 | |
| 117 | Return a new UUID, in the format that MSI typically requires (i.e. in curly |
| 118 | braces, and with all hexdigits in upper-case). |
| 119 | |
| 120 | |
| 121 | .. seealso:: |
| 122 | |
| 123 | `FCICreateFile <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devnotes/winprog/fcicreate.asp>`_ |
| 124 | `UuidCreate <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/uuidcreate.asp>`_ |
| 125 | `UuidToString <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/uuidtostring.asp>`_ |
| 126 | |
| 127 | .. _database-objects: |
| 128 | |
| 129 | Database Objects |
| 130 | ---------------- |
| 131 | |
| 132 | |
| 133 | .. method:: Database.OpenView(sql) |
| 134 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 135 | Return a view object, by calling :c:func:`MSIDatabaseOpenView`. *sql* is the SQL |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 136 | statement to execute. |
| 137 | |
| 138 | |
| 139 | .. method:: Database.Commit() |
| 140 | |
| 141 | Commit the changes pending in the current transaction, by calling |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 142 | :c:func:`MSIDatabaseCommit`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 143 | |
| 144 | |
| 145 | .. method:: Database.GetSummaryInformation(count) |
| 146 | |
| 147 | Return a new summary information object, by calling |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 148 | :c:func:`MsiGetSummaryInformation`. *count* is the maximum number of updated |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 149 | values. |
| 150 | |
| 151 | |
| 152 | .. seealso:: |
| 153 | |
Christian Heimes | 679db4a | 2008-01-18 09:56:22 +0000 | [diff] [blame] | 154 | `MSIDatabaseOpenView <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msidatabaseopenview.asp>`_ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 155 | `MSIDatabaseCommit <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msidatabasecommit.asp>`_ |
| 156 | `MSIGetSummaryInformation <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msigetsummaryinformation.asp>`_ |
| 157 | |
| 158 | .. _view-objects: |
| 159 | |
| 160 | View Objects |
| 161 | ------------ |
| 162 | |
| 163 | |
Benjamin Peterson | 4118174 | 2008-07-02 20:22:54 +0000 | [diff] [blame] | 164 | .. method:: View.Execute(params) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 165 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 166 | Execute the SQL query of the view, through :c:func:`MSIViewExecute`. If |
Benjamin Peterson | 4118174 | 2008-07-02 20:22:54 +0000 | [diff] [blame] | 167 | *params* is not ``None``, it is a record describing actual values of the |
| 168 | parameter tokens in the query. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 169 | |
| 170 | |
| 171 | .. method:: View.GetColumnInfo(kind) |
| 172 | |
| 173 | Return a record describing the columns of the view, through calling |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 174 | :c:func:`MsiViewGetColumnInfo`. *kind* can be either ``MSICOLINFO_NAMES`` or |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 175 | ``MSICOLINFO_TYPES``. |
| 176 | |
| 177 | |
| 178 | .. method:: View.Fetch() |
| 179 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 180 | Return a result record of the query, through calling :c:func:`MsiViewFetch`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 181 | |
| 182 | |
| 183 | .. method:: View.Modify(kind, data) |
| 184 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 185 | Modify the view, by calling :c:func:`MsiViewModify`. *kind* can be one of |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 186 | ``MSIMODIFY_SEEK``, ``MSIMODIFY_REFRESH``, ``MSIMODIFY_INSERT``, |
| 187 | ``MSIMODIFY_UPDATE``, ``MSIMODIFY_ASSIGN``, ``MSIMODIFY_REPLACE``, |
| 188 | ``MSIMODIFY_MERGE``, ``MSIMODIFY_DELETE``, ``MSIMODIFY_INSERT_TEMPORARY``, |
| 189 | ``MSIMODIFY_VALIDATE``, ``MSIMODIFY_VALIDATE_NEW``, |
| 190 | ``MSIMODIFY_VALIDATE_FIELD``, or ``MSIMODIFY_VALIDATE_DELETE``. |
| 191 | |
| 192 | *data* must be a record describing the new data. |
| 193 | |
| 194 | |
| 195 | .. method:: View.Close() |
| 196 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 197 | Close the view, through :c:func:`MsiViewClose`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 198 | |
| 199 | |
| 200 | .. seealso:: |
| 201 | |
| 202 | `MsiViewExecute <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewexecute.asp>`_ |
| 203 | `MSIViewGetColumnInfo <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewgetcolumninfo.asp>`_ |
| 204 | `MsiViewFetch <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewfetch.asp>`_ |
| 205 | `MsiViewModify <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewmodify.asp>`_ |
| 206 | `MsiViewClose <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiviewclose.asp>`_ |
| 207 | |
| 208 | .. _summary-objects: |
| 209 | |
| 210 | Summary Information Objects |
| 211 | --------------------------- |
| 212 | |
| 213 | |
| 214 | .. method:: SummaryInformation.GetProperty(field) |
| 215 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 216 | Return a property of the summary, through :c:func:`MsiSummaryInfoGetProperty`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 217 | *field* is the name of the property, and can be one of the constants |
| 218 | ``PID_CODEPAGE``, ``PID_TITLE``, ``PID_SUBJECT``, ``PID_AUTHOR``, |
| 219 | ``PID_KEYWORDS``, ``PID_COMMENTS``, ``PID_TEMPLATE``, ``PID_LASTAUTHOR``, |
| 220 | ``PID_REVNUMBER``, ``PID_LASTPRINTED``, ``PID_CREATE_DTM``, |
| 221 | ``PID_LASTSAVE_DTM``, ``PID_PAGECOUNT``, ``PID_WORDCOUNT``, ``PID_CHARCOUNT``, |
| 222 | ``PID_APPNAME``, or ``PID_SECURITY``. |
| 223 | |
| 224 | |
| 225 | .. method:: SummaryInformation.GetPropertyCount() |
| 226 | |
| 227 | Return the number of summary properties, through |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 228 | :c:func:`MsiSummaryInfoGetPropertyCount`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 229 | |
| 230 | |
| 231 | .. method:: SummaryInformation.SetProperty(field, value) |
| 232 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 233 | Set a property through :c:func:`MsiSummaryInfoSetProperty`. *field* can have the |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 234 | same values as in :meth:`GetProperty`, *value* is the new value of the property. |
| 235 | Possible value types are integer and string. |
| 236 | |
| 237 | |
| 238 | .. method:: SummaryInformation.Persist() |
| 239 | |
| 240 | Write the modified properties to the summary information stream, using |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 241 | :c:func:`MsiSummaryInfoPersist`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 242 | |
| 243 | |
| 244 | .. seealso:: |
| 245 | |
| 246 | `MsiSummaryInfoGetProperty <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfogetproperty.asp>`_ |
| 247 | `MsiSummaryInfoGetPropertyCount <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfogetpropertycount.asp>`_ |
| 248 | `MsiSummaryInfoSetProperty <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfosetproperty.asp>`_ |
| 249 | `MsiSummaryInfoPersist <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msisummaryinfopersist.asp>`_ |
| 250 | |
| 251 | .. _record-objects: |
| 252 | |
| 253 | Record Objects |
| 254 | -------------- |
| 255 | |
| 256 | |
| 257 | .. method:: Record.GetFieldCount() |
| 258 | |
| 259 | Return the number of fields of the record, through |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 260 | :c:func:`MsiRecordGetFieldCount`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 261 | |
| 262 | |
Martin v. Löwis | e95593e | 2008-06-02 10:08:54 +0000 | [diff] [blame] | 263 | .. method:: Record.GetInteger(field) |
| 264 | |
| 265 | Return the value of *field* as an integer where possible. *field* must |
| 266 | be an integer. |
| 267 | |
| 268 | |
| 269 | .. method:: Record.GetString(field) |
| 270 | |
| 271 | Return the value of *field* as a string where possible. *field* must |
| 272 | be an integer. |
| 273 | |
| 274 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 275 | .. method:: Record.SetString(field, value) |
| 276 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 277 | Set *field* to *value* through :c:func:`MsiRecordSetString`. *field* must be an |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 278 | integer; *value* a string. |
| 279 | |
| 280 | |
| 281 | .. method:: Record.SetStream(field, value) |
| 282 | |
| 283 | Set *field* to the contents of the file named *value*, through |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 284 | :c:func:`MsiRecordSetStream`. *field* must be an integer; *value* a string. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 285 | |
| 286 | |
| 287 | .. method:: Record.SetInteger(field, value) |
| 288 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 289 | Set *field* to *value* through :c:func:`MsiRecordSetInteger`. Both *field* and |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 290 | *value* must be an integer. |
| 291 | |
| 292 | |
| 293 | .. method:: Record.ClearData() |
| 294 | |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 295 | Set all fields of the record to 0, through :c:func:`MsiRecordClearData`. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 296 | |
| 297 | |
| 298 | .. seealso:: |
| 299 | |
| 300 | `MsiRecordGetFieldCount <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordgetfieldcount.asp>`_ |
| 301 | `MsiRecordSetString <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordsetstring.asp>`_ |
| 302 | `MsiRecordSetStream <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordsetstream.asp>`_ |
| 303 | `MsiRecordSetInteger <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordsetinteger.asp>`_ |
| 304 | `MsiRecordClear <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msirecordclear.asp>`_ |
| 305 | |
| 306 | .. _msi-errors: |
| 307 | |
| 308 | Errors |
| 309 | ------ |
| 310 | |
| 311 | All wrappers around MSI functions raise :exc:`MsiError`; the string inside the |
| 312 | exception will contain more detail. |
| 313 | |
| 314 | |
| 315 | .. _cab: |
| 316 | |
| 317 | CAB Objects |
| 318 | ----------- |
| 319 | |
| 320 | |
| 321 | .. class:: CAB(name) |
| 322 | |
| 323 | The class :class:`CAB` represents a CAB file. During MSI construction, files |
| 324 | will be added simultaneously to the ``Files`` table, and to a CAB file. Then, |
| 325 | when all files have been added, the CAB file can be written, then added to the |
| 326 | MSI file. |
| 327 | |
| 328 | *name* is the name of the CAB file in the MSI file. |
| 329 | |
| 330 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 331 | .. method:: append(full, file, logical) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 332 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 333 | Add the file with the pathname *full* to the CAB file, under the name |
| 334 | *logical*. If there is already a file named *logical*, a new file name is |
| 335 | created. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 336 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 337 | Return the index of the file in the CAB file, and the new name of the file |
| 338 | inside the CAB file. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 339 | |
| 340 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 341 | .. method:: commit(database) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 342 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 343 | Generate a CAB file, add it as a stream to the MSI file, put it into the |
| 344 | ``Media`` table, and remove the generated file from the disk. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 345 | |
| 346 | |
| 347 | .. _msi-directory: |
| 348 | |
| 349 | Directory Objects |
| 350 | ----------------- |
| 351 | |
| 352 | |
Éric Araujo | 2908765 | 2010-12-26 02:38:05 +0000 | [diff] [blame] | 353 | .. class:: Directory(database, cab, basedir, physical, logical, default, [componentflags]) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 354 | |
| 355 | Create a new directory in the Directory table. There is a current component at |
| 356 | each point in time for the directory, which is either explicitly created through |
| 357 | :meth:`start_component`, or implicitly when files are added for the first time. |
| 358 | Files are added into the current component, and into the cab file. To create a |
| 359 | directory, a base directory object needs to be specified (can be ``None``), the |
| 360 | path to the physical directory, and a logical directory name. *default* |
| 361 | specifies the DefaultDir slot in the directory table. *componentflags* specifies |
| 362 | the default flags that new components get. |
| 363 | |
| 364 | |
Georg Brandl | cd7f32b | 2009-06-08 09:13:45 +0000 | [diff] [blame] | 365 | .. method:: start_component(component=None, feature=None, flags=None, keyfile=None, uuid=None) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 366 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 367 | Add an entry to the Component table, and make this component the current |
| 368 | component for this directory. If no component name is given, the directory |
| 369 | name is used. If no *feature* is given, the current feature is used. If no |
| 370 | *flags* are given, the directory's default flags are used. If no *keyfile* |
| 371 | is given, the KeyPath is left null in the Component table. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 372 | |
| 373 | |
Georg Brandl | cd7f32b | 2009-06-08 09:13:45 +0000 | [diff] [blame] | 374 | .. method:: add_file(file, src=None, version=None, language=None) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 375 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 376 | Add a file to the current component of the directory, starting a new one |
| 377 | if there is no current component. By default, the file name in the source |
| 378 | and the file table will be identical. If the *src* file is specified, it |
| 379 | is interpreted relative to the current directory. Optionally, a *version* |
| 380 | and a *language* can be specified for the entry in the File table. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 381 | |
| 382 | |
Georg Brandl | cd7f32b | 2009-06-08 09:13:45 +0000 | [diff] [blame] | 383 | .. method:: glob(pattern, exclude=None) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 384 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 385 | Add a list of files to the current component as specified in the glob |
| 386 | pattern. Individual files can be excluded in the *exclude* list. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 387 | |
| 388 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 389 | .. method:: remove_pyc() |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 390 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 391 | Remove ``.pyc``/``.pyo`` files on uninstall. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 392 | |
| 393 | |
| 394 | .. seealso:: |
| 395 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 396 | `Directory Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/directory_table.asp>`_ |
| 397 | `File Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/file_table.asp>`_ |
| 398 | `Component Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/component_table.asp>`_ |
| 399 | `FeatureComponents Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/featurecomponents_table.asp>`_ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 400 | |
| 401 | .. _features: |
| 402 | |
| 403 | Features |
| 404 | -------- |
| 405 | |
| 406 | |
Georg Brandl | cd7f32b | 2009-06-08 09:13:45 +0000 | [diff] [blame] | 407 | .. class:: Feature(db, id, title, desc, display, level=1, parent=None, directory=None, attributes=0) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 408 | |
| 409 | Add a new record to the ``Feature`` table, using the values *id*, *parent.id*, |
| 410 | *title*, *desc*, *display*, *level*, *directory*, and *attributes*. The |
| 411 | resulting feature object can be passed to the :meth:`start_component` method of |
| 412 | :class:`Directory`. |
| 413 | |
| 414 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 415 | .. method:: set_current() |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 416 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 417 | Make this feature the current feature of :mod:`msilib`. New components are |
| 418 | automatically added to the default feature, unless a feature is explicitly |
| 419 | specified. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 420 | |
| 421 | |
| 422 | .. seealso:: |
| 423 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 424 | `Feature Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/feature_table.asp>`_ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 425 | |
| 426 | .. _msi-gui: |
| 427 | |
| 428 | GUI classes |
| 429 | ----------- |
| 430 | |
| 431 | :mod:`msilib` provides several classes that wrap the GUI tables in an MSI |
Serhiy Storchaka | bfdcd43 | 2013-10-13 23:09:14 +0300 | [diff] [blame] | 432 | database. However, no standard user interface is provided; use |
| 433 | :mod:`~distutils.command.bdist_msi` to create MSI files with a user-interface |
| 434 | for installing Python packages. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 435 | |
| 436 | |
| 437 | .. class:: Control(dlg, name) |
| 438 | |
| 439 | Base class of the dialog controls. *dlg* is the dialog object the control |
| 440 | belongs to, and *name* is the control's name. |
| 441 | |
| 442 | |
Georg Brandl | cd7f32b | 2009-06-08 09:13:45 +0000 | [diff] [blame] | 443 | .. method:: event(event, argument, condition=1, ordering=None) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 444 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 445 | Make an entry into the ``ControlEvent`` table for this control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 446 | |
| 447 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 448 | .. method:: mapping(event, attribute) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 449 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 450 | Make an entry into the ``EventMapping`` table for this control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 451 | |
| 452 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 453 | .. method:: condition(action, condition) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 454 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 455 | Make an entry into the ``ControlCondition`` table for this control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 456 | |
| 457 | |
| 458 | .. class:: RadioButtonGroup(dlg, name, property) |
| 459 | |
| 460 | Create a radio button control named *name*. *property* is the installer property |
| 461 | that gets set when a radio button is selected. |
| 462 | |
| 463 | |
Georg Brandl | cd7f32b | 2009-06-08 09:13:45 +0000 | [diff] [blame] | 464 | .. method:: add(name, x, y, width, height, text, value=None) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 465 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 466 | Add a radio button named *name* to the group, at the coordinates *x*, *y*, |
Georg Brandl | cd7f32b | 2009-06-08 09:13:45 +0000 | [diff] [blame] | 467 | *width*, *height*, and with the label *text*. If *value* is ``None``, it |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 468 | defaults to *name*. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 469 | |
| 470 | |
| 471 | .. class:: Dialog(db, name, x, y, w, h, attr, title, first, default, cancel) |
| 472 | |
| 473 | Return a new :class:`Dialog` object. An entry in the ``Dialog`` table is made, |
| 474 | with the specified coordinates, dialog attributes, title, name of the first, |
| 475 | default, and cancel controls. |
| 476 | |
| 477 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 478 | .. method:: control(name, type, x, y, width, height, attributes, property, text, control_next, help) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 479 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 480 | Return a new :class:`Control` object. An entry in the ``Control`` table is |
| 481 | made with the specified parameters. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 482 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 483 | This is a generic method; for specific types, specialized methods are |
| 484 | provided. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 485 | |
| 486 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 487 | .. method:: text(name, x, y, width, height, attributes, text) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 488 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 489 | Add and return a ``Text`` control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 490 | |
| 491 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 492 | .. method:: bitmap(name, x, y, width, height, text) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 493 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 494 | Add and return a ``Bitmap`` control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 495 | |
| 496 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 497 | .. method:: line(name, x, y, width, height) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 498 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 499 | Add and return a ``Line`` control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 500 | |
| 501 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 502 | .. method:: pushbutton(name, x, y, width, height, attributes, text, next_control) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 503 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 504 | Add and return a ``PushButton`` control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 505 | |
| 506 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 507 | .. method:: radiogroup(name, x, y, width, height, attributes, property, text, next_control) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 508 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 509 | Add and return a ``RadioButtonGroup`` control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 510 | |
| 511 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 512 | .. method:: checkbox(name, x, y, width, height, attributes, property, text, next_control) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 513 | |
Benjamin Peterson | e41251e | 2008-04-25 01:59:09 +0000 | [diff] [blame] | 514 | Add and return a ``CheckBox`` control. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 515 | |
| 516 | |
| 517 | .. seealso:: |
| 518 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 519 | `Dialog Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/dialog_table.asp>`_ |
| 520 | `Control Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/control_table.asp>`_ |
| 521 | `Control Types <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/controls.asp>`_ |
| 522 | `ControlCondition Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/controlcondition_table.asp>`_ |
| 523 | `ControlEvent Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/controlevent_table.asp>`_ |
| 524 | `EventMapping Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/eventmapping_table.asp>`_ |
| 525 | `RadioButton Table <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/radiobutton_table.asp>`_ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 526 | |
| 527 | .. _msi-tables: |
| 528 | |
| 529 | Precomputed tables |
| 530 | ------------------ |
| 531 | |
| 532 | :mod:`msilib` provides a few subpackages that contain only schema and table |
| 533 | definitions. Currently, these definitions are based on MSI version 2.0. |
| 534 | |
| 535 | |
| 536 | .. data:: schema |
| 537 | |
| 538 | This is the standard MSI schema for MSI 2.0, with the *tables* variable |
| 539 | providing a list of table definitions, and *_Validation_records* providing the |
| 540 | data for MSI validation. |
| 541 | |
| 542 | |
| 543 | .. data:: sequence |
| 544 | |
| 545 | This module contains table contents for the standard sequence tables: |
| 546 | *AdminExecuteSequence*, *AdminUISequence*, *AdvtExecuteSequence*, |
| 547 | *InstallExecuteSequence*, and *InstallUISequence*. |
| 548 | |
| 549 | |
| 550 | .. data:: text |
| 551 | |
| 552 | This module contains definitions for the UIText and ActionText tables, for the |
| 553 | standard installer actions. |