D7158: packaging: process Inno Setup files with Jinja2
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Sat Nov 9 00:04:51 UTC 2019
Closed by commit rHG04b862675439: packaging: process Inno Setup files with Jinja2 (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D7158?vs=17379&id=17809
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D7158/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D7158
AFFECTED FILES
contrib/packaging/hgpackaging/inno.py
contrib/packaging/inno/mercurial.iss
CHANGE DETAILS
diff --git a/contrib/packaging/inno/mercurial.iss b/contrib/packaging/inno/mercurial.iss
--- a/contrib/packaging/inno/mercurial.iss
+++ b/contrib/packaging/inno/mercurial.iss
@@ -40,7 +40,7 @@
AppPublisherURL=https://mercurial-scm.org/
AppSupportURL=https://mercurial-scm.org/
AppUpdatesURL=https://mercurial-scm.org/
-AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}
+{{ 'AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}' }}
AppContact=mercurial at mercurial-scm.org
DefaultDirName={pf}\Mercurial
SourceDir=..\..
@@ -121,4 +121,5 @@
setArrayLength(Result, 1)
Result[0] := ExpandConstant('{app}');
end;
-#include "modpath.iss"
+
+{% include 'modpath.iss' %}
diff --git a/contrib/packaging/hgpackaging/inno.py b/contrib/packaging/hgpackaging/inno.py
--- a/contrib/packaging/hgpackaging/inno.py
+++ b/contrib/packaging/hgpackaging/inno.py
@@ -12,6 +12,8 @@
import shutil
import subprocess
+import jinja2
+
from .py2exe import build_py2exe
from .util import find_vc_runtime_files
@@ -75,9 +77,26 @@
print('creating installer')
- # Copy Inno files into place.
- for p in ('mercurial.iss', 'modpath.iss'):
- shutil.copyfile(inno_source_dir / p, inno_build_dir / p)
+ # Install Inno files by rendering a template.
+ jinja_env = jinja2.Environment(
+ loader=jinja2.FileSystemLoader(str(inno_source_dir)),
+ # Need to change these to prevent conflict with Inno Setup.
+ comment_start_string='{##',
+ comment_end_string='##}',
+ )
+
+ try:
+ template = jinja_env.get_template('mercurial.iss')
+ except jinja2.TemplateSyntaxError as e:
+ raise Exception(
+ 'template syntax error at %s:%d: %s'
+ % (e.name, e.lineno, e.message,)
+ )
+
+ content = template.render()
+
+ with (inno_build_dir / 'mercurial.iss').open('w', encoding='utf-8') as fh:
+ fh.write(content)
args = [str(iscc_exe)]
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list