rust/hgcli/pyoxidizer.bzl
author Gregory Szorc <gregory.szorc@gmail.com>
Thu, 06 May 2021 09:27:22 -0700
changeset 47222 159d2de3286c
parent 47217 c8001d9c26f5
child 47643 11f834e7177d
permissions -rw-r--r--
pyoxidizer: use Python 3.9 (BC) Newer versions of PyOxidizer use Python 3.9 by default. We previously pinned the version to 3.8 to facilitate porting to a new PyOxidizer version and diffing results. Now that the porting work is complete, let's bump Python to Python 3.9. This will effectively change our Windows Inno and WiX Python 3 installers from Python 3.8 to 3.9. .. bc:: Windows .msi and .exe installers now use Python 3.9 instead of Python 3.8. Differential Revision: https://phab.mercurial-scm.org/D10689
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47216
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     1
# The following variables can be passed in as parameters:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     2
#
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     3
# VERSION
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     4
#   Version string of program being produced.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     5
#
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     6
# MSI_NAME
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     7
#   Root name of MSI installer.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     8
#
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
     9
# EXTRA_MSI_FEATURES
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
    10
#   ; delimited string of extra features to advertise in the built MSA.
47217
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    11
#
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    12
# SIGNING_PFX_PATH
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    13
#   Path to code signing certificate to use.
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    14
#
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    15
# SIGNING_PFX_PASSWORD
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    16
#   Password to code signing PFX file defined by SIGNING_PFX_PATH.
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    17
#
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    18
# SIGNING_SUBJECT_NAME
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    19
#   String fragment in code signing certificate subject name used to find
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    20
#   code signing certificate in Windows certificate store.
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    21
#
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    22
# TIME_STAMP_SERVER_URL
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    23
#   URL of time-stamp token authority (RFC 3161) servers to stamp code signatures.
47216
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
    24
44643
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44642
diff changeset
    25
ROOT = CWD + "/../.."
44642
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
47216
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
    27
VERSION = VARS.get("VERSION", "5.8")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
    28
MSI_NAME = VARS.get("MSI_NAME", "mercurial")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
    29
EXTRA_MSI_FEATURES = VARS.get("EXTRA_MSI_FEATURES")
47217
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    30
SIGNING_PFX_PATH = VARS.get("SIGNING_PFX_PATH")
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    31
SIGNING_PFX_PASSWORD = VARS.get("SIGNING_PFX_PASSWORD", "")
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    32
SIGNING_SUBJECT_NAME = VARS.get("SIGNING_SUBJECT_NAME")
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
    33
