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