cfgfile.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. The Config File
  2. ===============
  3. All paths in the config file are relative to the directory where the config
  4. file is located, unless noted otherwise.
  5. Application section
  6. -------------------
  7. .. describe:: name
  8. The user-readable name of your application. This will be used for various
  9. display purposes in the installer, and for shortcuts and the folder in
  10. 'Program Files'.
  11. .. describe:: version
  12. The version number of your application.
  13. .. describe:: entry_point
  14. The function to launch your application, in the format ``module:function``.
  15. Dots are allowed in the module part. pynsist will create a script like this,
  16. plus some boilerplate::
  17. from module import function
  18. function()
  19. .. describe:: script (optional)
  20. Path to the Python script which launches your application, as an alternative
  21. to ``entry_point``.
  22. Ensure that this boilerplate code is at the top of your script::
  23. #!python3.3
  24. import sys
  25. sys.path.insert(0, 'pkgs')
  26. The first line tells it which version of Python to run with. If you use
  27. binary packages, packages compiled for Python 3.3 won't work with Python 3.4.
  28. The other lines make sure it can find the packages installed along with your
  29. application.
  30. .. describe:: target (optional)
  31. parameters (optional)
  32. Lower level definition of a shortcut, to create start menu entries for help
  33. pages or other non-Python entry points. You shouldn't normally use this for
  34. Python entry points.
  35. .. note::
  36. Either ``entry_point``, ``script`` or ``target`` must be specified, but not
  37. more than one. Specifying ``entry_point`` is normally easiest and most
  38. reliable.
  39. .. describe:: icon (optional)
  40. Path to a ``.ico`` file to be used for shortcuts to your application. Pynsist
  41. has a default generic icon, but you probably want to replace it.
  42. .. describe:: console (optional)
  43. If ``true``, shortcuts will be created using the ``py`` launcher, which opens
  44. a console for the process. If ``false``, or not specified, they will use the
  45. ``pyw`` launcher, which doesn't create a console.
  46. .. describe:: extra_preamble (optional)
  47. Path to a file containing extra Python commands to be run before your code is
  48. launched, for example to set environment variables needed by pygtk. This is
  49. only valid if you use ``entry_point`` to specify how to launch your application.
  50. If you use the Python API, this parameter can also be passed as a file-like
  51. object, such as :class:`io.StringIO`.
  52. .. _shortcut_config:
  53. Shortcut sections
  54. -----------------
  55. One shortcut will always be generated for the application. You can add extra
  56. shortcuts by defining sections titled :samp:`Shortcut {Name}`. For example:
  57. .. code-block:: ini
  58. [Shortcut IPython Notebook]
  59. entry_point=IPython.html.notebookapp:launch_new_instance
  60. icon=scripts/ipython_nb.ico
  61. console=true
  62. .. describe:: entry_point
  63. script (optional)
  64. icon (optional)
  65. console (optional)
  66. target (optional)
  67. parameters (optional)
  68. extra_preamble (optional)
  69. These options all work the same way as in the Application section.
  70. .. _command_config:
  71. Command sections
  72. ----------------
  73. .. versionadded:: 1.7
  74. Your application can install commands to be run from the Windows command prompt.
  75. This is not standard practice for desktop applications on Windows, but if your
  76. application specifically provides a command line interface, you can define
  77. one or more sections titled :samp:`Command {name}`::
  78. [Command guessnumber]
  79. entry_point=guessnumber:main
  80. If you use this, the installer will modify the system :envvar:`PATH` environment
  81. variable.
  82. .. describe:: entry_point
  83. As with shortcuts, this specifies the Python function to call, in the format
  84. ``module:function``.
  85. .. describe:: extra_preamble (optional)
  86. As for shortcuts, a file containing extra code to run before importing the
  87. module from ``entry_point``. This should rarely be needed.
  88. .. _cfg_python:
  89. Python section
  90. --------------
  91. .. describe:: version
  92. The Python version to download and bundle with your application, e.g. ``3.4.3``.
  93. Python 3.3 or later and 2.7 are supported.
  94. .. describe:: bitness (optional)
  95. ``32`` or ``64``, to use 32-bit (x86) or 64-bit (x64) Python. On Windows, this
  96. defaults to the version you're using, so that compiled modules will match. On
  97. other platforms, it defaults to 32-bit.
  98. .. describe:: format (optional)
  99. - ``installer`` includes a copy of the Python MSI installer in your application
  100. and runs it at install time, setting up Python systemwide. This is the
  101. default for now.
  102. - ``bundled`` includes an embeddable Python build, which will be installed as
  103. part of your application. This is available for Python 3.5 and above.
  104. .. _python_bundled:
  105. Bundled Python
  106. ~~~~~~~~~~~~~~
  107. .. versionadded:: 1.6
  108. Experimental support for bundling Python into the application.
  109. Using ``format = bundled``, an embeddable Python build will be downloaded at
  110. build time and packaged along with the application. When the installer runs, it
  111. will create a ``Python`` subfolder inside the install directory with the files
  112. Python needs to run.
  113. This has the advantage of producing smaller, quicker installers (~7.5 MB for a
  114. trivial application), and more standalone installations. But it has a number of
  115. limitations:
  116. - This option is only available for Python 3.5 and above. These versions of
  117. Python have dropped support for Windows XP, so your application will only work
  118. on Windows Vista and newer.
  119. - Installing in Windows Vista to 8.1 (inclusive) may need an internet connection
  120. to download the necessary `Visual C++ runtime
  121. <http://www.microsoft.com/en-us/download/details.aspx?id=48145>`__. This isn't
  122. needed on Windows 10, which includes the necessary files.
  123. - The embeddable Python builds don't include ``tkinter``, to save space.
  124. Applications with a tkinter GUI can't easily use bundled Python. Workarounds
  125. may be found in the future.
  126. - The user cannot easily install extra Python packages in the application's
  127. Python. If your application has plugins based on Python packages, this might
  128. require extra thought about how and where plugins are installed.
  129. Include section
  130. ---------------
  131. To write these lists, put each value on a new line, with more indentation than
  132. the line with the key:
  133. .. code-block:: ini
  134. key=value1
  135. value2
  136. value3
  137. .. describe:: packages (optional)
  138. A list of importable package and module names to include in the installer.
  139. Specify only top-level packages, i.e. without a ``.`` in the name.
  140. .. describe:: pypi_wheels (optional)
  141. A list of packages to download from PyPI, in the format ``name==version``.
  142. These must be available as wheels; Pynsist will not try to download sdists
  143. or eggs.
  144. .. versionadded:: 1.7
  145. .. describe:: files (optional)
  146. Extra files or directories to be installed with your application.
  147. You can optionally add ``> destination`` after each file to install it
  148. somewhere other than the installation directory. The destination can be:
  149. * An absolute path on the target system, e.g. ``C:\\`` (but this is not
  150. usually desirable).
  151. * A path starting with ``$INSTDIR``, the specified installation directory.
  152. * A path starting with any of the `constants NSIS provides
  153. <http://nsis.sourceforge.net/Docs/Chapter4.html#4.2.3>`_, e.g. ``$SYSDIR``.
  154. The destination can also include ``${PRODUCT_NAME}``, which will be expanded
  155. to the name of your application.
  156. For instance, to put a data file in the (32 bit) common files directory:
  157. .. code-block:: ini
  158. [Include]
  159. files=mydata.dat > $COMMONFILES
  160. .. describe:: exclude (optional)
  161. Files to be excluded from your installer. This can be used to include a
  162. Python library or extra directory only partially, for example to include
  163. large monolithic python packages without their samples and test suites to
  164. achieve a smaller installer file.
  165. Please note:
  166. * The parameter is expected to contain a list of files *relative to the
  167. build directory*. Therefore, to include files from a package, you have to
  168. start your pattern with ``pkgs/<packagename>/``.
  169. * You can use `wildcard characters`_ like ``*`` or ``?``, similar to a Unix
  170. shell.
  171. * If you want to exclude whole subfolders, do *not* put a path separator
  172. (e.g. ``/``) at their end.
  173. * The exclude patterns are only applied to packages and to directories
  174. specified using the ``files`` option. If your ``exclude`` option directly
  175. contradicts your ``files`` or ``packages`` option, the files in question
  176. will be included (you can not exclude a full package/extra directory
  177. or a single file listed in ``files``).
  178. Example:
  179. .. code-block:: ini
  180. [Include]
  181. packages=PySide
  182. files=data_dir
  183. exclude=pkgs/PySide/examples
  184. data_dir/ignoredfile
  185. Build section
  186. -------------
  187. .. describe:: directory (optional)
  188. The build directory. Defaults to ``build/nsis/``.
  189. .. describe:: installer_name (optional)
  190. The filename of the installer, relative to the build directory. The default
  191. is made from your application name and version.
  192. .. describe:: nsi_template (optional)
  193. The path of a template .nsi file to specify further details of the installer.
  194. The default template is `part of pynsist <https://github.com/takluyver/pynsist/blob/master/nsist/pyapp.nsi>`_.
  195. This is an advanced option, and if you specify a custom template, you may
  196. well have to update it to work with future releases of Pynsist.
  197. See the `NSIS Scripting Reference <http://nsis.sourceforge.net/Docs/Chapter4.html>`_
  198. for details of the NSIS language, and the Jinja2 `Template Designer Docs
  199. <http://jinja.pocoo.org/docs/dev/templates/>`_ for details of the template
  200. format. Pynsist uses templates with square brackets (``[]``) instead of
  201. Jinja's default curly braces (``{}``).
  202. .. _wildcard characters: https://docs.python.org/3/library/fnmatch.html