1
0

design.rst 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Design principles
  2. =================
  3. or *Why I'm Refusing to Add a Feature*
  4. There are some principles in the design of Pynsist which have led me to turn
  5. down potentially useful options. I've tried to explain them here so that I can
  6. link to this rather than summarising them each time.
  7. 1. Pynsist is largely a **simplifying wrapper** around `NSIS
  8. <http://nsis.sourceforge.net/>`__: it provides an easy way to do a subset of
  9. the things NSIS can do. All simplifying wrappers come under pressure from
  10. people who want to do something just outside what the wrapper currently
  11. covers: they'd love to use the wrapper, if it just had one more option. But
  12. if we keep adding options, eventually the simplifying wrapper becomes a
  13. convoluted layer of extra complexity over the original system.
  14. 2. I'm very keen to **keep installers as simple as possible**. There are all
  15. sorts of clever things we could do at install time. But it's much harder to
  16. write and test the NSIS install code than the Python build code, and errors
  17. when the end user installs your software are a bigger problem than errors
  18. when you build it, because you're better able to understand and fix them.
  19. So Pynsist does as much as possible at build time so that the installer can
  20. be simple.
  21. 3. Pynsist has a **limited scope**: it builds Windows installers for Python
  22. applications. Mostly GUI applications, but it does also have support for
  23. adding command-line tools. I don't plan to add support for other target
  24. platforms or languages.
  25. If you need more flexibility
  26. ----------------------------
  27. If you want to do something which Pynsist doesn't support, there are several
  28. ways it can still help you:
  29. - **Generate an nsi script**: You can run Pynsist once with the
  30. ``--no-makensis`` option. In the build directory, you'll find a file
  31. ``installer.nsi``, which is the script for your installer. You can modify
  32. this and run ``makensis installer.nsi`` yourself to build the installer.
  33. - **Write a custom template**: Pynsist uses *Jinja* templates to create the
  34. nsi script. You can write a custom template and specify it in the
  35. :ref:`build_config` in your config file. Custom templates can inherit from
  36. the templates in Pynsist and override blocks, so you have a lot of control
  37. over the installer this way.
  38. - **Cannibalise the code**: Pull out whatever pieces are useful to you from
  39. Pynsist and use them in your build scripts. There are the installer templates,
  40. code to find and download wheels from PyPI, to download Python itself, to
  41. create command-line entry points, to find ``makensis.exe`` on Windows, and so
  42. on. You can take specific bits to reuse, or copy the whole thing and apply
  43. some changes.