Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | .. _built-dist: |
| 2 | |
| 3 | **************************** |
| 4 | Creating Built Distributions |
| 5 | **************************** |
| 6 | |
| 7 | A "built distribution" is what you're probably used to thinking of either as a |
| 8 | "binary package" or an "installer" (depending on your background). It's not |
| 9 | necessarily binary, though, because it might contain only Python source code |
| 10 | and/or byte-code; and we don't call it a package, because that word is already |
| 11 | spoken for in Python. (And "installer" is a term specific to the world of |
| 12 | mainstream desktop systems.) |
| 13 | |
| 14 | A built distribution is how you make life as easy as possible for installers of |
| 15 | your module distribution: for users of RPM-based Linux systems, it's a binary |
| 16 | RPM; for Windows users, it's an executable installer; for Debian-based Linux |
| 17 | users, it's a Debian package; and so forth. Obviously, no one person will be |
| 18 | able to create built distributions for every platform under the sun, so the |
| 19 | Distutils are designed to enable module developers to concentrate on their |
| 20 | specialty---writing code and creating source distributions---while an |
| 21 | intermediary species called *packagers* springs up to turn source distributions |
| 22 | into built distributions for as many platforms as there are packagers. |
| 23 | |
| 24 | Of course, the module developer could be his own packager; or the packager could |
| 25 | be a volunteer "out there" somewhere who has access to a platform which the |
| 26 | original developer does not; or it could be software periodically grabbing new |
| 27 | source distributions and turning them into built distributions for as many |
| 28 | platforms as the software has access to. Regardless of who they are, a packager |
| 29 | uses the setup script and the :command:`bdist` command family to generate built |
| 30 | distributions. |
| 31 | |
| 32 | As a simple example, if I run the following command in the Distutils source |
| 33 | tree:: |
| 34 | |
| 35 | python setup.py bdist |
| 36 | |
| 37 | then the Distutils builds my module distribution (the Distutils itself in this |
| 38 | case), does a "fake" installation (also in the :file:`build` directory), and |
| 39 | creates the default type of built distribution for my platform. The default |
| 40 | format for built distributions is a "dumb" tar file on Unix, and a simple |
| 41 | executable installer on Windows. (That tar file is considered "dumb" because it |
| 42 | has to be unpacked in a specific location to work.) |
| 43 | |
| 44 | Thus, the above command on a Unix system creates |
| 45 | :file:`Distutils-1.0.{plat}.tar.gz`; unpacking this tarball from the right place |
| 46 | installs the Distutils just as though you had downloaded the source distribution |
| 47 | and run ``python setup.py install``. (The "right place" is either the root of |
| 48 | the filesystem or Python's :file:`{prefix}` directory, depending on the options |
| 49 | given to the :command:`bdist_dumb` command; the default is to make dumb |
| 50 | distributions relative to :file:`{prefix}`.) |
| 51 | |
| 52 | Obviously, for pure Python distributions, this isn't any simpler than just |
| 53 | running ``python setup.py install``\ ---but for non-pure distributions, which |
| 54 | include extensions that would need to be compiled, it can mean the difference |
| 55 | between someone being able to use your extensions or not. And creating "smart" |
| 56 | built distributions, such as an RPM package or an executable installer for |
| 57 | Windows, is far more convenient for users even if your distribution doesn't |
| 58 | include any extensions. |
| 59 | |
| 60 | The :command:`bdist` command has a :option:`--formats` option, similar to the |
| 61 | :command:`sdist` command, which you can use to select the types of built |
| 62 | distribution to generate: for example, :: |
| 63 | |
| 64 | python setup.py bdist --format=zip |
| 65 | |
| 66 | would, when run on a Unix system, create :file:`Distutils-1.0.{plat}.zip`\ |
| 67 | ---again, this archive would be unpacked from the root directory to install the |
| 68 | Distutils. |
| 69 | |
| 70 | The available formats for built distributions are: |
| 71 | |
| 72 | +-------------+------------------------------+---------+ |
| 73 | | Format | Description | Notes | |
| 74 | +=============+==============================+=========+ |
| 75 | | ``gztar`` | gzipped tar file | (1),(3) | |
| 76 | | | (:file:`.tar.gz`) | | |
| 77 | +-------------+------------------------------+---------+ |
| 78 | | ``ztar`` | compressed tar file | \(3) | |
| 79 | | | (:file:`.tar.Z`) | | |
| 80 | +-------------+------------------------------+---------+ |
| 81 | | ``tar`` | tar file (:file:`.tar`) | \(3) | |
| 82 | +-------------+------------------------------+---------+ |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 83 | | ``zip`` | zip file (:file:`.zip`) | (2),(4) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 84 | +-------------+------------------------------+---------+ |
| 85 | | ``rpm`` | RPM | \(5) | |
| 86 | +-------------+------------------------------+---------+ |
| 87 | | ``pkgtool`` | Solaris :program:`pkgtool` | | |
| 88 | +-------------+------------------------------+---------+ |
| 89 | | ``sdux`` | HP-UX :program:`swinstall` | | |
| 90 | +-------------+------------------------------+---------+ |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 91 | | ``wininst`` | self-extracting ZIP file for | \(4) | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 92 | | | Windows | | |
| 93 | +-------------+------------------------------+---------+ |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 94 | | ``msi`` | Microsoft Installer. | | |
| 95 | +-------------+------------------------------+---------+ |
| 96 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 97 | |
| 98 | Notes: |
| 99 | |
| 100 | (1) |
| 101 | default on Unix |
| 102 | |
| 103 | (2) |
| 104 | default on Windows |
| 105 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 106 | (3) |
| 107 | requires external utilities: :program:`tar` and possibly one of :program:`gzip`, |
| 108 | :program:`bzip2`, or :program:`compress` |
| 109 | |
| 110 | (4) |
| 111 | requires either external :program:`zip` utility or :mod:`zipfile` module (part |
| 112 | of the standard Python library since Python 1.6) |
| 113 | |
| 114 | (5) |
| 115 | requires external :program:`rpm` utility, version 3.0.4 or better (use ``rpm |
| 116 | --version`` to find out which version you have) |
| 117 | |
| 118 | You don't have to use the :command:`bdist` command with the :option:`--formats` |
| 119 | option; you can also use the command that directly implements the format you're |
| 120 | interested in. Some of these :command:`bdist` "sub-commands" actually generate |
| 121 | several similar formats; for instance, the :command:`bdist_dumb` command |
| 122 | generates all the "dumb" archive formats (``tar``, ``ztar``, ``gztar``, and |
| 123 | ``zip``), and :command:`bdist_rpm` generates both binary and source RPMs. The |
| 124 | :command:`bdist` sub-commands, and the formats generated by each, are: |
| 125 | |
| 126 | +--------------------------+-----------------------+ |
| 127 | | Command | Formats | |
| 128 | +==========================+=======================+ |
| 129 | | :command:`bdist_dumb` | tar, ztar, gztar, zip | |
| 130 | +--------------------------+-----------------------+ |
| 131 | | :command:`bdist_rpm` | rpm, srpm | |
| 132 | +--------------------------+-----------------------+ |
| 133 | | :command:`bdist_wininst` | wininst | |
| 134 | +--------------------------+-----------------------+ |
Tarek Ziadé | f637050 | 2009-04-05 22:57:21 +0000 | [diff] [blame] | 135 | | :command:`bdist_msi` | msi | |
| 136 | +--------------------------+-----------------------+ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 137 | |
| 138 | The following sections give details on the individual :command:`bdist_\*` |
| 139 | commands. |
| 140 | |
| 141 | |
Georg Brandl | d5f2d6e | 2010-07-31 09:15:10 +0000 | [diff] [blame] | 142 | .. .. _creating-dumb: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 143 | |
Georg Brandl | d5f2d6e | 2010-07-31 09:15:10 +0000 | [diff] [blame] | 144 | .. Creating dumb built distributions |
| 145 | .. ================================= |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 146 | |
Georg Brandl | d5f2d6e | 2010-07-31 09:15:10 +0000 | [diff] [blame] | 147 | .. XXX Need to document absolute vs. prefix-relative packages here, but first |
| 148 | I have to implement it! |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 149 | |
| 150 | |
| 151 | .. _creating-rpms: |
| 152 | |
| 153 | Creating RPM packages |
| 154 | ===================== |
| 155 | |
| 156 | The RPM format is used by many popular Linux distributions, including Red Hat, |
| 157 | SuSE, and Mandrake. If one of these (or any of the other RPM-based Linux |
| 158 | distributions) is your usual environment, creating RPM packages for other users |
| 159 | of that same distribution is trivial. Depending on the complexity of your module |
| 160 | distribution and differences between Linux distributions, you may also be able |
| 161 | to create RPMs that work on different RPM-based distributions. |
| 162 | |
| 163 | The usual way to create an RPM of your module distribution is to run the |
| 164 | :command:`bdist_rpm` command:: |
| 165 | |
| 166 | python setup.py bdist_rpm |
| 167 | |
| 168 | or the :command:`bdist` command with the :option:`--format` option:: |
| 169 | |
| 170 | python setup.py bdist --formats=rpm |
| 171 | |
| 172 | The former allows you to specify RPM-specific options; the latter allows you to |
| 173 | easily specify multiple formats in one run. If you need to do both, you can |
| 174 | explicitly specify multiple :command:`bdist_\*` commands and their options:: |
| 175 | |
| 176 | python setup.py bdist_rpm --packager="John Doe <jdoe@example.org>" \ |
Georg Brandl | 56be37c | 2010-08-02 19:16:34 +0000 | [diff] [blame] | 177 | bdist_wininst --target-version="2.0" |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 178 | |
| 179 | Creating RPM packages is driven by a :file:`.spec` file, much as using the |
| 180 | Distutils is driven by the setup script. To make your life easier, the |
| 181 | :command:`bdist_rpm` command normally creates a :file:`.spec` file based on the |
| 182 | information you supply in the setup script, on the command line, and in any |
| 183 | Distutils configuration files. Various options and sections in the |
| 184 | :file:`.spec` file are derived from options in the setup script as follows: |
| 185 | |
| 186 | +------------------------------------------+----------------------------------------------+ |
| 187 | | RPM :file:`.spec` file option or section | Distutils setup script option | |
| 188 | +==========================================+==============================================+ |
| 189 | | Name | :option:`name` | |
| 190 | +------------------------------------------+----------------------------------------------+ |
| 191 | | Summary (in preamble) | :option:`description` | |
| 192 | +------------------------------------------+----------------------------------------------+ |
| 193 | | Version | :option:`version` | |
| 194 | +------------------------------------------+----------------------------------------------+ |
| 195 | | Vendor | :option:`author` and :option:`author_email`, | |
| 196 | | | or --- & :option:`maintainer` and | |
| 197 | | | :option:`maintainer_email` | |
| 198 | +------------------------------------------+----------------------------------------------+ |
Christian Heimes | c3f30c4 | 2008-02-22 16:37:40 +0000 | [diff] [blame] | 199 | | Copyright | :option:`license` | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 200 | +------------------------------------------+----------------------------------------------+ |
| 201 | | Url | :option:`url` | |
| 202 | +------------------------------------------+----------------------------------------------+ |
| 203 | | %description (section) | :option:`long_description` | |
| 204 | +------------------------------------------+----------------------------------------------+ |
| 205 | |
| 206 | Additionally, there are many options in :file:`.spec` files that don't have |
| 207 | corresponding options in the setup script. Most of these are handled through |
| 208 | options to the :command:`bdist_rpm` command as follows: |
| 209 | |
| 210 | +-------------------------------+-----------------------------+-------------------------+ |
| 211 | | RPM :file:`.spec` file option | :command:`bdist_rpm` option | default value | |
| 212 | | or section | | | |
| 213 | +===============================+=============================+=========================+ |
| 214 | | Release | :option:`release` | "1" | |
| 215 | +-------------------------------+-----------------------------+-------------------------+ |
| 216 | | Group | :option:`group` | "Development/Libraries" | |
| 217 | +-------------------------------+-----------------------------+-------------------------+ |
| 218 | | Vendor | :option:`vendor` | (see above) | |
| 219 | +-------------------------------+-----------------------------+-------------------------+ |
| 220 | | Packager | :option:`packager` | (none) | |
| 221 | +-------------------------------+-----------------------------+-------------------------+ |
| 222 | | Provides | :option:`provides` | (none) | |
| 223 | +-------------------------------+-----------------------------+-------------------------+ |
| 224 | | Requires | :option:`requires` | (none) | |
| 225 | +-------------------------------+-----------------------------+-------------------------+ |
| 226 | | Conflicts | :option:`conflicts` | (none) | |
| 227 | +-------------------------------+-----------------------------+-------------------------+ |
| 228 | | Obsoletes | :option:`obsoletes` | (none) | |
| 229 | +-------------------------------+-----------------------------+-------------------------+ |
| 230 | | Distribution | :option:`distribution_name` | (none) | |
| 231 | +-------------------------------+-----------------------------+-------------------------+ |
| 232 | | BuildRequires | :option:`build_requires` | (none) | |
| 233 | +-------------------------------+-----------------------------+-------------------------+ |
| 234 | | Icon | :option:`icon` | (none) | |
| 235 | +-------------------------------+-----------------------------+-------------------------+ |
| 236 | |
| 237 | Obviously, supplying even a few of these options on the command-line would be |
| 238 | tedious and error-prone, so it's usually best to put them in the setup |
| 239 | configuration file, :file:`setup.cfg`\ ---see section :ref:`setup-config`. If |
| 240 | you distribute or package many Python module distributions, you might want to |
| 241 | put options that apply to all of them in your personal Distutils configuration |
Tarek Ziadé | 96c45a9 | 2010-07-31 09:10:51 +0000 | [diff] [blame] | 242 | file (:file:`~/.pydistutils.cfg`). |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 243 | |
| 244 | There are three steps to building a binary RPM package, all of which are |
| 245 | handled automatically by the Distutils: |
| 246 | |
| 247 | #. create a :file:`.spec` file, which describes the package (analogous to the |
| 248 | Distutils setup script; in fact, much of the information in the setup script |
| 249 | winds up in the :file:`.spec` file) |
| 250 | |
| 251 | #. create the source RPM |
| 252 | |
| 253 | #. create the "binary" RPM (which may or may not contain binary code, depending |
| 254 | on whether your module distribution contains Python extensions) |
| 255 | |
| 256 | Normally, RPM bundles the last two steps together; when you use the Distutils, |
| 257 | all three steps are typically bundled together. |
| 258 | |
| 259 | If you wish, you can separate these three steps. You can use the |
| 260 | :option:`--spec-only` option to make :command:`bdist_rpm` just create the |
| 261 | :file:`.spec` file and exit; in this case, the :file:`.spec` file will be |
| 262 | written to the "distribution directory"---normally :file:`dist/`, but |
| 263 | customizable with the :option:`--dist-dir` option. (Normally, the :file:`.spec` |
| 264 | file winds up deep in the "build tree," in a temporary directory created by |
| 265 | :command:`bdist_rpm`.) |
| 266 | |
| 267 | .. % \XXX{this isn't implemented yet---is it needed?!} |
| 268 | .. % You can also specify a custom \file{.spec} file with the |
| 269 | .. % \longprogramopt{spec-file} option; used in conjunction with |
| 270 | .. % \longprogramopt{spec-only}, this gives you an opportunity to customize |
| 271 | .. % the \file{.spec} file manually: |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 272 | .. % |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 273 | .. % \ begin{verbatim} |
| 274 | .. % > python setup.py bdist_rpm --spec-only |
| 275 | .. % # ...edit dist/FooBar-1.0.spec |
| 276 | .. % > python setup.py bdist_rpm --spec-file=dist/FooBar-1.0.spec |
| 277 | .. % \ end{verbatim} |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 278 | .. % |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 279 | .. % (Although a better way to do this is probably to override the standard |
| 280 | .. % \command{bdist\_rpm} command with one that writes whatever else you want |
| 281 | .. % to the \file{.spec} file.) |
| 282 | |
| 283 | |
| 284 | .. _creating-wininst: |
| 285 | |
| 286 | Creating Windows Installers |
| 287 | =========================== |
| 288 | |
| 289 | Executable installers are the natural format for binary distributions on |
| 290 | Windows. They display a nice graphical user interface, display some information |
| 291 | about the module distribution to be installed taken from the metadata in the |
| 292 | setup script, let the user select a few options, and start or cancel the |
| 293 | installation. |
| 294 | |
| 295 | Since the metadata is taken from the setup script, creating Windows installers |
| 296 | is usually as easy as running:: |
| 297 | |
| 298 | python setup.py bdist_wininst |
| 299 | |
| 300 | or the :command:`bdist` command with the :option:`--formats` option:: |
| 301 | |
| 302 | python setup.py bdist --formats=wininst |
| 303 | |
| 304 | If you have a pure module distribution (only containing pure Python modules and |
| 305 | packages), the resulting installer will be version independent and have a name |
Georg Brandl | c575c90 | 2008-09-13 17:46:05 +0000 | [diff] [blame] | 306 | like :file:`foo-1.0.win32.exe`. These installers can even be created on Unix |
| 307 | platforms or Mac OS X. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 308 | |
| 309 | If you have a non-pure distribution, the extensions can only be created on a |
| 310 | Windows platform, and will be Python version dependent. The installer filename |
| 311 | will reflect this and now has the form :file:`foo-1.0.win32-py2.0.exe`. You |
| 312 | have to create a separate installer for every Python version you want to |
| 313 | support. |
| 314 | |
Georg Brandl | 9afde1c | 2007-11-01 20:32:30 +0000 | [diff] [blame] | 315 | The installer will try to compile pure modules into :term:`bytecode` after installation |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 316 | on the target system in normal and optimizing mode. If you don't want this to |
| 317 | happen for some reason, you can run the :command:`bdist_wininst` command with |
| 318 | the :option:`--no-target-compile` and/or the :option:`--no-target-optimize` |
| 319 | option. |
| 320 | |
| 321 | By default the installer will display the cool "Python Powered" logo when it is |
Benjamin Peterson | d7c3ed5 | 2010-06-27 22:32:30 +0000 | [diff] [blame] | 322 | run, but you can also supply your own 152x261 bitmap which must be a Windows |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 323 | :file:`.bmp` file with the :option:`--bitmap` option. |
| 324 | |
| 325 | The installer will also display a large title on the desktop background window |
| 326 | when it is run, which is constructed from the name of your distribution and the |
| 327 | version number. This can be changed to another text by using the |
| 328 | :option:`--title` option. |
| 329 | |
| 330 | The installer file will be written to the "distribution directory" --- normally |
| 331 | :file:`dist/`, but customizable with the :option:`--dist-dir` option. |
| 332 | |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 333 | .. _cross-compile-windows: |
| 334 | |
| 335 | Cross-compiling on Windows |
| 336 | ========================== |
| 337 | |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 338 | Starting with Python 2.6, distutils is capable of cross-compiling between |
| 339 | Windows platforms. In practice, this means that with the correct tools |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 340 | installed, you can use a 32bit version of Windows to create 64bit extensions |
| 341 | and vice-versa. |
| 342 | |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 343 | To build for an alternate platform, specify the :option:`--plat-name` option |
| 344 | to the build command. Valid values are currently 'win32', 'win-amd64' and |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 345 | 'win-ia64'. For example, on a 32bit version of Windows, you could execute:: |
| 346 | |
| 347 | python setup.py build --plat-name=win-amd64 |
| 348 | |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 349 | to build a 64bit version of your extension. The Windows Installers also |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 350 | support this option, so the command:: |
| 351 | |
| 352 | python setup.py build --plat-name=win-amd64 bdist_wininst |
| 353 | |
| 354 | would create a 64bit installation executable on your 32bit version of Windows. |
| 355 | |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 356 | To cross-compile, you must download the Python source code and cross-compile |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 357 | Python itself for the platform you are targetting - it is not possible from a |
Georg Brandl | 6faee4e | 2010-09-21 14:48:28 +0000 | [diff] [blame] | 358 | binary installation of Python (as the .lib etc file for other platforms are |
Georg Brandl | 48310cd | 2009-01-03 21:18:54 +0000 | [diff] [blame] | 359 | not included.) In practice, this means the user of a 32 bit operating |
| 360 | system will need to use Visual Studio 2008 to open the |
| 361 | :file:`PCBuild/PCbuild.sln` solution in the Python source tree and build the |
| 362 | "x64" configuration of the 'pythoncore' project before cross-compiling |
Christian Heimes | 5e69685 | 2008-04-09 08:37:03 +0000 | [diff] [blame] | 363 | extensions is possible. |
| 364 | |
| 365 | Note that by default, Visual Studio 2008 does not install 64bit compilers or |
| 366 | tools. You may need to reexecute the Visual Studio setup process and select |
| 367 | these tools (using Control Panel->[Add/Remove] Programs is a convenient way to |
| 368 | check or modify your existing install.) |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 369 | |
| 370 | .. _postinstallation-script: |
| 371 | |
| 372 | The Postinstallation script |
| 373 | --------------------------- |
| 374 | |
Benjamin Peterson | d7c3ed5 | 2010-06-27 22:32:30 +0000 | [diff] [blame] | 375 | Starting with Python 2.3, a postinstallation script can be specified with the |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 376 | :option:`--install-script` option. The basename of the script must be |
| 377 | specified, and the script filename must also be listed in the scripts argument |
| 378 | to the setup function. |
| 379 | |
| 380 | This script will be run at installation time on the target system after all the |
| 381 | files have been copied, with ``argv[1]`` set to :option:`-install`, and again at |
| 382 | uninstallation time before the files are removed with ``argv[1]`` set to |
| 383 | :option:`-remove`. |
| 384 | |
| 385 | The installation script runs embedded in the windows installer, every output |
| 386 | (``sys.stdout``, ``sys.stderr``) is redirected into a buffer and will be |
| 387 | displayed in the GUI after the script has finished. |
| 388 | |
| 389 | Some functions especially useful in this context are available as additional |
| 390 | built-in functions in the installation script. |
| 391 | |
| 392 | |
| 393 | .. function:: directory_created(path) |
| 394 | file_created(path) |
| 395 | |
| 396 | These functions should be called when a directory or file is created by the |
| 397 | postinstall script at installation time. It will register *path* with the |
| 398 | uninstaller, so that it will be removed when the distribution is uninstalled. |
| 399 | To be safe, directories are only removed if they are empty. |
| 400 | |
| 401 | |
| 402 | .. function:: get_special_folder_path(csidl_string) |
| 403 | |
| 404 | This function can be used to retrieve special folder locations on Windows like |
| 405 | the Start Menu or the Desktop. It returns the full path to the folder. |
| 406 | *csidl_string* must be one of the following strings:: |
| 407 | |
| 408 | "CSIDL_APPDATA" |
| 409 | |
| 410 | "CSIDL_COMMON_STARTMENU" |
| 411 | "CSIDL_STARTMENU" |
| 412 | |
| 413 | "CSIDL_COMMON_DESKTOPDIRECTORY" |
| 414 | "CSIDL_DESKTOPDIRECTORY" |
| 415 | |
| 416 | "CSIDL_COMMON_STARTUP" |
| 417 | "CSIDL_STARTUP" |
| 418 | |
| 419 | "CSIDL_COMMON_PROGRAMS" |
| 420 | "CSIDL_PROGRAMS" |
| 421 | |
| 422 | "CSIDL_FONTS" |
| 423 | |
| 424 | If the folder cannot be retrieved, :exc:`OSError` is raised. |
| 425 | |
| 426 | Which folders are available depends on the exact Windows version, and probably |
| 427 | also the configuration. For details refer to Microsoft's documentation of the |
Georg Brandl | 60203b4 | 2010-10-06 10:11:56 +0000 | [diff] [blame] | 428 | :c:func:`SHGetSpecialFolderPath` function. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 429 | |
| 430 | |
| 431 | .. function:: create_shortcut(target, description, filename[, arguments[, workdir[, iconpath[, iconindex]]]]) |
| 432 | |
| 433 | This function creates a shortcut. *target* is the path to the program to be |
| 434 | started by the shortcut. *description* is the description of the shortcut. |
| 435 | *filename* is the title of the shortcut that the user will see. *arguments* |
| 436 | specifies the command line arguments, if any. *workdir* is the working directory |
| 437 | for the program. *iconpath* is the file containing the icon for the shortcut, |
| 438 | and *iconindex* is the index of the icon in the file *iconpath*. Again, for |
| 439 | details consult the Microsoft documentation for the :class:`IShellLink` |
| 440 | interface. |
Benjamin Peterson | 8719ad5 | 2009-09-11 22:24:02 +0000 | [diff] [blame] | 441 | |
| 442 | |
| 443 | Vista User Access Control (UAC) |
| 444 | =============================== |
| 445 | |
| 446 | Starting with Python 2.6, bdist_wininst supports a :option:`--user-access-control` |
| 447 | option. The default is 'none' (meaning no UAC handling is done), and other |
| 448 | valid values are 'auto' (meaning prompt for UAC elevation if Python was |
| 449 | installed for all users) and 'force' (meaning always prompt for elevation). |