Mercurial > hg
comparison contrib/packaging/hgpackaging/inno.py @ 44762:eec66d9c9e50 stable
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
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 19 Apr 2020 15:35:21 -0700 |
parents | e2589b9e4562 |
children | 94f4f2ec7dee |
comparison
equal
deleted
inserted
replaced
44761:686d738b9df9 | 44762:eec66d9c9e50 |
---|---|
59 if not iscc_exe.exists(): | 59 if not iscc_exe.exists(): |
60 raise Exception('%s does not exist' % iscc_exe) | 60 raise Exception('%s does not exist' % iscc_exe) |
61 | 61 |
62 vc_x64 = r'\x64' in os.environ.get('LIB', '') | 62 vc_x64 = r'\x64' in os.environ.get('LIB', '') |
63 arch = 'x64' if vc_x64 else 'x86' | 63 arch = 'x64' if vc_x64 else 'x86' |
64 inno_source_dir = source_dir / 'contrib' / 'packaging' / 'inno' | 64 inno_build_dir = build_dir / ('inno-py2exe-%s' % arch) |
65 inno_build_dir = build_dir / ('inno-%s' % arch) | |
66 staging_dir = inno_build_dir / 'stage' | 65 staging_dir = inno_build_dir / 'stage' |
67 | 66 |
68 requirements_txt = ( | 67 requirements_txt = ( |
69 source_dir / 'contrib' / 'packaging' / 'requirements_win32.txt' | 68 source_dir / 'contrib' / 'packaging' / 'requirements_win32.txt' |
70 ) | 69 ) |
101 | 100 |
102 dest_path = staging_dir / basename | 101 dest_path = staging_dir / basename |
103 | 102 |
104 print('copying %s to %s' % (f, dest_path)) | 103 print('copying %s to %s' % (f, dest_path)) |
105 shutil.copyfile(f, dest_path) | 104 shutil.copyfile(f, dest_path) |
105 | |
106 build_installer( | |
107 source_dir, | |
108 inno_build_dir, | |
109 staging_dir, | |
110 iscc_exe, | |
111 version, | |
112 arch="x64" if vc_x64 else None, | |
113 ) | |
114 | |
115 | |
116 def build_installer( | |
117 source_dir: pathlib.Path, | |
118 inno_build_dir: pathlib.Path, | |
119 staging_dir: pathlib.Path, | |
120 iscc_exe: pathlib.Path, | |
121 version, | |
122 arch=None, | |
123 ): | |
124 """Build an Inno installer from staged Mercurial files. | |
125 | |
126 This function is agnostic about how to build Mercurial. It just | |
127 cares that Mercurial files are in ``staging_dir``. | |
128 """ | |
129 inno_source_dir = source_dir / "contrib" / "packaging" / "inno" | |
106 | 130 |
107 # The final package layout is simply a mirror of the staging directory. | 131 # The final package layout is simply a mirror of the staging directory. |
108 package_files = [] | 132 package_files = [] |
109 for root, dirs, files in os.walk(staging_dir): | 133 for root, dirs, files in os.walk(staging_dir): |
110 dirs.sort() | 134 dirs.sort() |
156 source_dir / 'contrib' / 'win32' / p, inno_build_dir / p | 180 source_dir / 'contrib' / 'win32' / p, inno_build_dir / p |
157 ) | 181 ) |
158 | 182 |
159 args = [str(iscc_exe)] | 183 args = [str(iscc_exe)] |
160 | 184 |
161 if vc_x64: | 185 if arch: |
162 args.append('/dARCH=x64') | 186 args.append('/dARCH=%s' % arch) |
163 | 187 |
164 if not version: | 188 if not version: |
165 version = read_version_py(source_dir) | 189 version = read_version_py(source_dir) |
166 | 190 |
167 args.append('/dVERSION=%s' % version) | 191 args.append('/dVERSION=%s' % version) |