Show More
@@ -63,7 +63,13 b' def bootstrap_windows_dev(hga: HGAutomat' | |||||
63 |
|
63 | |||
64 |
|
64 | |||
65 | def build_inno( |
|
65 | def build_inno( | |
66 | hga: HGAutomation, aws_region, arch, revision, version, base_image_name |
|
66 | hga: HGAutomation, | |
|
67 | aws_region, | |||
|
68 | python_version, | |||
|
69 | arch, | |||
|
70 | revision, | |||
|
71 | version, | |||
|
72 | base_image_name, | |||
67 | ): |
|
73 | ): | |
68 | c = hga.aws_connection(aws_region) |
|
74 | c = hga.aws_connection(aws_region) | |
69 | image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) |
|
75 | image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name) | |
@@ -74,10 +80,15 b' def build_inno(' | |||||
74 |
|
80 | |||
75 | windows.synchronize_hg(SOURCE_ROOT, revision, instance) |
|
81 | windows.synchronize_hg(SOURCE_ROOT, revision, instance) | |
76 |
|
82 | |||
77 | for a in arch: |
|
83 | for py_version in python_version: | |
78 | windows.build_inno_installer( |
|
84 | for a in arch: | |
79 | instance.winrm_client, a, DIST_PATH, version=version |
|
85 | windows.build_inno_installer( | |
80 | ) |
|
86 | instance.winrm_client, | |
|
87 | py_version, | |||
|
88 | a, | |||
|
89 | DIST_PATH, | |||
|
90 | version=version, | |||
|
91 | ) | |||
81 |
|
92 | |||
82 |
|
93 | |||
83 | def build_wix( |
|
94 | def build_wix( | |
@@ -146,12 +157,15 b' def build_all_windows_packages(' | |||||
146 | dest_path=DIST_PATH, |
|
157 | dest_path=DIST_PATH, | |
147 | ) |
|
158 | ) | |
148 |
|
159 | |||
|
160 | for py_version in (2, 3): | |||
|
161 | for arch in ('x86', 'x64'): | |||
|
162 | windows.purge_hg(winrm_client) | |||
|
163 | windows.build_inno_installer( | |||
|
164 | winrm_client, py_version, arch, DIST_PATH, version=version | |||
|
165 | ) | |||
|
166 | ||||
149 | for arch in ('x86', 'x64'): |
|
167 | for arch in ('x86', 'x64'): | |
150 | windows.purge_hg(winrm_client) |
|
168 | windows.purge_hg(winrm_client) | |
151 | windows.build_inno_installer( |
|
|||
152 | winrm_client, arch, DIST_PATH, version=version |
|
|||
153 | ) |
|
|||
154 | windows.purge_hg(winrm_client) |
|
|||
155 | windows.build_wix_installer( |
|
169 | windows.build_wix_installer( | |
156 | winrm_client, arch, DIST_PATH, version=version |
|
170 | winrm_client, arch, DIST_PATH, version=version | |
157 | ) |
|
171 | ) | |
@@ -309,6 +323,14 b' def get_parser():' | |||||
309 | 'build-inno', help='Build Inno Setup installer(s)', |
|
323 | 'build-inno', help='Build Inno Setup installer(s)', | |
310 | ) |
|
324 | ) | |
311 | sp.add_argument( |
|
325 | sp.add_argument( | |
|
326 | '--python-version', | |||
|
327 | help='Which version of Python to target', | |||
|
328 | choices={2, 3}, | |||
|
329 | type=int, | |||
|
330 | nargs='*', | |||
|
331 | default=[3], | |||
|
332 | ) | |||
|
333 | sp.add_argument( | |||
312 | '--arch', |
|
334 | '--arch', | |
313 | help='Architecture to build for', |
|
335 | help='Architecture to build for', | |
314 | choices={'x86', 'x64'}, |
|
336 | choices={'x86', 'x64'}, |
@@ -68,7 +68,17 b' hg.exe log -r .' | |||||
68 | Write-Output "updated Mercurial working directory to {revision}" |
|
68 | Write-Output "updated Mercurial working directory to {revision}" | |
69 | '''.lstrip() |
|
69 | '''.lstrip() | |
70 |
|
70 | |||
71 | BUILD_INNO = r''' |
|
71 | BUILD_INNO_PYTHON3 = r''' | |
|
72 | $Env:RUSTUP_HOME = "C:\hgdev\rustup" | |||
|
73 | $Env:CARGO_HOME = "C:\hgdev\cargo" | |||
|
74 | Set-Location C:\hgdev\src | |||
|
75 | C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py inno --pyoxidizer-target {pyoxidizer_target} --version {version} | |||
|
76 | if ($LASTEXITCODE -ne 0) {{ | |||
|
77 | throw "process exited non-0: $LASTEXITCODE" | |||
|
78 | }} | |||
|
79 | ''' | |||
|
80 | ||||
|
81 | BUILD_INNO_PYTHON2 = r''' | |||
72 | Set-Location C:\hgdev\src |
|
82 | Set-Location C:\hgdev\src | |
73 | $python = "C:\hgdev\python27-{arch}\python.exe" |
|
83 | $python = "C:\hgdev\python27-{arch}\python.exe" | |
74 | C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py inno --python $python {extra_args} |
|
84 | C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py inno --python $python {extra_args} | |
@@ -108,8 +118,10 b" WHEEL_FILENAME_PYTHON37_X64 = 'mercurial" | |||||
108 | WHEEL_FILENAME_PYTHON38_X86 = 'mercurial-{version}-cp38-cp38-win32.whl' |
|
118 | WHEEL_FILENAME_PYTHON38_X86 = 'mercurial-{version}-cp38-cp38-win32.whl' | |
109 | WHEEL_FILENAME_PYTHON38_X64 = 'mercurial-{version}-cp38-cp38-win_amd64.whl' |
|
119 | WHEEL_FILENAME_PYTHON38_X64 = 'mercurial-{version}-cp38-cp38-win_amd64.whl' | |
110 |
|
120 | |||
111 |
|
|
121 | EXE_FILENAME_PYTHON2_X86 = 'Mercurial-{version}-x86-python2.exe' | |
112 |
|
|
122 | EXE_FILENAME_PYTHON2_X64 = 'Mercurial-{version}-x64-python2.exe' | |
|
123 | EXE_FILENAME_PYTHON3_X86 = 'Mercurial-{version}-x86.exe' | |||
|
124 | EXE_FILENAME_PYTHON3_X64 = 'Mercurial-{version}-x64.exe' | |||
113 | X86_MSI_FILENAME = 'mercurial-{version}-x86-python2.msi' |
|
125 | X86_MSI_FILENAME = 'mercurial-{version}-x86-python2.msi' | |
114 | X64_MSI_FILENAME = 'mercurial-{version}-x64-python2.msi' |
|
126 | X64_MSI_FILENAME = 'mercurial-{version}-x64-python2.msi' | |
115 |
|
127 | |||
@@ -118,12 +130,21 b" MERCURIAL_SCM_BASE_URL = 'https://mercur" | |||||
118 | X86_USER_AGENT_PATTERN = '.*Windows.*' |
|
130 | X86_USER_AGENT_PATTERN = '.*Windows.*' | |
119 | X64_USER_AGENT_PATTERN = '.*Windows.*(WOW|x)64.*' |
|
131 | X64_USER_AGENT_PATTERN = '.*Windows.*(WOW|x)64.*' | |
120 |
|
132 | |||
121 |
|
|
133 | EXE_PYTHON2_X86_DESCRIPTION = ( | |
122 | 'Mercurial {version} Inno Setup installer - x86 Windows ' |
|
134 | 'Mercurial {version} Inno Setup installer - x86 Windows (Python 2) ' | |
|
135 | '- does not require admin rights' | |||
|
136 | ) | |||
|
137 | EXE_PYTHON2_X64_DESCRIPTION = ( | |||
|
138 | 'Mercurial {version} Inno Setup installer - x64 Windows (Python 2) ' | |||
123 | '- does not require admin rights' |
|
139 | '- does not require admin rights' | |
124 | ) |
|
140 | ) | |
125 | X64_EXE_DESCRIPTION = ( |
|
141 | # TODO remove Python version once Python 2 is dropped. | |
126 | 'Mercurial {version} Inno Setup installer - x64 Windows ' |
|
142 | EXE_PYTHON3_X86_DESCRIPTION = ( | |
|
143 | 'Mercurial {version} Inno Setup installer - x86 Windows (Python 3) ' | |||
|
144 | '- does not require admin rights' | |||
|
145 | ) | |||
|
146 | EXE_PYTHON3_X64_DESCRIPTION = ( | |||
|
147 | 'Mercurial {version} Inno Setup installer - x64 Windows (Python 3) ' | |||
127 | '- does not require admin rights' |
|
148 | '- does not require admin rights' | |
128 | ) |
|
149 | ) | |
129 | X86_MSI_DESCRIPTION = ( |
|
150 | X86_MSI_DESCRIPTION = ( | |
@@ -285,22 +306,48 b' def copy_latest_dist(winrm_client, patte' | |||||
285 |
|
306 | |||
286 |
|
307 | |||
287 | def build_inno_installer( |
|
308 | def build_inno_installer( | |
288 | winrm_client, arch: str, dest_path: pathlib.Path, version=None |
|
309 | winrm_client, | |
|
310 | python_version: int, | |||
|
311 | arch: str, | |||
|
312 | dest_path: pathlib.Path, | |||
|
313 | version=None, | |||
289 | ): |
|
314 | ): | |
290 | """Build the Inno Setup installer on a remote machine. |
|
315 | """Build the Inno Setup installer on a remote machine. | |
291 |
|
316 | |||
292 | Using a WinRM client, remote commands are executed to build |
|
317 | Using a WinRM client, remote commands are executed to build | |
293 | a Mercurial Inno Setup installer. |
|
318 | a Mercurial Inno Setup installer. | |
294 | """ |
|
319 | """ | |
295 | print('building Inno Setup installer for %s' % arch) |
|
320 | print( | |
|
321 | 'building Inno Setup installer for Python %d %s' | |||
|
322 | % (python_version, arch) | |||
|
323 | ) | |||
|
324 | ||||
|
325 | if python_version == 3: | |||
|
326 | # TODO fix this limitation in packaging code | |||
|
327 | if not version: | |||
|
328 | raise Exception( | |||
|
329 | "version string is required when building for Python 3" | |||
|
330 | ) | |||
296 |
|
331 | |||
297 | extra_args = [] |
|
332 | if arch == "x86": | |
298 | if version: |
|
333 | target_triple = "i686-pc-windows-msvc" | |
299 | extra_args.extend(['--version', version]) |
|
334 | elif arch == "x64": | |
|
335 | target_triple = "x86_64-pc-windows-msvc" | |||
|
336 | else: | |||
|
337 | raise Exception("unhandled arch: %s" % arch) | |||
300 |
|
338 | |||
301 |
ps = |
|
339 | ps = BUILD_INNO_PYTHON3.format( | |
302 | arch=arch, extra_args=' '.join(extra_args) |
|
340 | pyoxidizer_target=target_triple, version=version, | |
303 | ) |
|
341 | ) | |
|
342 | else: | |||
|
343 | extra_args = [] | |||
|
344 | if version: | |||
|
345 | extra_args.extend(['--version', version]) | |||
|
346 | ||||
|
347 | ps = get_vc_prefix(arch) + BUILD_INNO_PYTHON2.format( | |||
|
348 | arch=arch, extra_args=' '.join(extra_args) | |||
|
349 | ) | |||
|
350 | ||||
304 | run_powershell(winrm_client, ps) |
|
351 | run_powershell(winrm_client, ps) | |
305 | copy_latest_dist(winrm_client, '*.exe', dest_path) |
|
352 | copy_latest_dist(winrm_client, '*.exe', dest_path) | |
306 |
|
353 | |||
@@ -388,16 +435,20 b' def resolve_all_artifacts(dist_path: pat' | |||||
388 | dist_path / WHEEL_FILENAME_PYTHON37_X64.format(version=version), |
|
435 | dist_path / WHEEL_FILENAME_PYTHON37_X64.format(version=version), | |
389 | dist_path / WHEEL_FILENAME_PYTHON38_X86.format(version=version), |
|
436 | dist_path / WHEEL_FILENAME_PYTHON38_X86.format(version=version), | |
390 | dist_path / WHEEL_FILENAME_PYTHON38_X64.format(version=version), |
|
437 | dist_path / WHEEL_FILENAME_PYTHON38_X64.format(version=version), | |
391 |
dist_path / |
|
438 | dist_path / EXE_FILENAME_PYTHON2_X86.format(version=version), | |
392 |
dist_path / |
|
439 | dist_path / EXE_FILENAME_PYTHON2_X64.format(version=version), | |
|
440 | dist_path / EXE_FILENAME_PYTHON3_X86.format(version=version), | |||
|
441 | dist_path / EXE_FILENAME_PYTHON3_X64.format(version=version), | |||
393 | dist_path / X86_MSI_FILENAME.format(version=version), |
|
442 | dist_path / X86_MSI_FILENAME.format(version=version), | |
394 | dist_path / X64_MSI_FILENAME.format(version=version), |
|
443 | dist_path / X64_MSI_FILENAME.format(version=version), | |
395 | ) |
|
444 | ) | |
396 |
|
445 | |||
397 |
|
446 | |||
398 | def generate_latest_dat(version: str): |
|
447 | def generate_latest_dat(version: str): | |
399 |
x86_exe_filename = |
|
448 | python2_x86_exe_filename = EXE_FILENAME_PYTHON2_X86.format(version=version) | |
400 |
x64_exe_filename = |
|
449 | python2_x64_exe_filename = EXE_FILENAME_PYTHON2_X64.format(version=version) | |
|
450 | python3_x86_exe_filename = EXE_FILENAME_PYTHON3_X86.format(version=version) | |||
|
451 | python3_x64_exe_filename = EXE_FILENAME_PYTHON3_X64.format(version=version) | |||
401 | x86_msi_filename = X86_MSI_FILENAME.format(version=version) |
|
452 | x86_msi_filename = X86_MSI_FILENAME.format(version=version) | |
402 | x64_msi_filename = X64_MSI_FILENAME.format(version=version) |
|
453 | x64_msi_filename = X64_MSI_FILENAME.format(version=version) | |
403 |
|
454 | |||
@@ -406,15 +457,29 b' def generate_latest_dat(version: str):' | |||||
406 | '10', |
|
457 | '10', | |
407 | version, |
|
458 | version, | |
408 | X86_USER_AGENT_PATTERN, |
|
459 | X86_USER_AGENT_PATTERN, | |
409 | '%s/%s' % (MERCURIAL_SCM_BASE_URL, x86_exe_filename), |
|
460 | '%s/%s' % (MERCURIAL_SCM_BASE_URL, python3_x86_exe_filename), | |
410 |
|
|
461 | EXE_PYTHON3_X86_DESCRIPTION.format(version=version), | |
411 | ), |
|
462 | ), | |
412 | ( |
|
463 | ( | |
413 | '10', |
|
464 | '10', | |
414 | version, |
|
465 | version, | |
415 | X64_USER_AGENT_PATTERN, |
|
466 | X64_USER_AGENT_PATTERN, | |
416 | '%s/%s' % (MERCURIAL_SCM_BASE_URL, x64_exe_filename), |
|
467 | '%s/%s' % (MERCURIAL_SCM_BASE_URL, python3_x64_exe_filename), | |
417 |
|
|
468 | EXE_PYTHON3_X64_DESCRIPTION.format(version=version), | |
|
469 | ), | |||
|
470 | ( | |||
|
471 | '9', | |||
|
472 | version, | |||
|
473 | X86_USER_AGENT_PATTERN, | |||
|
474 | '%s/%s' % (MERCURIAL_SCM_BASE_URL, python2_x86_exe_filename), | |||
|
475 | EXE_PYTHON2_X86_DESCRIPTION.format(version=version), | |||
|
476 | ), | |||
|
477 | ( | |||
|
478 | '9', | |||
|
479 | version, | |||
|
480 | X64_USER_AGENT_PATTERN, | |||
|
481 | '%s/%s' % (MERCURIAL_SCM_BASE_URL, python2_x64_exe_filename), | |||
|
482 | EXE_PYTHON2_X64_DESCRIPTION.format(version=version), | |||
418 | ), |
|
483 | ), | |
419 | ( |
|
484 | ( | |
420 | '10', |
|
485 | '10', |
General Comments 0
You need to be logged in to leave comments.
Login now