Show More
@@ -25,7 +25,8 b' def build_py2exe(source_dir: pathlib.Pat' | |||||
25 | python_exe: pathlib.Path, build_name: str, |
|
25 | python_exe: pathlib.Path, build_name: str, | |
26 | venv_requirements_txt: pathlib.Path, |
|
26 | venv_requirements_txt: pathlib.Path, | |
27 | extra_packages=None, extra_excludes=None, |
|
27 | extra_packages=None, extra_excludes=None, | |
28 |
extra_dll_excludes=None |
|
28 | extra_dll_excludes=None, | |
|
29 | extra_packages_script=None): | |||
29 | """Build Mercurial with py2exe. |
|
30 | """Build Mercurial with py2exe. | |
30 |
|
31 | |||
31 | Build files will be placed in ``build_dir``. |
|
32 | Build files will be placed in ``build_dir``. | |
@@ -105,6 +106,16 b' def build_py2exe(source_dir: pathlib.Pat' | |||||
105 | env['DISTUTILS_USE_SDK'] = '1' |
|
106 | env['DISTUTILS_USE_SDK'] = '1' | |
106 | env['MSSdk'] = '1' |
|
107 | env['MSSdk'] = '1' | |
107 |
|
108 | |||
|
109 | if extra_packages_script: | |||
|
110 | more_packages = set(subprocess.check_output( | |||
|
111 | extra_packages_script, | |||
|
112 | cwd=build_dir).split(b'\0')[-1].strip().decode('utf-8').splitlines()) | |||
|
113 | if more_packages: | |||
|
114 | if not extra_packages: | |||
|
115 | extra_packages = more_packages | |||
|
116 | else: | |||
|
117 | extra_packages |= more_packages | |||
|
118 | ||||
108 | if extra_packages: |
|
119 | if extra_packages: | |
109 | env['HG_PY2EXE_EXTRA_PACKAGES'] = ' '.join(sorted(extra_packages)) |
|
120 | env['HG_PY2EXE_EXTRA_PACKAGES'] = ' '.join(sorted(extra_packages)) | |
110 | if extra_excludes: |
|
121 | if extra_excludes: |
@@ -177,7 +177,8 b' def make_libraries_xml(wix_dir: pathlib.' | |||||
177 |
|
177 | |||
178 |
|
178 | |||
179 | def build_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, |
|
179 | def build_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, | |
180 |
msi_name='mercurial', version=None, post_build_fn=None |
|
180 | msi_name='mercurial', version=None, post_build_fn=None, | |
|
181 | extra_packages_script=None): | |||
181 | """Build a WiX MSI installer. |
|
182 | """Build a WiX MSI installer. | |
182 |
|
183 | |||
183 | ``source_dir`` is the path to the Mercurial source tree to use. |
|
184 | ``source_dir`` is the path to the Mercurial source tree to use. | |
@@ -189,6 +190,10 b' def build_installer(source_dir: pathlib.' | |||||
189 | Mercurial but before invoking WiX. It can be used to e.g. facilitate |
|
190 | Mercurial but before invoking WiX. It can be used to e.g. facilitate | |
190 | signing. It is passed the paths to the Mercurial source, build, and |
|
191 | signing. It is passed the paths to the Mercurial source, build, and | |
191 | dist directories and the resolved Mercurial version. |
|
192 | dist directories and the resolved Mercurial version. | |
|
193 | ``extra_packages_script`` is a command to be run to inject extra packages | |||
|
194 | into the py2exe binary. It should stage packages into the virtualenv and | |||
|
195 | print a null byte followed by a newline-separated list of packages that | |||
|
196 | should be included in the exe. | |||
192 | """ |
|
197 | """ | |
193 | arch = 'x64' if r'\x64' in os.environ.get('LIB', '') else 'x86' |
|
198 | arch = 'x64' if r'\x64' in os.environ.get('LIB', '') else 'x86' | |
194 |
|
199 | |||
@@ -200,7 +205,8 b' def build_installer(source_dir: pathlib.' | |||||
200 |
|
205 | |||
201 | build_py2exe(source_dir, hg_build_dir, |
|
206 | build_py2exe(source_dir, hg_build_dir, | |
202 | python_exe, 'wix', requirements_txt, |
|
207 | python_exe, 'wix', requirements_txt, | |
203 |
extra_packages=EXTRA_PACKAGES |
|
208 | extra_packages=EXTRA_PACKAGES, | |
|
209 | extra_packages_script=extra_packages_script) | |||
204 |
|
210 | |||
205 | version = version or normalize_version(find_version(source_dir)) |
|
211 | version = version or normalize_version(find_version(source_dir)) | |
206 | print('using version string: %s' % version) |
|
212 | print('using version string: %s' % version) | |
@@ -280,7 +286,7 b' def build_installer(source_dir: pathlib.' | |||||
280 | def build_signed_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, |
|
286 | def build_signed_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, | |
281 | name: str, version=None, subject_name=None, |
|
287 | name: str, version=None, subject_name=None, | |
282 | cert_path=None, cert_password=None, |
|
288 | cert_path=None, cert_password=None, | |
283 | timestamp_url=None): |
|
289 | timestamp_url=None, extra_packages_script=None): | |
284 | """Build an installer with signed executables.""" |
|
290 | """Build an installer with signed executables.""" | |
285 |
|
291 | |||
286 | post_build_fn = make_post_build_signing_fn( |
|
292 | post_build_fn = make_post_build_signing_fn( | |
@@ -292,7 +298,8 b' def build_signed_installer(source_dir: p' | |||||
292 |
|
298 | |||
293 | info = build_installer(source_dir, python_exe=python_exe, |
|
299 | info = build_installer(source_dir, python_exe=python_exe, | |
294 | msi_name=name.lower(), version=version, |
|
300 | msi_name=name.lower(), version=version, | |
295 |
post_build_fn=post_build_fn |
|
301 | post_build_fn=post_build_fn, | |
|
302 | extra_packages_script=extra_packages_script) | |||
296 |
|
303 | |||
297 | description = '%s %s' % (name, version) |
|
304 | description = '%s %s' % (name, version) | |
298 |
|
305 |
@@ -34,6 +34,9 b" if __name__ == '__main__':" | |||||
34 | help='URL of timestamp server to use for signing') |
|
34 | help='URL of timestamp server to use for signing') | |
35 | parser.add_argument('--version', |
|
35 | parser.add_argument('--version', | |
36 | help='Version string to use') |
|
36 | help='Version string to use') | |
|
37 | parser.add_argument('--extra-packages-script', | |||
|
38 | help=('Script to execute to include extra packages in ' | |||
|
39 | 'py2exe binary.')) | |||
37 |
|
40 | |||
38 | args = parser.parse_args() |
|
41 | args = parser.parse_args() | |
39 |
|
42 | |||
@@ -54,6 +57,9 b" if __name__ == '__main__':" | |||||
54 | 'version': args.version, |
|
57 | 'version': args.version, | |
55 | } |
|
58 | } | |
56 |
|
59 | |||
|
60 | if args.extra_packages_script: | |||
|
61 | kwargs['extra_packages_script'] = args.extra_packages_script | |||
|
62 | ||||
57 | if args.sign_sn or args.sign_cert: |
|
63 | if args.sign_sn or args.sign_cert: | |
58 | fn = build_signed_installer |
|
64 | fn = build_signed_installer | |
59 | kwargs['name'] = args.name |
|
65 | kwargs['name'] = args.name |
General Comments 0
You need to be logged in to leave comments.
Login now