Mercurial > hg
annotate contrib/packaging/hgpackaging/inno.py @ 48848:17d5e25b8e78
packaging: remove py2exe / Python 2.7 support
This commit started by deleting references to py2exe (which is only used
on Python 2). After pulling the thread, quite a lot of code was orphaned
and was deleted.
Differential Revision: https://phab.mercurial-scm.org/D12265
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Feb 2022 22:13:11 -0700 |
parents | df1767fa822d |
children |
rev | line source |
---|---|
41911
dc7827a9ba64
packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41910
diff
changeset
|
1 # inno.py - Inno Setup functionality. |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 # no-check-code because Python 3 native. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 import os |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 import pathlib |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 import shutil |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 import subprocess |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
43515
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
15 import jinja2 |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
16 |
47208
df1767fa822d
packaging: rename run_pyoxidizer()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
46364
diff
changeset
|
17 from .pyoxidizer import create_pyoxidizer_install_layout |
43518
7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43517
diff
changeset
|
18 from .util import ( |
44221
f37971c31067
packaging: set the FileVersion field in the Inno installer executable
Matt Harbison <matt_harbison@yahoo.com>
parents:
43518
diff
changeset
|
19 normalize_windows_version, |
44222
a8786727e478
packaging: bundle the default mercurial.ini template with Inno also
Matt Harbison <matt_harbison@yahoo.com>
parents:
44221
diff
changeset
|
20 process_install_rules, |
43518
7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43517
diff
changeset
|
21 read_version_py, |
7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43517
diff
changeset
|
22 ) |
41911
dc7827a9ba64
packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41910
diff
changeset
|
23 |
46364
5b747aa1b2be
packaging: include `windows_curses` when building py2exe
Matt Harbison <matt_harbison@yahoo.com>
parents:
45942
diff
changeset
|
24 |
44222
a8786727e478
packaging: bundle the default mercurial.ini template with Inno also
Matt Harbison <matt_harbison@yahoo.com>
parents:
44221
diff
changeset
|
25 EXTRA_INSTALL_RULES = [ |
a8786727e478
packaging: bundle the default mercurial.ini template with Inno also
Matt Harbison <matt_harbison@yahoo.com>
parents:
44221
diff
changeset
|
26 ('contrib/win32/mercurial.ini', 'defaultrc/mercurial.rc'), |
a8786727e478
packaging: bundle the default mercurial.ini template with Inno also
Matt Harbison <matt_harbison@yahoo.com>
parents:
44221
diff
changeset
|
27 ] |
a8786727e478
packaging: bundle the default mercurial.ini template with Inno also
Matt Harbison <matt_harbison@yahoo.com>
parents:
44221
diff
changeset
|
28 |
43516
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
29 PACKAGE_FILES_METADATA = { |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
30 'ReadMe.html': 'Flags: isreadme', |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
31 } |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
32 |
41916
260305e8ddbd
setup: configure py2exe config via environment variables
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41915
diff
changeset
|
33 |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
34 def build_with_pyoxidizer( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
35 source_dir: pathlib.Path, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
36 build_dir: pathlib.Path, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
37 target_triple: str, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
38 iscc_exe: pathlib.Path, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
39 version=None, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
40 ): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
41 """Build the Inno installer using PyOxidizer.""" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
42 if not iscc_exe.exists(): |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
43 raise Exception("%s does not exist" % iscc_exe) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
44 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
45 inno_build_dir = build_dir / ("inno-pyoxidizer-%s" % target_triple) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
46 staging_dir = inno_build_dir / "stage" |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
47 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
48 inno_build_dir.mkdir(parents=True, exist_ok=True) |
47208
df1767fa822d
packaging: rename run_pyoxidizer()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
46364
diff
changeset
|
49 create_pyoxidizer_install_layout( |
df1767fa822d
packaging: rename run_pyoxidizer()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
46364
diff
changeset
|
50 source_dir, inno_build_dir, staging_dir, target_triple |
df1767fa822d
packaging: rename run_pyoxidizer()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
46364
diff
changeset
|
51 ) |
44763
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
52 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
53 process_install_rules(EXTRA_INSTALL_RULES, source_dir, staging_dir) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
54 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
55 build_installer( |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
56 source_dir, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
57 inno_build_dir, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
58 staging_dir, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
59 iscc_exe, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
60 version, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
61 arch="x64" if "x86_64" in target_triple else None, |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
62 ) |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
63 |
94f4f2ec7dee
packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44762
diff
changeset
|
64 |
44762
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
65 def build_installer( |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
66 source_dir: pathlib.Path, |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
67 inno_build_dir: pathlib.Path, |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
68 staging_dir: pathlib.Path, |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
69 iscc_exe: pathlib.Path, |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
70 version, |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
71 arch=None, |
44769
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
72 suffix="", |
44762
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
73 ): |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
74 """Build an Inno installer from staged Mercurial files. |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
75 |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
76 This function is agnostic about how to build Mercurial. It just |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
77 cares that Mercurial files are in ``staging_dir``. |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
78 """ |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
79 inno_source_dir = source_dir / "contrib" / "packaging" / "inno" |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
80 |
43516
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
81 # The final package layout is simply a mirror of the staging directory. |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
82 package_files = [] |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
83 for root, dirs, files in os.walk(staging_dir): |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
84 dirs.sort() |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
85 |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
86 root = pathlib.Path(root) |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
87 |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
88 for f in sorted(files): |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
89 full = root / f |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
90 rel = full.relative_to(staging_dir) |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
91 if str(rel.parent) == '.': |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
92 dest_dir = '{app}' |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
93 else: |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
94 dest_dir = '{app}\\%s' % rel.parent |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
95 |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
96 package_files.append( |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
97 { |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
98 'source': rel, |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
99 'dest_dir': dest_dir, |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
100 'metadata': PACKAGE_FILES_METADATA.get(str(rel), None), |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
101 } |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
102 ) |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
103 |
41913
5e923355c595
packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41912
diff
changeset
|
104 print('creating installer') |
5e923355c595
packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41912
diff
changeset
|
105 |
43515
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
106 # Install Inno files by rendering a template. |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
107 jinja_env = jinja2.Environment( |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
108 loader=jinja2.FileSystemLoader(str(inno_source_dir)), |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
109 # Need to change these to prevent conflict with Inno Setup. |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
110 comment_start_string='{##', |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
111 comment_end_string='##}', |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
112 ) |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
113 |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
114 try: |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
115 template = jinja_env.get_template('mercurial.iss') |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
116 except jinja2.TemplateSyntaxError as e: |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
117 raise Exception( |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
118 'template syntax error at %s:%d: %s' |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45752
diff
changeset
|
119 % ( |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45752
diff
changeset
|
120 e.name, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45752
diff
changeset
|
121 e.lineno, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45752
diff
changeset
|
122 e.message, |
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45752
diff
changeset
|
123 ) |
43515
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
124 ) |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
125 |
43516
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
126 content = template.render(package_files=package_files) |
43515
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
127 |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
128 with (inno_build_dir / 'mercurial.iss').open('w', encoding='utf-8') as fh: |
7bd88d0d6a82
packaging: process Inno Setup files with Jinja2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43514
diff
changeset
|
129 fh.write(content) |
43514
10454e788111
packaging: install and run Inno files in a build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43076
diff
changeset
|
130 |
43516
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
131 # Copy additional files used by Inno. |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
132 for p in ('mercurial.ico', 'postinstall.txt'): |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
133 shutil.copyfile( |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
134 source_dir / 'contrib' / 'win32' / p, inno_build_dir / p |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
135 ) |
d053d3f10b6a
packaging: stage installed files for Inno
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43515
diff
changeset
|
136 |
41913
5e923355c595
packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41912
diff
changeset
|
137 args = [str(iscc_exe)] |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
138 |
44762
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
139 if arch: |
eec66d9c9e50
packaging: split Inno installer building from Mercurial building
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44224
diff
changeset
|
140 args.append('/dARCH=%s' % arch) |
44769
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
141 args.append('/dSUFFIX=-%s%s' % (arch, suffix)) |
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
142 else: |
9ade217b550d
packaging: add -python2 to Windows installer filenames
Gregory Szorc <gregory.szorc@gmail.com>
parents:
44763
diff
changeset
|
143 args.append('/dSUFFIX=-x86%s' % suffix) |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
144 |
43518
7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43517
diff
changeset
|
145 if not version: |
7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43517
diff
changeset
|
146 version = read_version_py(source_dir) |
7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43517
diff
changeset
|
147 |
7c9f63a5cb14
packaging: always pass VERSION into Inno invocation
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43517
diff
changeset
|
148 args.append('/dVERSION=%s' % version) |
44221
f37971c31067
packaging: set the FileVersion field in the Inno installer executable
Matt Harbison <matt_harbison@yahoo.com>
parents:
43518
diff
changeset
|
149 args.append('/dQUAD_VERSION=%s' % normalize_windows_version(version)) |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 |
41913
5e923355c595
packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41912
diff
changeset
|
151 args.append('/Odist') |
43514
10454e788111
packaging: install and run Inno files in a build directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43076
diff
changeset
|
152 args.append(str(inno_build_dir / 'mercurial.iss')) |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
153 |
41913
5e923355c595
packaging: don't use temporary directory
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41912
diff
changeset
|
154 subprocess.run(args, cwd=str(source_dir), check=True) |