cfgfile.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 and
  44. during the install/uninstall process. Pynsist has a default generic icon, but
  45. you probably want to replace it.
  46. .. describe:: console (optional)
  47. If ``true``, shortcuts will be created using ``python.exe``, which opens
  48. a console for the process. If ``false``, or not specified, they will use
  49. ``pythonw.exe``, which doesn't create a console. In that case, stdout and
  50. stderr from Python code will be redirected to a log file in :envvar:`APPDATA`.
  51. .. describe:: extra_preamble (optional)
  52. Path to a file containing extra Python commands to be run before your code is
  53. launched, for example to set environment variables needed by pygtk. This is
  54. only valid if you use ``entry_point`` to specify how to launch your application.
  55. If you use the Python API, this parameter can also be passed as a file-like
  56. object, such as :class:`io.StringIO`.
  57. .. describe:: license_file (optional)
  58. Path to a text file containing the license under which your software is to
  59. be distributed. If given, an extra step before installation will check the
  60. user's agreement to abide by the displayed license. If not given, the extra
  61. step is omitted.
  62. .. _shortcut_config:
  63. Shortcut sections
  64. -----------------
  65. One shortcut will always be generated for the application. You can add extra
  66. shortcuts by defining sections titled :samp:`Shortcut {Name}`. For example:
  67. .. code-block:: ini
  68. [Shortcut IPython Notebook]
  69. entry_point=IPython.html.notebookapp:launch_new_instance
  70. icon=scripts/ipython_nb.ico
  71. console=true
  72. .. describe:: entry_point
  73. script (optional)
  74. icon (optional)
  75. console (optional)
  76. target (optional)
  77. parameters (optional)
  78. extra_preamble (optional)
  79. These options all work the same way as in the Application section.
  80. Microsoft offers guidance on `what shortcuts to include in the Start screen/menu
  81. <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>`__.
  82. Most applications should only need one shortcut, and things like help and
  83. settings should be accessed inside the app rather than as separate shortcuts.
  84. .. _command_config:
  85. Command sections
  86. ----------------
  87. .. versionadded:: 1.7
  88. Your application can install commands to be run from the Windows command prompt.
  89. This is not standard practice for desktop applications on Windows, but if your
  90. application specifically provides a command line interface, you can define
  91. one or more sections titled :samp:`Command {name}`::
  92. [Command guessnumber]
  93. entry_point=guessnumber:main
  94. If you use this, the installer will modify the system :envvar:`PATH` environment
  95. variable.
  96. .. describe:: entry_point
  97. As with shortcuts, this specifies the Python function to call, in the format
  98. ``module:function``.
  99. .. describe:: console (optional)
  100. If ``true`` (default), the ``.exe`` wrapper for the command will open a
  101. console if it's not already inside one. If ``false``, it will be a GUI
  102. application, which doesn't use a console.
  103. If the user runs the command directly, they do so in a console anyway.
  104. But commands with ``console=false`` can be useful if your GUI application
  105. needs to run a subprocess without a console window popping up.
  106. .. describe:: extra_preamble (optional)
  107. As for shortcuts, a file containing extra code to run before importing the
  108. module from ``entry_point``. This should rarely be needed.
  109. .. _cfg_python:
  110. Python section
  111. --------------
  112. .. describe:: version
  113. The Python version to download and bundle with your application, e.g. ``3.6.3``.
  114. Python 3.5 or later are supported. For older versions of Python, use Pynsist
  115. 1.x.
  116. .. describe:: bitness (optional)
  117. ``32`` or ``64``, to use 32-bit (x86) or 64-bit (x64) Python. On Windows, this
  118. defaults to the version you're using, so that compiled modules will match. On
  119. other platforms, it defaults to 32-bit.
  120. .. describe:: include_msvcrt (optional)
  121. The default is ``true``,
  122. which will include an app-local copy of the Microsoft Visual C++ Runtime,
  123. required for Python to run. The installer will only install this if it doesn't
  124. detect a system installation of the runtime.
  125. Setting this to ``false`` will not include the C++ Runtime. Your application may
  126. not run for all users until they install it manually (`download from Microsoft
  127. <https://www.microsoft.com/en-us/download/details.aspx?id=48145>`__). You may
  128. prefer to do this for security reasons: the separately installed runtime will
  129. get updates through Windows Update, but app-local copies will not.
  130. Users on Windows 10 should already have the runtime installed systemwide, so
  131. this does won't affect them. Users on Windows Vista, 7, 8 or 8.1 *may* already
  132. have it, depending on what else is installed.
  133. .. versionadded:: 1.9
  134. .. note::
  135. Pynsist 1.x also included a ``format=`` option to select between two ways to
  136. use Python: *bundled* or *installer*. Pynsist 2 only supports *bundled*
  137. Python. For the installer option, use Pynsist 1.x.
  138. .. _cfg_include:
  139. Include section
  140. ---------------
  141. To write these lists, put each value on a new line, with more indentation than
  142. the line with the key:
  143. .. code-block:: ini
  144. key=value1
  145. value2
  146. value3
  147. .. describe:: pypi_wheels (optional)
  148. A list of packages in the format ``name==version`` to download from PyPI or
  149. extract from the directories in ``extra_wheel_sources``.
  150. These must be available as wheels; Pynsist will not try to use sdists
  151. or eggs.
  152. .. versionadded:: 1.7
  153. .. describe:: extra_wheel_sources (optional)
  154. One or more directory paths in which to find wheels, in addition to fetching
  155. from PyPI. Each package listed in ``pypi_wheels`` will be retrieved from the
  156. first source containing a
  157. compatible wheel, and all extra sources have priority over PyPI.
  158. Relative paths are from the directory containing the config file.
  159. .. versionadded:: 2.0
  160. .. describe:: local_wheels (optional)
  161. One or more paths to ``.whl`` wheel files on the local filesystem.
  162. All matching wheel files will be included in the installer.
  163. These paths can also use *glob* patterns to match multiple wheels,
  164. e.g. ``wheels/*.whl`` will include all wheels from the folder ``wheels``.
  165. Pynsist checks that each pattern matches at least one file, that only
  166. one wheel is being used for each distribution name, and that all wheels are
  167. compatible with the target Python version.
  168. Relative paths are from the directory containing the config file.
  169. .. versionadded:: 2.2
  170. .. note::
  171. The ``local_wheels`` option is useful if you're using Pynsist as a step
  172. in a larger build process: you can use another tool to prepare all your
  173. application's dependencies as wheels, and then pass them to Pynsist.
  174. For simpler build processes, ``pypi_wheels`` will search PyPI for compatible
  175. wheels, and handle downloading and caching them.
  176. .. describe:: packages (optional)
  177. A list of importable package and module names to include in the installer.
  178. Specify only top-level packages, i.e. without a ``.`` in the name.
  179. .. note::
  180. The ``packages`` option finds and copies installed packages from your
  181. development environment. Specifying packages in ``pypi_wheels`` instead
  182. is more reliable, and works with namespace packages.
  183. .. describe:: files (optional)
  184. Extra files or directories to be installed with your application.
  185. You can optionally add ``> destination`` after each file to install it
  186. somewhere other than the installation directory. The destination can be:
  187. * An absolute path on the target system, e.g. ``C:\\`` (but this is not
  188. usually desirable).
  189. * A path starting with ``$INSTDIR``, the specified installation directory.
  190. * A path starting with any of the `constants NSIS provides
  191. <http://nsis.sourceforge.net/Docs/Chapter4.html#4.2.3>`_, e.g. ``$SYSDIR``.
  192. The destination can also include ``${PRODUCT_NAME}``, which will be expanded
  193. to the name of your application.
  194. For instance, to put a data file in the (32 bit) common files directory:
  195. .. code-block:: ini
  196. [Include]
  197. files=mydata.dat > $COMMONFILES
  198. .. describe:: exclude (optional)
  199. Files to be excluded from your installer. This can be used to include a
  200. Python library or extra directory only partially, for example to include
  201. large monolithic python packages without their samples and test suites to
  202. achieve a smaller installer file.
  203. * The parameter is expected to contain a list of files *relative to the
  204. build directory*. Therefore, to include files from a package, you have to
  205. start your pattern with ``pkgs/<packagename>/``.
  206. * You can use `wildcard characters`_ like ``*`` or ``?``, similar to a Unix
  207. shell.
  208. * If you want to exclude whole subfolders, do *not* put a path separator
  209. (e.g. ``/``) at their end.
  210. * The exclude patterns are applied to packages, pypi wheels, and directories
  211. specified using the ``files`` option. If your ``exclude`` option directly
  212. contradicts your ``files`` or ``packages`` option, the files in question
  213. will be included (you can not exclude a full package/extra directory
  214. or a single file listed in ``files``).
  215. * Exclude patterns are applied uniformly across platforms and can use
  216. either Unix-style forward-slash (``/``), or Windows-style back-slash (``\``)
  217. path separators. Exclude patterns are normalized so that patterns
  218. written on Unix will work on Windows, and vice-versa.
  219. Example:
  220. .. code-block:: ini
  221. [Include]
  222. packages=PySide
  223. files=data_dir
  224. exclude=pkgs/PySide/examples
  225. data_dir/ignoredfile
  226. .. _build_config:
  227. Build section
  228. -------------
  229. .. describe:: directory (optional)
  230. The build directory. Defaults to ``build/nsis/``.
  231. .. describe:: installer_name (optional)
  232. The filename of the installer, relative to the build directory. The default
  233. is made from your application name and version.
  234. .. describe:: nsi_template (optional)
  235. The path of a template .nsi file to specify further details of the installer.
  236. The default template is `part of pynsist <https://github.com/takluyver/pynsist/blob/master/nsist/pyapp.nsi>`_.
  237. This is an advanced option, and if you specify a custom template, you may
  238. well have to update it to work with future releases of Pynsist.
  239. See the `NSIS Scripting Reference <http://nsis.sourceforge.net/Docs/Chapter4.html>`_
  240. for details of the NSIS language, and the Jinja2 `Template Designer Docs
  241. <http://jinja.pocoo.org/docs/dev/templates/>`_ for details of the template
  242. format. Pynsist uses templates with square brackets (``[]``) instead of
  243. Jinja's default curly braces (``{}``).
  244. .. _wildcard characters: https://docs.python.org/3/library/fnmatch.html