comparison contrib/packaging/hgpackaging/inno.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 df1767fa822d
children
comparison
equal deleted inserted replaced
48847:4561ec90d3c1 48848:17d5e25b8e78
12 import shutil 12 import shutil
13 import subprocess 13 import subprocess
14 14
15 import jinja2 15 import jinja2
16 16
17 from .py2exe import (
18 build_py2exe,
19 stage_install,
20 )
21 from .pyoxidizer import create_pyoxidizer_install_layout 17 from .pyoxidizer import create_pyoxidizer_install_layout
22 from .util import ( 18 from .util import (
23 find_legacy_vc_runtime_files,
24 normalize_windows_version, 19 normalize_windows_version,
25 process_install_rules, 20 process_install_rules,
26 read_version_py, 21 read_version_py,
27 ) 22 )
28 23
29 EXTRA_PACKAGES = {
30 'dulwich',
31 'keyring',
32 'pygments',
33 'win32ctypes',
34 }
35
36 EXTRA_INCLUDES = {
37 '_curses',
38 '_curses_panel',
39 }
40 24
41 EXTRA_INSTALL_RULES = [ 25 EXTRA_INSTALL_RULES = [
42 ('contrib/win32/mercurial.ini', 'defaultrc/mercurial.rc'), 26 ('contrib/win32/mercurial.ini', 'defaultrc/mercurial.rc'),
43 ] 27 ]
44 28
45 PACKAGE_FILES_METADATA = { 29 PACKAGE_FILES_METADATA = {
46 'ReadMe.html': 'Flags: isreadme', 30 'ReadMe.html': 'Flags: isreadme',
47 } 31 }
48
49
50 def build_with_py2exe(
51 source_dir: pathlib.Path,
52 build_dir: pathlib.Path,
53 python_exe: pathlib.Path,
54 iscc_exe: pathlib.Path,
55 version=None,
56 ):
57 """Build the Inno installer using py2exe.
58
59 Build files will be placed in ``build_dir``.
60
61 py2exe's setup.py doesn't use setuptools. It doesn't have modern logic
62 for finding the Python 2.7 toolchain. So, we require the environment
63 to already be configured with an active toolchain.
64 """
65 if not iscc_exe.exists():
66 raise Exception('%s does not exist' % iscc_exe)
67
68 vc_x64 = r'\x64' in os.environ.get('LIB', '')
69 arch = 'x64' if vc_x64 else 'x86'
70 inno_build_dir = build_dir / ('inno-py2exe-%s' % arch)
71 staging_dir = inno_build_dir / 'stage'
72
73 requirements_txt = (
74 source_dir / 'contrib' / 'packaging' / 'requirements-windows-py2.txt'
75 )
76
77 inno_build_dir.mkdir(parents=True, exist_ok=True)
78
79 build_py2exe(
80 source_dir,
81 build_dir,
82 python_exe,
83 'inno',
84 requirements_txt,
85 extra_packages=EXTRA_PACKAGES,
86 extra_includes=EXTRA_INCLUDES,
87 )
88
89 # Purge the staging directory for every build so packaging is
90 # pristine.
91 if staging_dir.exists():
92 print('purging %s' % staging_dir)
93 shutil.rmtree(staging_dir)
94
95 # Now assemble all the packaged files into the staging directory.
96 stage_install(source_dir, staging_dir)
97
98 # We also install some extra files.
99 process_install_rules(EXTRA_INSTALL_RULES, source_dir, staging_dir)
100
101 # hg.exe depends on VC9 runtime DLLs. Copy those into place.
102 for f in find_legacy_vc_runtime_files(vc_x64):
103 if f.name.endswith('.manifest'):
104 basename = 'Microsoft.VC90.CRT.manifest'
105 else:
106 basename = f.name
107
108 dest_path = staging_dir / basename
109
110 print('copying %s to %s' % (f, dest_path))
111 shutil.copyfile(f, dest_path)
112
113 build_installer(
114 source_dir,
115 inno_build_dir,
116 staging_dir,
117 iscc_exe,
118 version,
119 arch="x64" if vc_x64 else None,
120 suffix="-python2",
121 )
122 32
123 33
124 def build_with_pyoxidizer( 34 def build_with_pyoxidizer(
125 source_dir: pathlib.Path, 35 source_dir: pathlib.Path,
126 build_dir: pathlib.Path, 36 build_dir: pathlib.Path,