TIME_STAMP_SERVER_URL = VARS.get("TIME_STAMP_SERVER_URL", "http://timestamp.digicert.com")
47216
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
    34
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    35
IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    36
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    37
# Code to run in Python interpreter.
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    38
RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    39
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    40
set_build_path(ROOT + "/build/pyoxidizer")
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    41
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    42
def make_distribution():
47222
159d2de3286c pyoxidizer: use Python 3.9 (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47217
diff changeset
    43
    return default_python_distribution(python_version = "3.9")
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    44
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    45
def resource_callback(policy, resource):
45850
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
    46
    if not IS_WINDOWS:
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
    47
        resource.add_location = "in-memory"
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
    48
        return
45894
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45851
diff changeset
    49
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    50
    # We use a custom resource routing policy to influence where things are loaded
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    51
    # from.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    52
    #
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    53
    # For Python modules and resources, we load from memory if they are in
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    54
    # the standard library and from the filesystem if not. This is because
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    55
    # parts of Mercurial and some 3rd party packages aren't yet compatible
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    56
    # with memory loading.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    57
    #
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    58
    # For Python extension modules, we load from the filesystem because
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    59
    # this yields greatest compatibility.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    60
    if type(resource) in ("PythonModuleSource", "PythonPackageResource", "PythonPackageDistributionResource"):
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    61
        if resource.is_stdlib:
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    62
            resource.add_location = "in-memory"
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    63
        else:
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    64
            resource.add_location = "filesystem-relative:lib"
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    65
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    66
    elif type(resource) == "PythonExtensionModule":
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    67
        resource.add_location = "filesystem-relative:lib"
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    68
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    69
def make_exe(dist):
44888
118f067f6bd1 pyoxidizer: formatting bazel definitions
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents: 44748
diff changeset
    70
    """Builds a Rust-wrapped Mercurial binary."""
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    71
    packaging_policy = dist.make_python_packaging_policy()
45894
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45851
diff changeset
    72
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    73
    # Extension may depend on any Python functionality. Include all
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    74
    # extensions.
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    75
    packaging_policy.extension_module_filter = "all"
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
    76
    packaging_policy.resources_location = "in-memory"
45850
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
    77
    if IS_WINDOWS:
f14c33b2e497 pyoxidizer: default to one-file binary on non-Windows platforms
Augie Fackler <augie@google.com>
parents: 45752
diff changeset
    78
        packaging_policy.resources_location_fallback = "filesystem-relative:lib"
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    79
    packaging_policy.register_resource_callback(resource_callback)
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    80
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
    81
    config = dist.make_python_interpreter_config()
47215
3380848c6e04 pyoxidizer: use allocator_backend instead of raw_allocator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47214
diff changeset
    82
    config.allocator_backend = "default"
45851
867385f45559 pyoxidizer: switch to modern config using run_command instead of run_mode
Augie Fackler <augie@google.com>
parents: 45850
diff changeset
    83
    config.run_command = RUN_CODE
45894
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45851
diff changeset
    84
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
    85
    # We want to let the user load extensions from the file system
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
    86
    config.filesystem_importer = True
45894
5d73d3053d92 pyoxidizer: run buildifier
Augie Fackler <augie@google.com>
parents: 45851
diff changeset
    87
45749
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
    88
    # We need this to make resourceutil happy, since it looks for sys.frozen.
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
    89
    config.sys_frozen = True
f95b16796688 pyoxidizer: update to PyOxidizer 0.9
Gregory Szorc <gregory.szorc@gmail.com>
parents: 45685
diff changeset
    90
    config.legacy_windows_stdio = True
44642
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
    exe = dist.to_python_executable(
44643
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44642
diff changeset
    93
        name = "hg",
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    94
        packaging_policy = packaging_policy,
44643
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44642
diff changeset
    95
        config = config,
44642
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    96
    )
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    97
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
    98
    # Add Mercurial to resources.
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
    99
    exe.add_python_resources(exe.pip_install(["--verbose", ROOT]))
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
   100
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
   101
    # On Windows, we install extra packages for convenience.
45685
57b5452a55d5 pyoxidizer: produce working Python 3 Windows installers (issue6366)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44888
diff changeset
   102
    if IS_WINDOWS:
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
   103
        exe.add_python_resources(
45775
cd7f36337741 pyoxidizer: point to the py3 requirements instead of py2 on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 45752
diff changeset
   104
            exe.pip_install(["-r", ROOT + "/contrib/packaging/requirements-windows-py3.txt"]),
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
   105
        )
44642
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   106
44643
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44642
diff changeset
   107
    return exe
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44642
diff changeset
   108
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
   109
def make_manifest(dist, exe):
44643
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44642
diff changeset
   110
    m = FileManifest()
bc847878f4c0 hgcli: customize for Mercurial
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44642
diff changeset
   111
    m.add_python_resource(".", exe)
44642
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
   113
    return m
44642
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   114
47216
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   115
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   116
# This adjusts the InstallManifest produced from exe generation to provide
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   117
# additional files found in a Windows install layout.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   118
def make_windows_install_layout(manifest):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   119
    # Copy various files to new install locations. This can go away once
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   120
    # we're using the importlib resource reader.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   121
    RECURSIVE_COPIES = {
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   122
        "lib/mercurial/locale/": "locale/",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   123
        "lib/mercurial/templates/": "templates/",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   124
    }
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   125
    for (search, replace) in RECURSIVE_COPIES.items():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   126
        for path in manifest.paths():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   127
            if path.startswith(search):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   128
                new_path = path.replace(search, replace)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   129
                print("copy %s to %s" % (path, new_path))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   130
                file = manifest.get_file(path)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   131
                manifest.add_file(file, path = new_path)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   132
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   133
    # Similar to above, but with filename pattern matching.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   134
    # lib/mercurial/helptext/**/*.txt -> helptext/
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   135
    # lib/mercurial/defaultrc/*.rc -> defaultrc/
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   136
    for path in manifest.paths():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   137
        if path.startswith("lib/mercurial/helptext/") and path.endswith(".txt"):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   138
            new_path = path[len("lib/mercurial/"):]
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   139
        elif path.startswith("lib/mercurial/defaultrc/") and path.endswith(".rc"):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   140
            new_path = path[len("lib/mercurial/"):]
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   141
        else:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   142
            continue
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   143
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   144
        print("copying %s to %s" % (path, new_path))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   145
        manifest.add_file(manifest.get_file(path), path = new_path)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   146
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   147
    # We also install a handful of additional files.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   148
    EXTRA_CONTRIB_FILES = [
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   149
        "bash_completion",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   150
        "hgweb.fcgi",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   151
        "hgweb.wsgi",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   152
        "logo-droplets.svg",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   153
        "mercurial.el",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   154
        "mq.el",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   155
        "tcsh_completion",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   156
        "tcsh_completion_build.sh",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   157
        "xml.rnc",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   158
        "zsh_completion",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   159
    ]
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   160
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   161
    for f in EXTRA_CONTRIB_FILES:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   162
        manifest.add_file(FileContent(path = ROOT + "/contrib/" + f), directory = "contrib")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   163
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   164
    # Individual files with full source to destination path mapping.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   165
    EXTRA_FILES = {
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   166
        "contrib/hgk": "contrib/hgk.tcl",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   167
        "contrib/win32/postinstall.txt": "ReleaseNotes.txt",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   168
        "contrib/win32/ReadMe.html": "ReadMe.html",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   169
        "doc/style.css": "doc/style.css",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   170
        "COPYING": "Copying.txt",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   171
    }
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   172
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   173
    for source, dest in EXTRA_FILES.items():
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   174
        print("adding extra file %s" % dest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   175
        manifest.add_file(FileContent(path = ROOT + "/" + source), path = dest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   176
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   177
    # And finally some wildcard matches.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   178
    manifest.add_manifest(glob(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   179
        include = [ROOT + "/contrib/vim/*"],
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   180
        strip_prefix = ROOT + "/"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   181
    ))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   182
    manifest.add_manifest(glob(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   183
        include = [ROOT + "/doc/*.html"],
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   184
        strip_prefix = ROOT + "/"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   185
    ))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   186
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   187
    # But we don't ship hg-ssh on Windows, so exclude its documentation.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   188
    manifest.remove("doc/hg-ssh.8.html")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   189
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   190
    return manifest
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   191
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   192
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   193
def make_msi(manifest):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   194
    manifest = make_windows_install_layout(manifest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   195
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   196
    if "x86_64" in BUILD_TARGET_TRIPLE:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   197
        platform = "x64"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   198
    else:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   199
        platform = "x86"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   200
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   201
    manifest.add_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   202
        FileContent(path = ROOT + "/contrib/packaging/wix/COPYING.rtf"),
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   203
        path = "COPYING.rtf",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   204
    )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   205
    manifest.remove("Copying.txt")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   206
    manifest.add_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   207
        FileContent(path = ROOT + "/contrib/win32/mercurial.ini"),
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   208
        path = "defaultrc/mercurial.rc",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   209
    )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   210
    manifest.add_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   211
        FileContent(filename = "editor.rc", content = "[ui]\neditor = notepad\n"),
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   212
        path = "defaultrc/editor.rc",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   213
    )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   214
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   215
    wix = WiXInstaller("hg", "%s-%s.msi" % (MSI_NAME, VERSION))
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   216
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   217
    # Materialize files in the manifest to the install layout.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   218
    wix.add_install_files(manifest)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   219
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   220
    # From mercurial.wxs.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   221
    wix.install_files_root_directory_id = "INSTALLDIR"
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   222
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   223
    # Pull in our custom .wxs files.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   224
    defines = {
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   225
        "PyOxidizer": "1",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   226
        "Platform": platform,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   227
        "Version": VERSION,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   228
        "Comments": "Installs Mercurial version %s" % VERSION,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   229
        "PythonVersion": "3",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   230
        "MercurialHasLib": "1",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   231
    }
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   232
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   233
    if EXTRA_MSI_FEATURES:
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   234
        defines["MercurialExtraFeatures"] = EXTRA_MSI_FEATURES
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   235
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   236
    wix.add_wxs_file(
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   237
        ROOT + "/contrib/packaging/wix/mercurial.wxs",
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   238
        preprocessor_parameters=defines,
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   239
    )
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   240
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   241
    # Our .wxs references to other files. Pull those into the build environment.
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   242
    for f in ("defines.wxi", "guids.wxi", "COPYING.rtf"):
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   243
        wix.add_build_file(f, ROOT + "/contrib/packaging/wix/" + f)
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   244
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   245
    wix.add_build_file("mercurial.ico", ROOT + "/contrib/win32/mercurial.ico")
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   246
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   247
    return wix
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   248
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   249
47217
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   250
def register_code_signers():
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   251
    if not IS_WINDOWS:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   252
        return
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   253
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   254
    if SIGNING_PFX_PATH:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   255
        signer = code_signer_from_pfx_file(SIGNING_PFX_PATH, SIGNING_PFX_PASSWORD)
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   256
    elif SIGNING_SUBJECT_NAME:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   257
        signer = code_signer_from_windows_store_subject(SIGNING_SUBJECT_NAME)
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   258
    else:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   259
        signer = None
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   260
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   261
    if signer:
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   262
        signer.set_time_stamp_server(TIME_STAMP_SERVER_URL)
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   263
        signer.activate()
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   264
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   265
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   266
register_code_signers()
c8001d9c26f5 pyoxidizer: support code signing
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47216
diff changeset
   267
47214
9438e9b7321a pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47212
diff changeset
   268
register_target("distribution", make_distribution)
9438e9b7321a pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47212
diff changeset
   269
register_target("exe", make_exe, depends = ["distribution"])
9438e9b7321a pyoxidizer: simplify targets
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47212
diff changeset
   270
register_target("app", make_manifest, depends = ["distribution", "exe"], default = True)
47216
603efb3845ba pyoxidizer: support producing MSI installers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 47215
diff changeset
   271
register_target("msi", make_msi, depends = ["app"])
44748
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44643
diff changeset
   272
44642
af739894a4c1 hgcli: add stub PyOxidizer project
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   273
resolve_targets()