##// END OF EJS Templates
subsetmaker: stabilize the computation of `scratch` subset...
subsetmaker: stabilize the computation of `scratch` subset `heads` is set, order of the element are not deterministic and we need to stabilize that if we want to get reproducible results. Differential Revision: https://phab.mercurial-scm.org/D12394

File last commit:

r49703:17d5e25b default
r49877:18622379 default
Show More
wix.py
96 lines | 2.6 KiB | text/x-python | PythonLexer
Gregory Szorc
packaging: convert files to LF...
r42118 # wix.py - WiX installer functionality
#
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
# no-check-code because Python 3 native.
Augie Fackler
packaging: add command line flag to add extra vars to pyoxidizer...
r48444 import json
Gregory Szorc
packaging: convert files to LF...
r42118 import os
import pathlib
Gregory Szorc
packaging: stage files and dynamically generate WiX installer...
r44022 import shutil
Augie Fackler
wix: add support for additional wxs files...
r42215 import typing
Gregory Szorc
packaging: convert files to LF...
r42118
Gregory Szorc
packaging: use PyOxidizer for producing WiX MSI installer...
r47981 from .pyoxidizer import (
build_docs_html,
run_pyoxidizer,
)
Gregory Szorc
packaging: support building WiX installers with PyOxidizer...
r45274
def build_installer_pyoxidizer(
source_dir: pathlib.Path,
target_triple: str,
msi_name='mercurial',
version=None,
extra_wxs: typing.Optional[typing.Dict[str, str]] = None,
extra_features: typing.Optional[typing.List[str]] = None,
signing_info: typing.Optional[typing.Dict[str, str]] = None,
Augie Fackler
packaging: add command line flag to add extra vars to pyoxidizer...
r48444 extra_pyoxidizer_vars=None,
Gregory Szorc
packaging: support building WiX installers with PyOxidizer...
r45274 ):
"""Build a WiX MSI installer using PyOxidizer."""
hg_build_dir = source_dir / "build"
build_dir = hg_build_dir / ("wix-%s" % target_triple)
build_dir.mkdir(parents=True, exist_ok=True)
Gregory Szorc
packaging: use PyOxidizer for producing WiX MSI installer...
r47981
# Need to ensure docs HTML is built because this isn't done as part of
# `pip install Mercurial`.
build_docs_html(source_dir)
build_vars = {}
if msi_name:
build_vars["MSI_NAME"] = msi_name
if version:
build_vars["VERSION"] = version
if extra_features:
build_vars["EXTRA_MSI_FEATURES"] = ";".join(extra_features)
if signing_info:
if signing_info["cert_path"]:
build_vars["SIGNING_PFX_PATH"] = signing_info["cert_path"]
if signing_info["cert_password"]:
build_vars["SIGNING_PFX_PASSWORD"] = signing_info["cert_password"]
if signing_info["subject_name"]:
build_vars["SIGNING_SUBJECT_NAME"] = signing_info["subject_name"]
if signing_info["timestamp_url"]:
build_vars["TIME_STAMP_SERVER_URL"] = signing_info["timestamp_url"]
Augie Fackler
packaging: add command line flag to add extra vars to pyoxidizer...
r48444 if extra_pyoxidizer_vars:
build_vars.update(json.loads(extra_pyoxidizer_vars))
Gregory Szorc
packaging: use PyOxidizer for producing WiX MSI installer...
r47981 if extra_wxs:
raise Exception(
"support for extra .wxs files has been temporarily dropped"
)
out_dir = run_pyoxidizer(
source_dir,
build_dir,
target_triple,
build_vars=build_vars,
target="msi",
Gregory Szorc
packaging: rename run_pyoxidizer()...
r47979 )
Gregory Szorc
packaging: support building WiX installers with PyOxidizer...
r45274
Gregory Szorc
packaging: use PyOxidizer for producing WiX MSI installer...
r47981 msi_dir = out_dir / "msi"
msi_files = [f for f in os.listdir(msi_dir) if f.endswith(".msi")]
Gregory Szorc
packaging: support building WiX installers with PyOxidizer...
r45274
Gregory Szorc
packaging: use PyOxidizer for producing WiX MSI installer...
r47981 if len(msi_files) != 1:
raise Exception("expected exactly 1 .msi file; got %d" % len(msi_files))
msi_filename = msi_files[0]
Gregory Szorc
packaging: support building WiX installers with PyOxidizer...
r45274
Gregory Szorc
packaging: use PyOxidizer for producing WiX MSI installer...
r47981 msi_path = msi_dir / msi_filename
dist_path = source_dir / "dist" / msi_filename
dist_path.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(msi_path, dist_path)
return {
"msi_path": dist_path,
}