contrib/packaging/hgpackaging/cli.py
author Kyle Lippincott <spectral@google.com>
Tue, 30 Mar 2021 13:05:22 -0700
changeset 46871 887f89b100ac
parent 45942 89a2afe31e82
child 47644 be37bb8d0c7c
permissions -rw-r--r--
exthelper: improve docs to indicate what module vars are needed I recently tried creating an extension "from scratch" using exthelper, and it wasn't obvious that you needed these. I believe that a careful reading of one of the comments would tell you that they were required, but it's easy to miss and having the examples be "complete" is helpful. Differential Revision: https://phab.mercurial-scm.org/D10295
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
# cli.py - Command line interface for automation
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
#
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
#
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
# no-check-code because Python 3 native.
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
import argparse
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
import os
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
import pathlib
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
from . import (
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
    inno,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
    wix,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
)
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
HERE = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
SOURCE_DIR = HERE.parent.parent.parent
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    21
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    23
def build_inno(pyoxidizer_target=None, python=None, iscc=None, version=None):
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    24
    if not pyoxidizer_target and not python:
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    25
        raise Exception("--python required unless building with PyOxidizer")
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    26
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    27
    if python and not os.path.isabs(python):
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
        raise Exception("--python arg must be an absolute path")
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    30
    if iscc:
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    31
        iscc = pathlib.Path(iscc)
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
    else:
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
        iscc = (
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
            pathlib.Path(os.environ["ProgramFiles(x86)"])
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
            / "Inno Setup 5"
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
            / "ISCC.exe"
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
        )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
    build_dir = SOURCE_DIR / "build"
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    41
    if pyoxidizer_target:
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    42
        inno.build_with_pyoxidizer(
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    43
            SOURCE_DIR, build_dir, pyoxidizer_target, iscc, version=version
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    44
        )
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    45
    else:
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    46
        inno.build_with_py2exe(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 44767
diff changeset
    47
            SOURCE_DIR,
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 44767
diff changeset
    48
            build_dir,
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 44767
diff changeset
    49
            pathlib.Path(python),
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 44767
diff changeset
    50
            iscc,
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 44767
diff changeset
    51
            version=version,
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
    52
        )
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    53
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
def build_wix(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    56
    name=None,
44767
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    57
    pyoxidizer_target=None,
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    58
    python=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    59
    version=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    60
    sign_sn=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
    sign_cert=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
    sign_password=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    63
    sign_timestamp_url=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    64
    extra_packages_script=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    65
    extra_wxs=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    66
    extra_features=None,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    67
):
44767
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    68
    if not pyoxidizer_target and not python:
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    69
        raise Exception("--python required unless building with PyOxidizer")
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    70
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    71
    if python and not os.path.isabs(python):
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    72
        raise Exception("--python arg must be an absolute path")
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    73
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
    kwargs = {
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
        "source_dir": SOURCE_DIR,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
        "version": version,
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    77
    }
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
44767
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    79
    if pyoxidizer_target:
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    80
        fn = wix.build_installer_pyoxidizer
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    81
        kwargs["target_triple"] = pyoxidizer_target
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    82
    else:
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    83
        fn = wix.build_installer_py2exe
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    84
        kwargs["python_exe"] = pathlib.Path(python)
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
    if extra_packages_script:
44767
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    87
        if pyoxidizer_target:
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    88
            raise Exception(
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    89
                "pyoxidizer does not support --extra-packages-script"
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
    90
            )
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
        kwargs["extra_packages_script"] = extra_packages_script
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
    if extra_wxs:
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
        kwargs["extra_wxs"] = dict(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    94
            thing.split("=") for thing in extra_wxs.split(",")
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    95
        )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    96
    if extra_features:
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    97
        kwargs["extra_features"] = extra_features.split(",")
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    98
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    99
    if sign_sn or sign_cert:
44765
a39984091380 packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44763
diff changeset
   100
        kwargs["signing_info"] = {
a39984091380 packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44763
diff changeset
   101
            "name": name,
a39984091380 packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44763
diff changeset
   102
            "subject_name": sign_sn,
a39984091380 packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44763
diff changeset
   103
            "cert_path": sign_cert,
a39984091380 packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44763
diff changeset
   104
            "cert_password": sign_password,
a39984091380 packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44763
diff changeset
   105
            "timestamp_url": sign_timestamp_url,
a39984091380 packaging: integrate signing into run_wix_packaging()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44763
diff changeset
   106
        }
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   107
44767
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
   108
    fn(**kwargs)
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   109
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   110
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   111
def get_parser():
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
    parser = argparse.ArgumentParser()
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   113
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   114
    subparsers = parser.add_subparsers()
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   115
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   116
    sp = subparsers.add_parser("inno", help="Build Inno Setup installer")
44763
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
   117
    sp.add_argument(
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
   118
        "--pyoxidizer-target",
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
   119
        choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"},
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
   120
        help="Build with PyOxidizer targeting this host triple",
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
   121
    )
94f4f2ec7dee packaging: support building Inno installer with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43513
diff changeset
   122
    sp.add_argument("--python", help="path to python.exe to use")
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   123
    sp.add_argument("--iscc", help="path to iscc.exe to use")
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   124
    sp.add_argument(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   125
        "--version",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   126
        help="Mercurial version string to use "
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   127
        "(detected from __version__.py if not defined",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   128
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   129
    sp.set_defaults(func=build_inno)
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   130
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   131
    sp = subparsers.add_parser(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   132
        "wix", help="Build Windows installer with WiX Toolset"
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   133
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   134
    sp.add_argument("--name", help="Application name", default="Mercurial")
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   135
    sp.add_argument(
44767
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
   136
        "--pyoxidizer-target",
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
   137
        choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"},
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
   138
        help="Build with PyOxidizer targeting this host triple",
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   139
    )
44767
234882d17814 packaging: support building WiX installers with PyOxidizer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44765
diff changeset
   140
    sp.add_argument("--python", help="Path to Python executable to use")
43513
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   141
    sp.add_argument(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   142
        "--sign-sn",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   143
        help="Subject name (or fragment thereof) of certificate "
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   144
        "to use for signing",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   145
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   146
    sp.add_argument(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   147
        "--sign-cert", help="Path to certificate to use for signing"
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   148
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   149
    sp.add_argument("--sign-password", help="Password for signing certificate")
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   150
    sp.add_argument(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   151
        "--sign-timestamp-url",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   152
        help="URL of timestamp server to use for signing",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   153
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   154
    sp.add_argument("--version", help="Version string to use")
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   155
    sp.add_argument(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   156
        "--extra-packages-script",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   157
        help=(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   158
            "Script to execute to include extra packages in " "py2exe binary."
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   159
        ),
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   160
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   161
    sp.add_argument(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   162
        "--extra-wxs", help="CSV of path_to_wxs_file=working_dir_for_wxs_file"
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   163
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   164
    sp.add_argument(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   165
        "--extra-features",
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   166
        help=(
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   167
            "CSV of extra feature names to include "
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   168
            "in the installer from the extra wxs files"
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   169
        ),
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   170
    )
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   171
    sp.set_defaults(func=build_wix)
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   172
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   173
    return parser
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   174
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   175
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   176
def main():
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   177
    parser = get_parser()
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   178
    args = parser.parse_args()
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   179
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   180
    if not hasattr(args, "func"):
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   181
        parser.print_help()
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   182
        return
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   183
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   184
    kwargs = dict(vars(args))
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   185
    del kwargs["func"]
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   186
081a77df7bc6 packaging: consolidate CLI functionality into packaging.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   187
    args.func(**kwargs)