Mercurial > hg
annotate contrib/packaging/inno/build.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 | 57645939df59 |
children |
rev | line source |
---|---|
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # build.py - Inno installer build script. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 # GNU General Public License version 2 or any later version. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 # This script automates the building of the Inno MSI installer for Mercurial. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 # no-check-code because Python 3 native. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 import argparse |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 import os |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 import pathlib |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 import sys |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 if __name__ == '__main__': |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 parser = argparse.ArgumentParser() |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
22 parser.add_argument( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
23 '--python', required=True, help='path to python.exe to use' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
24 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
25 parser.add_argument('--iscc', help='path to iscc.exe to use') |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
26 parser.add_argument( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
27 '--version', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
28 help='Mercurial version string to use ' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
29 '(detected from __version__.py if not defined', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
30 ) |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
31 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
32 args = parser.parse_args() |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
33 |
42091
57645939df59
packaging: ensure that --python is an absolute path when building on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
41911
diff
changeset
|
34 if not os.path.isabs(args.python): |
57645939df59
packaging: ensure that --python is an absolute path when building on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
41911
diff
changeset
|
35 raise Exception('--python arg must be an absolute path') |
57645939df59
packaging: ensure that --python is an absolute path when building on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
41911
diff
changeset
|
36 |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
37 if args.iscc: |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
38 iscc = pathlib.Path(args.iscc) |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
39 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
40 iscc = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
41 pathlib.Path(os.environ['ProgramFiles(x86)']) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
42 / 'Inno Setup 5' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
43 / 'ISCC.exe' |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
44 ) |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
45 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
46 here = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
47 source_dir = here.parent.parent.parent |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
48 build_dir = source_dir / 'build' |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
49 |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
50 sys.path.insert(0, str(source_dir / 'contrib' / 'packaging')) |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
51 |
41911
dc7827a9ba64
packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41910
diff
changeset
|
52 from hgpackaging.inno import build |
dc7827a9ba64
packaging: move Inno Setup core logic into a module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41910
diff
changeset
|
53 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
54 build( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
55 source_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
56 build_dir, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
57 pathlib.Path(args.python), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
58 iscc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
59 version=args.version, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42091
diff
changeset
|
60 ) |