contrib/packaging/wix/readme.rst
author Gregory Szorc <gregory.szorc@gmail.com>
Fri, 08 Mar 2019 10:48:22 -0800
changeset 41921 4371f543efda
parent 41920 contrib/packaging/wix/README.txt@c68a1df5c79a
child 43513 081a77df7bc6
permissions -rw-r--r--
wix: functionality to automate building WiX installers Like we did for Inno Setup, we want to make it easier to produce WiX installers. This commit does that. We introduce a new hgpackaging.wix module for performing all the high-level tasks required to produce WiX installers. This required miscellaneous enhancements to existing code in hgpackaging, including support for signing binaries. A new build.py script for calling into the module APIs has been created. It behaves very similarly to the Inno Setup build.py script. Unlike Inno Setup, we didn't have code in the repo previously to generate WiX installers. It appears that all existing automation for building WiX installers lives in the https://bitbucket.org/tortoisehg/thg-winbuild repository - most notably in its setup.py file. My strategy for inventing the code in this commit was to step through the code in that repo's setup.py and observe what it was doing. Despite the length of setup.py in that repository, the actual amount of steps required to produce a WiX installer is actually quite low. It consists of a basic py2exe build plus invocations of candle.exe and light.exe to produce the MSI. One rabbit hole that gave me fits was locating the Visual Studio 9 C Runtime merge modules. These merge modules are only present on your system if you have a full Visual Studio 2008 installation. Fortunately, I have a copy of Visual Studio 2008 and was able to install all the required updates. I then uploaded these merge modules to a personal repository on GitHub. That is where the added code references them from. We probably don't need to ship the merge modules. But that is for another day. The installs from the MSIs produced with the new automation differ from the last official MSI in the following ways: * Our HTML manual pages have UNIX line endings instead of Windows. * We ship modules in the mercurial.pure package. It appears the upstream packaging code is not including this package due to omission (they supply an explicit list of packages that has drifted out of sync with our setup.py). * We do not ship various distutils.* modules. This is because virtualenvs have a custom distutils/__init__.py that automagically imports distutils from its original location and py2exe gets confused by this. We don't use distutils in core Mercurial and don't provide a usable python.exe, so this omission should be acceptable. * The version of the enum package is different and we ship an enum.pyc instead of an enum/__init__.py. * The version of the docutils package is different and we ship a different set of files. * The version of Sphinx is drastically newer and we ship a number of files the old version did not. (I'm not sure why we ship Sphinx - I think it is a side-effect of the way the THG code was installing dependencies.) * We ship the idna package (dependent of requests which is a dependency of newer versions of Sphinx). * The version of imagesize is different and we ship an imagesize.pyc instead of an imagesize/__init__.pyc. * The version of the jinja2 package is different and the sets of files differs. * We ship the packaging package, which is a dependency for Sphinx. * The version of the pygments package is different and the sets of files differs. * We ship the requests package, which is a dependency for Sphinx. * We ship the snowballstemmer package, which is a dependency for Sphinx. * We ship the urllib3 package, which is a dependency for requests, which is a dependency for Sphinx. * We ship a newer version of the futures package, which includes a handful of extra modules that match Python 3 module names. # no-check-commit because foo_bar naming Differential Revision: https://phab.mercurial-scm.org/D6097

WiX Installer
=============

The files in this directory are used to produce an MSI installer using
the WiX Toolset (http://wixtoolset.org/).

The MSI installers require elevated (admin) privileges due to the
installation of MSVC CRT libraries into the Windows system store. See
the Inno Setup installers in the ``inno`` sibling directory for installers
that do not have this requirement.

Requirements
============

Building the WiX installers requires a Windows machine. The following
dependencies must be installed:

* Python 2.7 (download from https://www.python.org/downloads/)
* Microsoft Visual C++ Compiler for Python 2.7
  (https://www.microsoft.com/en-us/download/details.aspx?id=44266)
* Python 3.5+ (to run the ``build.py`` script)

Building
========

The ``build.py`` script automates the process of producing an MSI
installer. It manages fetching and configuring non-system dependencies
(such as py2exe, gettext, and various Python packages).

The script requires an activated ``Visual C++ 2008`` command prompt.
A shortcut to such a prompt was installed with ``Microsoft Visual
C++ Compiler for Python 2.7``. From your Start Menu, look for
``Microsoft Visual C++ Compiler Package for Python 2.7`` then
launch either ``Visual C++ 2008 32-bit Command Prompt`` or
``Visual C++ 2008 64-bit Command Prompt``.

From the prompt, change to the Mercurial source directory. e.g.
``cd c:\src\hg``.

Next, invoke ``build.py`` to produce an MSI installer. You will need
to supply the path to the Python interpreter to use.::

   $ python3 contrib\packaging\wix\build.py \
      --python c:\python27\python.exe

.. note::

   The script validates that the Visual C++ environment is active and
   that the architecture of the specified Python interpreter matches the
   Visual C++ environment. An error is raised otherwise.

If everything runs as intended, dependencies will be fetched and
configured into the ``build`` sub-directory, Mercurial will be built,
and an installer placed in the ``dist`` sub-directory. The final line
of output should print the name of the generated installer.

Additional options may be configured. Run ``build.py --help`` to see
a list of program flags.

Relationship to TortoiseHG
==========================

TortoiseHG uses the WiX files in this directory.

The code for building TortoiseHG installers lives at
https://bitbucket.org/tortoisehg/thg-winbuild and is maintained by
Steve Borho (steve@borho.org).

When changing behavior of the WiX installer, be sure to notify
the TortoiseHG Project of the changes so they have ample time
provide feedback and react to those changes.