cfgfile.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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:: publisher (optional)
  14. The publisher name that shows up in the *Add or Remove programs* control panel.
  15. .. versionadded:: 1.10
  16. .. describe:: entry_point
  17. The function to launch your application, in the format ``module:function``.
  18. Dots are allowed in the module part. pynsist will create a script like this,
  19. plus some boilerplate::
  20. from module import function
  21. function()
  22. .. describe:: script (optional)
  23. Path to the Python script which launches your application, as an alternative
  24. to ``entry_point``.
  25. Ensure that this boilerplate code is at the top of your script::
  26. #!python3.6
  27. import sys
  28. sys.path.insert(0, 'pkgs')
  29. The first line tells it which version of Python to run with. If you use
  30. binary packages, packages compiled for Python 3.3 won't work with Python 3.4.
  31. The other lines make sure it can find the packages installed along with your
  32. application.
  33. .. describe:: target (optional)
  34. parameters (optional)
  35. Lower level definition of a shortcut, to create start menu entries for help
  36. pages or other non-Python entry points. You shouldn't normally use this for
  37. Python entry points.
  38. .. note::
  39. Either ``entry_point``, ``script`` or ``target`` must be specified, but not
  40. more than one. Specifying ``entry_point`` is normally easiest and most
  41. reliable.
  42. .. describe:: icon (optional)
  43. Path to a ``.ico`` file to be used for shortcuts to your application. Pynsist
  44. has a default generic icon, but you probably want to replace it.
  45. .. describe:: console (optional)
  46. If ``true``, shortcuts will be created using the ``py`` launcher, which opens
  47. a console for the process. If ``false``, or not specified, they will use the
  48. ``pyw`` launcher, which doesn't create a console.
  49. .. describe:: extra_preamble (optional)
  50. Path to a file containing extra Python commands to be run before your code is
  51. launched, for example to set environment variables needed by pygtk. This is
  52. only valid if you use ``entry_point`` to specify how to launch your application.
  53. If you use the Python API, this parameter can also be passed as a file-like
  54. object, such as :class:`io.StringIO`.
  55. .. _shortcut_config:
  56. Shortcut sections
  57. -----------------
  58. One shortcut will always be generated for the application. You can add extra
  59. shortcuts by defining sections titled :samp:`Shortcut {Name}`. For example:
  60. .. code-block:: ini
  61. [Shortcut IPython Notebook]
  62. entry_point=IPython.html.notebookapp:launch_new_instance
  63. icon=scripts/ipython_nb.ico
  64. console=true
  65. .. describe:: entry_point
  66. script (optional)
  67. icon (optional)
  68. console (optional)
  69. target (optional)
  70. parameters (optional)
  71. extra_preamble (optional)
  72. These options all work the same way as in the Application section.
  73. Microsoft offers guidance on `what shortcuts to include in the Start screen/menu
  74. <https://msdn.microsoft.com/en-us/library/windows/desktop/jj673981(v=vs.85).aspx#decide_the_right_entry_points_to_include_in_the_start_screen>`__.
  75. Most applications should only need one shortcut, and things like help and
  76. settings should be accessed inside the app rather than as separate shortcuts.
  77. .. _command_config:
  78. Command sections
  79. ----------------
  80. .. versionadded:: 1.7
  81. Your application can install commands to be run from the Windows command prompt.
  82. This is not standard practice for desktop applications on Windows, but if your
  83. application specifically provides a command line interface, you can define
  84. one or more sections titled :samp:`Command {name}`::
  85. [Command guessnumber]
  86. entry_point=guessnumber:main
  87. If you use this, the installer will modify the system :envvar:`PATH` environment
  88. variable.
  89. .. describe:: entry_point
  90. As with shortcuts, this specifies the Python function to call, in the format
  91. ``module:function``.
  92. .. describe:: extra_preamble (optional)
  93. As for shortcuts, a file containing extra code to run before importing the
  94. module from ``entry_point``. This should rarely be needed.
  95. .. _cfg_python:
  96. Python section
  97. --------------
  98. .. describe:: version
  99. The Python version to download and bundle with your application, e.g. ``3.6.3``.
  100. Python 3.5 or later are supported. For older versions of Python, use Pynsist
  101. 1.x.
  102. .. describe:: bitness (optional)
  103. ``32`` or ``64``, to use 32-bit (x86) or 64-bit (x64) Python. On Windows, this
  104. defaults to the version you're using, so that compiled modules will match. On
  105. other platforms, it defaults to 32-bit.
  106. .. describe:: include_msvcrt (optional)
  107. The default is ``true``,
  108. which will include an app-local copy of the Microsoft Visual C++ Runtime,
  109. required for Python to run. The installer will only install this if it doesn't
  110. detect a system installation of the runtime.
  111. Setting this to ``false`` will not include the C++ Runtime. Your application may
  112. not run for all users until they install it manually (`download from Microsoft
  113. <https://www.microsoft.com/en-us/download/details.aspx?id=48145>`__). You may
  114. prefer to do this for security reasons: the separately installed runtime will
  115. get updates through Windows Update, but app-local copies will not.
  116. Users on Windows 10 should already have the runtime installed systemwide, so
  117. this does won't affect them. Users on Windows Vista, 7, 8 or 8.1 *may* already
  118. have it, depending on what else is installed.
  119. .. versionadded:: 1.9
  120. .. note::
  121. Pynsist 1.x also included a ``format=`` option to select between two ways to
  122. use Python: *bundled* or *installer*. Pynsist 2 only supports *bundled*
  123. Python. For the installer option, use Pynsist 1.x.
  124. .. _cfg_include:
  125. Include section
  126. ---------------
  127. To write these lists, put each value on a new line, with more indentation than
  128. the line with the key:
  129. .. code-block:: ini
  130. key=value1
  131. value2
  132. value3
  133. .. describe:: pypi_wheels (optional)
  134. A list of packages in the format ``name==version`` to download from PyPI or
  135. extract from the directories in ``extra_wheel_sources``.
  136. These must be available as wheels; Pynsist will not try to use sdists
  137. or eggs.
  138. .. versionadded:: 1.7
  139. .. describe:: extra_wheel_sources (optional)
  140. One or more directory paths in which to find wheels, in addition to fetching
  141. from PyPI. Each package listed in ``pypi_wheels`` will be retrieved from the
  142. first source containing a
  143. compatible wheel, and all extra sources have priority over PyPI.
  144. Relative paths are from the directory containing the config file.
  145. .. versionadded:: 2.0
  146. .. describe:: packages (optional)
  147. A list of importable package and module names to include in the installer.
  148. Specify only top-level packages, i.e. without a ``.`` in the name.
  149. .. note::
  150. The ``packages`` option finds and copies installed packages from your
  151. development environment. Specifying packages in ``pypi_wheels`` instead
  152. is more reliable, and works with namespace packages.
  153. .. describe:: files (optional)
  154. Extra files or directories to be installed with your application.
  155. You can optionally add ``> destination`` after each file to install it
  156. somewhere other than the installation directory. The destination can be:
  157. * An absolute path on the target system, e.g. ``C:\\`` (but this is not
  158. usually desirable).
  159. * A path starting with ``$INSTDIR``, the specified installation directory.
  160. * A path starting with any of the `constants NSIS provides
  161. <http://nsis.sourceforge.net/Docs/Chapter4.html#4.2.3>`_, e.g. ``$SYSDIR``.
  162. The destination can also include ``${PRODUCT_NAME}``, which will be expanded
  163. to the name of your application.
  164. For instance, to put a data file in the (32 bit) common files directory:
  165. .. code-block:: ini
  166. [Include]
  167. files=mydata.dat > $COMMONFILES
  168. .. describe:: exclude (optional)
  169. Files to be excluded from your installer. This can be used to include a
  170. Python library or extra directory only partially, for example to include
  171. large monolithic python packages without their samples and test suites to
  172. achieve a smaller installer file.
  173. * The parameter is expected to contain a list of files *relative to the
  174. build directory*. Therefore, to include files from a package, you have to
  175. start your pattern with ``pkgs/<packagename>/``.
  176. * You can use `wildcard characters`_ like ``*`` or ``?``, similar to a Unix
  177. shell.
  178. * If you want to exclude whole subfolders, do *not* put a path separator
  179. (e.g. ``/``) at their end.
  180. * The exclude patterns are only applied to packages and to directories
  181. specified using the ``files`` option. If your ``exclude`` option directly
  182. contradicts your ``files`` or ``packages`` option, the files in question
  183. will be included (you can not exclude a full package/extra directory
  184. or a single file listed in ``files``).
  185. Example:
  186. .. code-block:: ini
  187. [Include]
  188. packages=PySide
  189. files=data_dir
  190. exclude=pkgs/PySide/examples
  191. data_dir/ignoredfile
  192. .. _build_config:
  193. Build section
  194. -------------
  195. .. describe:: directory (optional)
  196. The build directory. Defaults to ``build/nsis/``.
  197. .. describe:: installer_name (optional)
  198. The filename of the installer, relative to the build directory. The default
  199. is made from your application name and version.
  200. .. describe:: nsi_template (optional)
  201. The path of a template .nsi file to specify further details of the installer.
  202. The default template is `part of pynsist <https://github.com/takluyver/pynsist/blob/master/nsist/pyapp.nsi>`_.
  203. This is an advanced option, and if you specify a custom template, you may
  204. well have to update it to work with future releases of Pynsist.
  205. See the `NSIS Scripting Reference <http://nsis.sourceforge.net/Docs/Chapter4.html>`_
  206. for details of the NSIS language, and the Jinja2 `Template Designer Docs
  207. <http://jinja.pocoo.org/docs/dev/templates/>`_ for details of the template
  208. format. Pynsist uses templates with square brackets (``[]``) instead of
  209. Jinja's default curly braces (``{}``).
  210. .. _wildcard characters: https://docs.python.org/3/library/fnmatch.html