##// END OF EJS Templates
packaging: don't use temporary directory...
Gregory Szorc -
r42079:5e923355 default
parent child Browse files
Show More
@@ -11,7 +11,6 b' 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,
@@ -99,73 +98,70 b' def build(source_dir: pathlib.Path, buil'
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)
106
107 venv_python = venv_path / 'Scripts' / 'python.exe'
108 venv_pip = venv_path / 'Scripts' / 'pip.exe'
104
109
105 if not venv_path.exists():
110 requirements_txt = (source_dir / 'contrib' / 'packaging' /
106 print('creating virtualenv with dependencies')
111 'inno' / 'requirements.txt')
107 subprocess.run(
112 subprocess.run([str(venv_pip), 'install', '-r', str(requirements_txt)],
108 [str(python_exe), str(virtualenv_py), str(venv_path)],
113 check=True)
109 check=True)
110
114
111 venv_python = venv_path / 'Scripts' / 'python.exe'
115 # Force distutils to use VC++ settings from environment, which was
112 venv_pip = venv_path / 'Scripts' / 'pip.exe'
116 # validated above.
117 env = dict(os.environ)
118 env['DISTUTILS_USE_SDK'] = '1'
119 env['MSSdk'] = '1'
113
120
114 requirements_txt = (source_dir / 'contrib' / 'packaging' /
121 py2exe_py_path = venv_path / 'Lib' / 'site-packages' / 'py2exe'
115 'inno' / 'requirements.txt')
122 if not py2exe_py_path.exists():
116 subprocess.run([str(venv_pip), 'install', '-r', str(requirements_txt)],
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'):
136
145 basename = 'Microsoft.VC90.CRT.manifest'
137 print('building Mercurial')
146 else:
138 subprocess.run(
147 basename = f.name
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
148
146 # hg.exe depends on VC9 runtime DLLs. Copy those into place.
149 dest_path = source_dir / 'dist' / basename
147 for f in find_vc_runtime_files(vc_x64):
148 if f.name.endswith('.manifest'):
149 basename = 'Microsoft.VC90.CRT.manifest'
150 else:
151 basename = f.name
152
150
153 dest_path = source_dir / 'dist' / basename
151 print('copying %s to %s' % (f, dest_path))
152 shutil.copyfile(f, dest_path)
154
153
155 print('copying %s to %s' % (f, dest_path))
154 print('creating installer')
156 shutil.copyfile(f, dest_path)
155
156 args = [str(iscc_exe)]
157
157
158 print('creating installer')
158 if vc_x64:
159
159 args.append('/dARCH=x64')
160 args = [str(iscc_exe)]
161
162 if vc_x64:
163 args.append('/dARCH=x64')
164
160
165 if version:
161 if version:
166 args.append('/dVERSION=%s' % version)
162 args.append('/dVERSION=%s' % version)
167
163
168 args.append('/Odist')
164 args.append('/Odist')
169 args.append('contrib/packaging/inno/mercurial.iss')
165 args.append('contrib/packaging/inno/mercurial.iss')
170
166
171 subprocess.run(args, cwd=str(source_dir), check=True)
167 subprocess.run(args, cwd=str(source_dir), check=True)
General Comments 0
You need to be logged in to leave comments. Login now