packaging: split Inno installer building from Mercurial building stable
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 19 Apr 2020 15:35:21 -0700
branchstable
changeset 44747 eec66d9c9e50
parent 44746 686d738b9df9
child 44748 94f4f2ec7dee
packaging: split Inno installer building from Mercurial building We want to make the logic for producing the installer agnostic about how Mercurial is built to allow for alternate build methods (like PyOxidizer). Differential Revision: https://phab.mercurial-scm.org/D8472
contrib/packaging/hgpackaging/inno.py
--- a/contrib/packaging/hgpackaging/inno.py	Sun Apr 19 14:25:27 2020 -0700
+++ b/contrib/packaging/hgpackaging/inno.py	Sun Apr 19 15:35:21 2020 -0700
@@ -61,8 +61,7 @@
 
     vc_x64 = r'\x64' in os.environ.get('LIB', '')
     arch = 'x64' if vc_x64 else 'x86'
-    inno_source_dir = source_dir / 'contrib' / 'packaging' / 'inno'
-    inno_build_dir = build_dir / ('inno-%s' % arch)
+    inno_build_dir = build_dir / ('inno-py2exe-%s' % arch)
     staging_dir = inno_build_dir / 'stage'
 
     requirements_txt = (
@@ -104,6 +103,31 @@
         print('copying %s to %s' % (f, dest_path))
         shutil.copyfile(f, dest_path)
 
+    build_installer(
+        source_dir,
+        inno_build_dir,
+        staging_dir,
+        iscc_exe,
+        version,
+        arch="x64" if vc_x64 else None,
+    )
+
+
+def build_installer(
+    source_dir: pathlib.Path,
+    inno_build_dir: pathlib.Path,
+    staging_dir: pathlib.Path,
+    iscc_exe: pathlib.Path,
+    version,
+    arch=None,
+):
+    """Build an Inno installer from staged Mercurial files.
+
+    This function is agnostic about how to build Mercurial. It just
+    cares that Mercurial files are in ``staging_dir``.
+    """
+    inno_source_dir = source_dir / "contrib" / "packaging" / "inno"
+
     # The final package layout is simply a mirror of the staging directory.
     package_files = []
     for root, dirs, files in os.walk(staging_dir):
@@ -158,8 +182,8 @@
 
     args = [str(iscc_exe)]
 
-    if vc_x64:
-        args.append('/dARCH=x64')
+    if arch:
+        args.append('/dARCH=%s' % arch)
 
     if not version:
         version = read_version_py(source_dir)