Mercurial > hg
comparison contrib/packaging/hgpackaging/cli.py @ 48848:17d5e25b8e78
packaging: remove py2exe / Python 2.7 support
This commit started by deleting references to py2exe (which is only used
on Python 2). After pulling the thread, quite a lot of code was orphaned
and was deleted.
Differential Revision: https://phab.mercurial-scm.org/D12265
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 19 Feb 2022 22:13:11 -0700 |
parents | 39ab4c2f38b4 |
children | f40fb4c52594 |
comparison
equal
deleted
inserted
replaced
48847:4561ec90d3c1 | 48848:17d5e25b8e78 |
---|---|
18 | 18 |
19 HERE = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) | 19 HERE = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) |
20 SOURCE_DIR = HERE.parent.parent.parent | 20 SOURCE_DIR = HERE.parent.parent.parent |
21 | 21 |
22 | 22 |
23 def build_inno(pyoxidizer_target=None, python=None, iscc=None, version=None): | 23 def build_inno(pyoxidizer_target, iscc=None, version=None): |
24 if not pyoxidizer_target and not python: | |
25 raise Exception("--python required unless building with PyOxidizer") | |
26 | |
27 if python and not os.path.isabs(python): | |
28 raise Exception("--python arg must be an absolute path") | |
29 | |
30 if iscc: | 24 if iscc: |
31 iscc = pathlib.Path(iscc) | 25 iscc = pathlib.Path(iscc) |
32 else: | 26 else: |
33 iscc = ( | 27 iscc = ( |
34 pathlib.Path(os.environ["ProgramFiles(x86)"]) | 28 pathlib.Path(os.environ["ProgramFiles(x86)"]) |
36 / "ISCC.exe" | 30 / "ISCC.exe" |
37 ) | 31 ) |
38 | 32 |
39 build_dir = SOURCE_DIR / "build" | 33 build_dir = SOURCE_DIR / "build" |
40 | 34 |
41 if pyoxidizer_target: | 35 inno.build_with_pyoxidizer( |
42 inno.build_with_pyoxidizer( | 36 SOURCE_DIR, build_dir, pyoxidizer_target, iscc, version=version |
43 SOURCE_DIR, build_dir, pyoxidizer_target, iscc, version=version | 37 ) |
44 ) | |
45 else: | |
46 inno.build_with_py2exe( | |
47 SOURCE_DIR, | |
48 build_dir, | |
49 pathlib.Path(python), | |
50 iscc, | |
51 version=version, | |
52 ) | |
53 | 38 |
54 | 39 |
55 def build_wix( | 40 def build_wix( |
41 pyoxidizer_target, | |
56 name=None, | 42 name=None, |
57 pyoxidizer_target=None, | |
58 python=None, | |
59 version=None, | 43 version=None, |
60 sign_sn=None, | 44 sign_sn=None, |
61 sign_cert=None, | 45 sign_cert=None, |
62 sign_password=None, | 46 sign_password=None, |
63 sign_timestamp_url=None, | 47 sign_timestamp_url=None, |
64 extra_packages_script=None, | |
65 extra_wxs=None, | 48 extra_wxs=None, |
66 extra_features=None, | 49 extra_features=None, |
67 extra_pyoxidizer_vars=None, | 50 extra_pyoxidizer_vars=None, |
68 ): | 51 ): |
69 if not pyoxidizer_target and not python: | |
70 raise Exception("--python required unless building with PyOxidizer") | |
71 | |
72 if python and not os.path.isabs(python): | |
73 raise Exception("--python arg must be an absolute path") | |
74 | |
75 kwargs = { | 52 kwargs = { |
76 "source_dir": SOURCE_DIR, | 53 "source_dir": SOURCE_DIR, |
77 "version": version, | 54 "version": version, |
55 "target_triple": pyoxidizer_target, | |
56 "extra_pyoxidizer_vars": extra_pyoxidizer_vars, | |
78 } | 57 } |
79 | 58 |
80 if pyoxidizer_target: | |
81 fn = wix.build_installer_pyoxidizer | |
82 kwargs["target_triple"] = pyoxidizer_target | |
83 kwargs["extra_pyoxidizer_vars"] = extra_pyoxidizer_vars | |
84 else: | |
85 fn = wix.build_installer_py2exe | |
86 kwargs["python_exe"] = pathlib.Path(python) | |
87 | |
88 if extra_packages_script: | |
89 if pyoxidizer_target: | |
90 raise Exception( | |
91 "pyoxidizer does not support --extra-packages-script" | |
92 ) | |
93 kwargs["extra_packages_script"] = extra_packages_script | |
94 if extra_wxs: | 59 if extra_wxs: |
95 kwargs["extra_wxs"] = dict( | 60 kwargs["extra_wxs"] = dict( |
96 thing.split("=") for thing in extra_wxs.split(",") | 61 thing.split("=") for thing in extra_wxs.split(",") |
97 ) | 62 ) |
98 if extra_features: | 63 if extra_features: |
105 "cert_path": sign_cert, | 70 "cert_path": sign_cert, |
106 "cert_password": sign_password, | 71 "cert_password": sign_password, |
107 "timestamp_url": sign_timestamp_url, | 72 "timestamp_url": sign_timestamp_url, |
108 } | 73 } |
109 | 74 |
110 fn(**kwargs) | 75 wix.build_installer_pyoxidizer(**kwargs) |
111 | 76 |
112 | 77 |
113 def get_parser(): | 78 def get_parser(): |
114 parser = argparse.ArgumentParser() | 79 parser = argparse.ArgumentParser() |
115 | 80 |
117 | 82 |
118 sp = subparsers.add_parser("inno", help="Build Inno Setup installer") | 83 sp = subparsers.add_parser("inno", help="Build Inno Setup installer") |
119 sp.add_argument( | 84 sp.add_argument( |
120 "--pyoxidizer-target", | 85 "--pyoxidizer-target", |
121 choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"}, | 86 choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"}, |
87 required=True, | |
122 help="Build with PyOxidizer targeting this host triple", | 88 help="Build with PyOxidizer targeting this host triple", |
123 ) | 89 ) |
124 sp.add_argument("--python", help="path to python.exe to use") | |
125 sp.add_argument("--iscc", help="path to iscc.exe to use") | 90 sp.add_argument("--iscc", help="path to iscc.exe to use") |
126 sp.add_argument( | 91 sp.add_argument( |
127 "--version", | 92 "--version", |
128 help="Mercurial version string to use " | 93 help="Mercurial version string to use " |
129 "(detected from __version__.py if not defined", | 94 "(detected from __version__.py if not defined", |
135 ) | 100 ) |
136 sp.add_argument("--name", help="Application name", default="Mercurial") | 101 sp.add_argument("--name", help="Application name", default="Mercurial") |
137 sp.add_argument( | 102 sp.add_argument( |
138 "--pyoxidizer-target", | 103 "--pyoxidizer-target", |
139 choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"}, | 104 choices={"i686-pc-windows-msvc", "x86_64-pc-windows-msvc"}, |
105 required=True, | |
140 help="Build with PyOxidizer targeting this host triple", | 106 help="Build with PyOxidizer targeting this host triple", |
141 ) | 107 ) |
142 sp.add_argument("--python", help="Path to Python executable to use") | |
143 sp.add_argument( | 108 sp.add_argument( |
144 "--sign-sn", | 109 "--sign-sn", |
145 help="Subject name (or fragment thereof) of certificate " | 110 help="Subject name (or fragment thereof) of certificate " |
146 "to use for signing", | 111 "to use for signing", |
147 ) | 112 ) |
152 sp.add_argument( | 117 sp.add_argument( |
153 "--sign-timestamp-url", | 118 "--sign-timestamp-url", |
154 help="URL of timestamp server to use for signing", | 119 help="URL of timestamp server to use for signing", |
155 ) | 120 ) |
156 sp.add_argument("--version", help="Version string to use") | 121 sp.add_argument("--version", help="Version string to use") |
157 sp.add_argument( | |
158 "--extra-packages-script", | |
159 help=( | |
160 "Script to execute to include extra packages in " "py2exe binary." | |
161 ), | |
162 ) | |
163 sp.add_argument( | 122 sp.add_argument( |
164 "--extra-wxs", help="CSV of path_to_wxs_file=working_dir_for_wxs_file" | 123 "--extra-wxs", help="CSV of path_to_wxs_file=working_dir_for_wxs_file" |
165 ) | 124 ) |
166 sp.add_argument( | 125 sp.add_argument( |
167 "--extra-features", | 126 "--extra-features", |