Mercurial > hg
diff contrib/packaging/hgpackaging/wix.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 1711f5813a63 |
children | ce96be208ea4 |
line wrap: on
line diff
--- a/contrib/packaging/hgpackaging/wix.py Sat Oct 05 10:29:34 2019 -0400 +++ b/contrib/packaging/hgpackaging/wix.py Sun Oct 06 09:45:02 2019 -0400 @@ -15,12 +15,8 @@ import typing import xml.dom.minidom -from .downloads import ( - download_entry, -) -from .py2exe import ( - build_py2exe, -) +from .downloads import download_entry +from .py2exe import build_py2exe from .util import ( extract_zip_to_directory, sign_with_signtool, @@ -84,17 +80,29 @@ def ensure_vc90_merge_modules(build_dir): x86 = ( - download_entry('vc9-crt-x86-msm', build_dir, - local_name='microsoft.vcxx.crt.x86_msm.msm')[0], - download_entry('vc9-crt-x86-msm-policy', build_dir, - local_name='policy.x.xx.microsoft.vcxx.crt.x86_msm.msm')[0] + download_entry( + 'vc9-crt-x86-msm', + build_dir, + local_name='microsoft.vcxx.crt.x86_msm.msm', + )[0], + download_entry( + 'vc9-crt-x86-msm-policy', + build_dir, + local_name='policy.x.xx.microsoft.vcxx.crt.x86_msm.msm', + )[0], ) x64 = ( - download_entry('vc9-crt-x64-msm', build_dir, - local_name='microsoft.vcxx.crt.x64_msm.msm')[0], - download_entry('vc9-crt-x64-msm-policy', build_dir, - local_name='policy.x.xx.microsoft.vcxx.crt.x64_msm.msm')[0] + download_entry( + 'vc9-crt-x64-msm', + build_dir, + local_name='microsoft.vcxx.crt.x64_msm.msm', + )[0], + download_entry( + 'vc9-crt-x64-msm-policy', + build_dir, + local_name='policy.x.xx.microsoft.vcxx.crt.x64_msm.msm', + )[0], ) return { 'x86': x86, @@ -116,17 +124,26 @@ subprocess.run(args, cwd=str(cwd), check=True) -def make_post_build_signing_fn(name, subject_name=None, cert_path=None, - cert_password=None, timestamp_url=None): +def make_post_build_signing_fn( + name, + subject_name=None, + cert_path=None, + cert_password=None, + timestamp_url=None, +): """Create a callable that will use signtool to sign hg.exe.""" def post_build_sign(source_dir, build_dir, dist_dir, version): description = '%s %s' % (name, version) - sign_with_signtool(dist_dir / 'hg.exe', description, - subject_name=subject_name, cert_path=cert_path, - cert_password=cert_password, - timestamp_url=timestamp_url) + sign_with_signtool( + dist_dir / 'hg.exe', + description, + subject_name=subject_name, + cert_path=cert_path, + cert_password=cert_password, + timestamp_url=timestamp_url, + ) return post_build_sign @@ -155,7 +172,8 @@ # We can't use ElementTree because it doesn't handle the # <?include ?> directives. doc = xml.dom.minidom.parseString( - LIBRARIES_XML.format(wix_dir=str(wix_dir))) + LIBRARIES_XML.format(wix_dir=str(wix_dir)) + ) component = doc.getElementsByTagName('Component')[0] @@ -177,11 +195,16 @@ return doc.toprettyxml() -def build_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, - msi_name='mercurial', version=None, post_build_fn=None, - extra_packages_script=None, - extra_wxs:typing.Optional[typing.Dict[str,str]]=None, - extra_features:typing.Optional[typing.List[str]]=None): +def build_installer( + source_dir: pathlib.Path, + python_exe: pathlib.Path, + msi_name='mercurial', + version=None, + post_build_fn=None, + extra_packages_script=None, + extra_wxs: typing.Optional[typing.Dict[str, str]] = None, + extra_features: typing.Optional[typing.List[str]] = None, +): """Build a WiX MSI installer. ``source_dir`` is the path to the Mercurial source tree to use. @@ -209,10 +232,15 @@ requirements_txt = wix_dir / 'requirements.txt' - build_py2exe(source_dir, hg_build_dir, - python_exe, 'wix', requirements_txt, - extra_packages=EXTRA_PACKAGES, - extra_packages_script=extra_packages_script) + build_py2exe( + source_dir, + hg_build_dir, + python_exe, + 'wix', + requirements_txt, + extra_packages=EXTRA_PACKAGES, + extra_packages_script=extra_packages_script, + ) version = version or normalize_version(find_version(source_dir)) print('using version string: %s' % version) @@ -265,16 +293,19 @@ run_candle(wix_path, build_dir, source, source_build_rel, defines=defines) - msi_path = source_dir / 'dist' / ( - '%s-%s-%s.msi' % (msi_name, version, arch)) + msi_path = ( + source_dir / 'dist' / ('%s-%s-%s.msi' % (msi_name, version, arch)) + ) args = [ str(wix_path / 'light.exe'), '-nologo', - '-ext', 'WixUIExtension', + '-ext', + 'WixUIExtension', '-sw1076', '-spdb', - '-o', str(msi_path), + '-o', + str(msi_path), ] for source, rel_path in SUPPORT_WXS: @@ -286,10 +317,12 @@ source = os.path.basename(source) args.append(str(build_dir / ('%s.wixobj' % source[:-4]))) - args.extend([ - str(build_dir / 'library.wixobj'), - str(build_dir / 'mercurial.wixobj'), - ]) + args.extend( + [ + str(build_dir / 'library.wixobj'), + str(build_dir / 'mercurial.wixobj'), + ] + ) subprocess.run(args, cwd=str(source_dir), check=True) @@ -300,11 +333,19 @@ } -def build_signed_installer(source_dir: pathlib.Path, python_exe: pathlib.Path, - name: str, version=None, subject_name=None, - cert_path=None, cert_password=None, - timestamp_url=None, extra_packages_script=None, - extra_wxs=None, extra_features=None): +def build_signed_installer( + source_dir: pathlib.Path, + python_exe: pathlib.Path, + name: str, + version=None, + subject_name=None, + cert_path=None, + cert_password=None, + timestamp_url=None, + extra_packages_script=None, + extra_wxs=None, + extra_features=None, +): """Build an installer with signed executables.""" post_build_fn = make_post_build_signing_fn( @@ -312,16 +353,27 @@ subject_name=subject_name, cert_path=cert_path, cert_password=cert_password, - timestamp_url=timestamp_url) + timestamp_url=timestamp_url, + ) - info = build_installer(source_dir, python_exe=python_exe, - msi_name=name.lower(), version=version, - post_build_fn=post_build_fn, - extra_packages_script=extra_packages_script, - extra_wxs=extra_wxs, extra_features=extra_features) + info = build_installer( + source_dir, + python_exe=python_exe, + msi_name=name.lower(), + version=version, + post_build_fn=post_build_fn, + extra_packages_script=extra_packages_script, + extra_wxs=extra_wxs, + extra_features=extra_features, + ) description = '%s %s' % (name, version) - sign_with_signtool(info['msi_path'], description, - subject_name=subject_name, cert_path=cert_path, - cert_password=cert_password, timestamp_url=timestamp_url) + sign_with_signtool( + info['msi_path'], + description, + subject_name=subject_name, + cert_path=cert_path, + cert_password=cert_password, + timestamp_url=timestamp_url, + )