Mercurial > hg
comparison contrib/packaging/hgpackaging/inno.py @ 41913:5e923355c595
packaging: don't use temporary directory
We were no longer doing anything with it after extracting
virtualenv and py2exe to the build directory.
Differential Revision: https://phab.mercurial-scm.org/D6089
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 07 Mar 2019 10:36:20 -0800 |
parents | d4bf73ea06de |
children | 7d1211168863 |
comparison
equal
deleted
inserted
replaced
41912:d4bf73ea06de | 41913:5e923355c595 |
---|---|
9 | 9 |
10 import os | 10 import os |
11 import pathlib | 11 import pathlib |
12 import shutil | 12 import shutil |
13 import subprocess | 13 import subprocess |
14 import tempfile | |
15 | 14 |
16 from .downloads import ( | 15 from .downloads import ( |
17 download_entry, | 16 download_entry, |
18 ) | 17 ) |
19 from .util import ( | 18 from .util import ( |
97 py2exe_source_path = build_dir / ('py2exe-%s' % py2exe_entry['version']) | 96 py2exe_source_path = build_dir / ('py2exe-%s' % py2exe_entry['version']) |
98 | 97 |
99 if not py2exe_source_path.exists(): | 98 if not py2exe_source_path.exists(): |
100 extract_zip_to_directory(py2exe_pkg, build_dir) | 99 extract_zip_to_directory(py2exe_pkg, build_dir) |
101 | 100 |
102 with tempfile.TemporaryDirectory() as td: | 101 if not venv_path.exists(): |
103 td = pathlib.Path(td) | 102 print('creating virtualenv with dependencies') |
103 subprocess.run( | |
104 [str(python_exe), str(virtualenv_py), str(venv_path)], | |
105 check=True) | |
104 | 106 |
105 if not venv_path.exists(): | 107 venv_python = venv_path / 'Scripts' / 'python.exe' |
106 print('creating virtualenv with dependencies') | 108 venv_pip = venv_path / 'Scripts' / 'pip.exe' |
107 subprocess.run( | |
108 [str(python_exe), str(virtualenv_py), str(venv_path)], | |
109 check=True) | |
110 | 109 |
111 venv_python = venv_path / 'Scripts' / 'python.exe' | 110 requirements_txt = (source_dir / 'contrib' / 'packaging' / |
112 venv_pip = venv_path / 'Scripts' / 'pip.exe' | 111 'inno' / 'requirements.txt') |
112 subprocess.run([str(venv_pip), 'install', '-r', str(requirements_txt)], | |
113 check=True) | |
113 | 114 |
114 requirements_txt = (source_dir / 'contrib' / 'packaging' / | 115 # Force distutils to use VC++ settings from environment, which was |
115 'inno' / 'requirements.txt') | 116 # validated above. |
116 subprocess.run([str(venv_pip), 'install', '-r', str(requirements_txt)], | 117 env = dict(os.environ) |
118 env['DISTUTILS_USE_SDK'] = '1' | |
119 env['MSSdk'] = '1' | |
120 | |
121 py2exe_py_path = venv_path / 'Lib' / 'site-packages' / 'py2exe' | |
122 if not py2exe_py_path.exists(): | |
123 print('building py2exe') | |
124 subprocess.run([str(venv_python), 'setup.py', 'install'], | |
125 cwd=py2exe_source_path, | |
126 env=env, | |
117 check=True) | 127 check=True) |
118 | 128 |
119 # Force distutils to use VC++ settings from environment, which was | 129 # Register location of msgfmt and other binaries. |
120 # validated above. | 130 env['PATH'] = '%s%s%s' % ( |
121 env = dict(os.environ) | 131 env['PATH'], os.pathsep, str(gettext_root / 'bin')) |
122 env['DISTUTILS_USE_SDK'] = '1' | |
123 env['MSSdk'] = '1' | |
124 | 132 |
125 py2exe_py_path = venv_path / 'Lib' / 'site-packages' / 'py2exe' | 133 print('building Mercurial') |
126 if not py2exe_py_path.exists(): | 134 subprocess.run( |
127 print('building py2exe') | 135 [str(venv_python), 'setup.py', |
128 subprocess.run([str(venv_python), 'setup.py', 'install'], | 136 'py2exe', '-b', '3' if vc_x64 else '2', |
129 cwd=py2exe_source_path, | 137 'build_doc', '--html'], |
130 env=env, | 138 cwd=str(source_dir), |
131 check=True) | 139 env=env, |
140 check=True) | |
132 | 141 |
133 # Register location of msgfmt and other binaries. | 142 # hg.exe depends on VC9 runtime DLLs. Copy those into place. |
134 env['PATH'] = '%s%s%s' % ( | 143 for f in find_vc_runtime_files(vc_x64): |
135 env['PATH'], os.pathsep, str(gettext_root / 'bin')) | 144 if f.name.endswith('.manifest'): |
145 basename = 'Microsoft.VC90.CRT.manifest' | |
146 else: | |
147 basename = f.name | |
136 | 148 |
137 print('building Mercurial') | 149 dest_path = source_dir / 'dist' / basename |
138 subprocess.run( | |
139 [str(venv_python), 'setup.py', | |
140 'py2exe', '-b', '3' if vc_x64 else '2', | |
141 'build_doc', '--html'], | |
142 cwd=str(source_dir), | |
143 env=env, | |
144 check=True) | |
145 | 150 |
146 # hg.exe depends on VC9 runtime DLLs. Copy those into place. | 151 print('copying %s to %s' % (f, dest_path)) |
147 for f in find_vc_runtime_files(vc_x64): | 152 shutil.copyfile(f, dest_path) |
148 if f.name.endswith('.manifest'): | |
149 basename = 'Microsoft.VC90.CRT.manifest' | |
150 else: | |
151 basename = f.name | |
152 | 153 |
153 dest_path = source_dir / 'dist' / basename | 154 print('creating installer') |
154 | 155 |
155 print('copying %s to %s' % (f, dest_path)) | 156 args = [str(iscc_exe)] |
156 shutil.copyfile(f, dest_path) | |
157 | 157 |
158 print('creating installer') | 158 if vc_x64: |
159 args.append('/dARCH=x64') | |
159 | 160 |
160 args = [str(iscc_exe)] | 161 if version: |
162 args.append('/dVERSION=%s' % version) | |
161 | 163 |
162 if vc_x64: | 164 args.append('/Odist') |
163 args.append('/dARCH=x64') | 165 args.append('contrib/packaging/inno/mercurial.iss') |
164 | 166 |
165 if version: | 167 subprocess.run(args, cwd=str(source_dir), check=True) |
166 args.append('/dVERSION=%s' % version) | |
167 | |
168 args.append('/Odist') | |
169 args.append('contrib/packaging/inno/mercurial.iss') | |
170 | |
171 subprocess.run(args, cwd=str(source_dir), check=True) |