cfgfile.rst 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. .. versionadded:: 0.2
  71. .. _cfg_python:
  72. Python section
  73. --------------
  74. .. describe:: version
  75. The Python version to download and bundle with your application, e.g. ``3.4.3``.
  76. Python 3.3 or later and 2.7 are supported.
  77. .. describe:: bitness (optional)
  78. ``32`` or ``64``, to use 32-bit (x86) or 64-bit (x64) Python. On Windows, this
  79. defaults to the version you're using, so that compiled modules will match. On
  80. other platforms, it defaults to 32-bit.
  81. .. describe:: format (optional)
  82. - ``installer`` includes a copy of the Python MSI installer in your application
  83. and runs it at install time, setting up Python systemwide. This is the
  84. default for now.
  85. - ``bundled`` includes an embeddable Python build, which will be installed as
  86. part of your application. This is available for Python 3.5 and above.
  87. .. _python_bundled:
  88. Bundled Python
  89. ~~~~~~~~~~~~~~
  90. .. versionadded:: 1.6
  91. Experimental support for bundling Python into the application.
  92. Using ``format = bundled``, an embeddable Python build will be downloaded at
  93. build time and packaged along with the application. When the installer runs, it
  94. will create a ``Python`` subfolder inside the install directory with the files
  95. Python needs to run.
  96. This has the advantage of producing smaller, quicker installers (~7.5 MB for a
  97. trivial application), and more standalone installations. But it has a number of
  98. limitations:
  99. - This option is only available for Python 3.5 and above. These versions of
  100. Python have dropped support for Windows XP, so your application will only work
  101. on Windows Vista and newer.
  102. - Installing in Windows Vista to 8.1 (inclusive) may need an internet connection
  103. to download the necessary `Visual C++ runtime
  104. <http://www.microsoft.com/en-us/download/details.aspx?id=48145>`__. This isn't
  105. needed on Windows 10, which includes the necessary files.
  106. - The embeddable Python builds don't include ``tkinter``, to save space.
  107. Applications with a tkinter GUI can't easily use bundled Python. Workarounds
  108. may be found in the future.
  109. - The user cannot easily install extra Python packages in the application's
  110. Python. If your application has plugins based on Python packages, this might
  111. require extra thought about how and where plugins are installed.
  112. Include section
  113. ---------------
  114. To write these lists, put each value on a new line, with more indentation than
  115. the line with the key:
  116. .. code-block:: ini
  117. key=value1
  118. value2
  119. value3
  120. .. describe:: packages (optional)
  121. A list of importable package and module names to include in the installer.
  122. Specify only top-level packages, i.e. without a ``.`` in the name.
  123. .. describe:: files (optional)
  124. Extra files or directories to be installed with your application.
  125. You can optionally add ``> destination`` after each file to install it
  126. somewhere other than the installation directory. The destination can be:
  127. * An absolute path on the target system, e.g. ``C:\\`` (but this is not
  128. usually desirable).
  129. * A path starting with ``$INSTDIR``, the specified installation directory.
  130. * A path starting with any of the `constants NSIS provides
  131. <http://nsis.sourceforge.net/Docs/Chapter4.html#4.2.3>`_, e.g. ``$SYSDIR``.
  132. The destination can also include ``${PRODUCT_NAME}``, which will be expanded
  133. to the name of your application.
  134. For instance, to put a data file in the (32 bit) common files directory:
  135. .. code-block:: ini
  136. [Include]
  137. files=mydata.dat > $COMMONFILES
  138. .. describe:: exclude (optional)
  139. Files to be excluded from your installer. This can be used to include a
  140. Python library or extra directory only partially, for example to include
  141. large monolithic python packages without their samples and test suites to
  142. achieve a smaller installer file.
  143. Please note:
  144. * The parameter is expected to contain a list of files *relative to the
  145. build directory*. Therefore, to include files from a package, you have to
  146. start your pattern with ``pkgs/<packagename>/``.
  147. * You can use `wildcard characters`_ like ``*`` or ``?``, similar to a Unix
  148. shell.
  149. * If you want to exclude whole subfolders, do *not* put a path separator
  150. (e.g. ``/``) at their end.
  151. * The exclude patterns are only applied to packages and to directories
  152. specified using the ``files`` option. If your ``exclude`` option directly
  153. contradicts your ``files`` or ``packages`` option, the files in question
  154. will be included (you can not exclude a full package/extra directory
  155. or a single file listed in ``files``).
  156. Example:
  157. .. code-block:: ini
  158. [Include]
  159. packages=PySide
  160. files=data_dir
  161. exclude=pkgs/PySide/examples
  162. data_dir/ignoredfile
  163. Build section
  164. -------------
  165. .. describe:: directory (optional)
  166. The build directory. Defaults to ``build/nsis/``.
  167. .. describe:: installer_name (optional)
  168. The filename of the installer, relative to the build directory. The default
  169. is made from your application name and version.
  170. .. describe:: nsi_template (optional)
  171. The path of a template .nsi file to specify further details of the installer.
  172. The default template is `part of pynsist <https://github.com/takluyver/pynsist/blob/master/nsist/pyapp.nsi>`_.
  173. This is an advanced option, and if you specify a custom template, you may
  174. well have to update it to work with future releases of Pynsist.
  175. See the `NSIS Scripting Reference <http://nsis.sourceforge.net/Docs/Chapter4.html>`_
  176. for details of the NSIS language, and the Jinja2 `Template Designer Docs
  177. <http://jinja.pocoo.org/docs/dev/templates/>`_ for details of the template
  178. format. Pynsist uses templates with square brackets (``[]``) instead of
  179. Jinja's default curly braces (``{}``).
  180. .. _wildcard characters: https://docs.python.org/3/library/fnmatch.html