##// END OF EJS Templates
automation: support building Python 3 MSI installers...
Gregory Szorc -
r45279:5e788dc7 stable
parent child Browse files
Show More
@@ -92,7 +92,13 b' def build_inno('
92
92
93
93
94 def build_wix(
94 def build_wix(
95 hga: HGAutomation, aws_region, arch, revision, version, base_image_name
95 hga: HGAutomation,
96 aws_region,
97 python_version,
98 arch,
99 revision,
100 version,
101 base_image_name,
96 ):
102 ):
97 c = hga.aws_connection(aws_region)
103 c = hga.aws_connection(aws_region)
98 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
104 image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
@@ -103,9 +109,14 b' def build_wix('
103
109
104 windows.synchronize_hg(SOURCE_ROOT, revision, instance)
110 windows.synchronize_hg(SOURCE_ROOT, revision, instance)
105
111
112 for py_version in python_version:
106 for a in arch:
113 for a in arch:
107 windows.build_wix_installer(
114 windows.build_wix_installer(
108 instance.winrm_client, a, DIST_PATH, version=version
115 instance.winrm_client,
116 py_version,
117 a,
118 DIST_PATH,
119 version=version,
109 )
120 )
110
121
111
122
@@ -163,11 +174,8 b' def build_all_windows_packages('
163 windows.build_inno_installer(
174 windows.build_inno_installer(
164 winrm_client, py_version, arch, DIST_PATH, version=version
175 winrm_client, py_version, arch, DIST_PATH, version=version
165 )
176 )
166
167 for arch in ('x86', 'x64'):
168 windows.purge_hg(winrm_client)
169 windows.build_wix_installer(
177 windows.build_wix_installer(
170 winrm_client, arch, DIST_PATH, version=version
178 winrm_client, py_version, arch, DIST_PATH, version=version
171 )
179 )
172
180
173
181
@@ -379,6 +387,14 b' def get_parser():'
379
387
380 sp = subparsers.add_parser('build-wix', help='Build WiX installer(s)')
388 sp = subparsers.add_parser('build-wix', help='Build WiX installer(s)')
381 sp.add_argument(
389 sp.add_argument(
390 '--python-version',
391 help='Which version of Python to target',
392 choices={2, 3},
393 type=int,
394 nargs='*',
395 default=[3],
396 )
397 sp.add_argument(
382 '--arch',
398 '--arch',
383 help='Architecture to build for',
399 help='Architecture to build for',
384 choices={'x86', 'x64'},
400 choices={'x86', 'x64'},
@@ -95,7 +95,17 b' if ($LASTEXITCODE -ne 0) {{'
95 }}
95 }}
96 '''
96 '''
97
97
98 BUILD_WIX = r'''
98 BUILD_WIX_PYTHON3 = r'''
99 $Env:RUSTUP_HOME = "C:\hgdev\rustup"
100 $Env:CARGO_HOME = "C:\hgdev\cargo"
101 Set-Location C:\hgdev\src
102 C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py wix --pyoxidizer-target {pyoxidizer_target} --version {version}
103 if ($LASTEXITCODE -ne 0) {{
104 throw "process exited non-0: $LASTEXITCODE"
105 }}
106 '''
107
108 BUILD_WIX_PYTHON2 = r'''
99 Set-Location C:\hgdev\src
109 Set-Location C:\hgdev\src
100 $python = "C:\hgdev\python27-{arch}\python.exe"
110 $python = "C:\hgdev\python27-{arch}\python.exe"
101 C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py wix --python $python {extra_args}
111 C:\hgdev\python37-x64\python.exe contrib\packaging\packaging.py wix --python $python {extra_args}
@@ -122,8 +132,11 b" EXE_FILENAME_PYTHON2_X86 = 'Mercurial-{v"
122 EXE_FILENAME_PYTHON2_X64 = 'Mercurial-{version}-x64-python2.exe'
132 EXE_FILENAME_PYTHON2_X64 = 'Mercurial-{version}-x64-python2.exe'
123 EXE_FILENAME_PYTHON3_X86 = 'Mercurial-{version}-x86.exe'
133 EXE_FILENAME_PYTHON3_X86 = 'Mercurial-{version}-x86.exe'
124 EXE_FILENAME_PYTHON3_X64 = 'Mercurial-{version}-x64.exe'
134 EXE_FILENAME_PYTHON3_X64 = 'Mercurial-{version}-x64.exe'
125 X86_MSI_FILENAME = 'mercurial-{version}-x86-python2.msi'
135
126 X64_MSI_FILENAME = 'mercurial-{version}-x64-python2.msi'
136 MSI_FILENAME_PYTHON2_X86 = 'mercurial-{version}-x86-python2.msi'
137 MSI_FILENAME_PYTHON2_X64 = 'mercurial-{version}-x64-python2.msi'
138 MSI_FILENAME_PYTHON3_X86 = 'mercurial-{version}-x86.msi'
139 MSI_FILENAME_PYTHON3_X64 = 'mercurial-{version}-x64.msi'
127
140
128 MERCURIAL_SCM_BASE_URL = 'https://mercurial-scm.org/release/windows'
141 MERCURIAL_SCM_BASE_URL = 'https://mercurial-scm.org/release/windows'
129
142
@@ -147,11 +160,21 b' EXE_PYTHON3_X64_DESCRIPTION = ('
147 'Mercurial {version} Inno Setup installer - x64 Windows (Python 3) '
160 'Mercurial {version} Inno Setup installer - x64 Windows (Python 3) '
148 '- does not require admin rights'
161 '- does not require admin rights'
149 )
162 )
150 X86_MSI_DESCRIPTION = (
163 MSI_PYTHON2_X86_DESCRIPTION = (
151 'Mercurial {version} MSI installer - x86 Windows ' '- requires admin rights'
164 'Mercurial {version} MSI installer - x86 Windows (Python 2) '
165 '- requires admin rights'
166 )
167 MSI_PYTHON2_X64_DESCRIPTION = (
168 'Mercurial {version} MSI installer - x64 Windows (Python 2) '
169 '- requires admin rights'
152 )
170 )
153 X64_MSI_DESCRIPTION = (
171 MSI_PYTHON3_X86_DESCRIPTION = (
154 'Mercurial {version} MSI installer - x64 Windows ' '- requires admin rights'
172 'Mercurial {version} MSI installer - x86 Windows (Python 3) '
173 '- requires admin rights'
174 )
175 MSI_PYTHON3_X64_DESCRIPTION = (
176 'Mercurial {version} MSI installer - x64 Windows (Python 3) '
177 '- requires admin rights'
155 )
178 )
156
179
157
180
@@ -375,20 +398,44 b' def build_wheel('
375
398
376
399
377 def build_wix_installer(
400 def build_wix_installer(
378 winrm_client, arch: str, dest_path: pathlib.Path, version=None
401 winrm_client,
402 python_version: int,
403 arch: str,
404 dest_path: pathlib.Path,
405 version=None,
379 ):
406 ):
380 """Build the WiX installer on a remote machine.
407 """Build the WiX installer on a remote machine.
381
408
382 Using a WinRM client, remote commands are executed to build a WiX installer.
409 Using a WinRM client, remote commands are executed to build a WiX installer.
383 """
410 """
384 print('Building WiX installer for %s' % arch)
411 print('Building WiX installer for Python %d %s' % (python_version, arch))
412
413 if python_version == 3:
414 # TODO fix this limitation in packaging code
415 if not version:
416 raise Exception(
417 "version string is required when building for Python 3"
418 )
419
420 if arch == "x86":
421 target_triple = "i686-pc-windows-msvc"
422 elif arch == "x64":
423 target_triple = "x86_64-pc-windows-msvc"
424 else:
425 raise Exception("unhandled arch: %s" % arch)
426
427 ps = BUILD_WIX_PYTHON3.format(
428 pyoxidizer_target=target_triple, version=version,
429 )
430 else:
385 extra_args = []
431 extra_args = []
386 if version:
432 if version:
387 extra_args.extend(['--version', version])
433 extra_args.extend(['--version', version])
388
434
389 ps = get_vc_prefix(arch) + BUILD_WIX.format(
435 ps = get_vc_prefix(arch) + BUILD_WIX_PYTHON2.format(
390 arch=arch, extra_args=' '.join(extra_args)
436 arch=arch, extra_args=' '.join(extra_args)
391 )
437 )
438
392 run_powershell(winrm_client, ps)
439 run_powershell(winrm_client, ps)
393 copy_latest_dist(winrm_client, '*.msi', dest_path)
440 copy_latest_dist(winrm_client, '*.msi', dest_path)
394
441
@@ -439,8 +486,10 b' def resolve_all_artifacts(dist_path: pat'
439 dist_path / EXE_FILENAME_PYTHON2_X64.format(version=version),
486 dist_path / EXE_FILENAME_PYTHON2_X64.format(version=version),
440 dist_path / EXE_FILENAME_PYTHON3_X86.format(version=version),
487 dist_path / EXE_FILENAME_PYTHON3_X86.format(version=version),
441 dist_path / EXE_FILENAME_PYTHON3_X64.format(version=version),
488 dist_path / EXE_FILENAME_PYTHON3_X64.format(version=version),
442 dist_path / X86_MSI_FILENAME.format(version=version),
489 dist_path / MSI_FILENAME_PYTHON2_X86.format(version=version),
443 dist_path / X64_MSI_FILENAME.format(version=version),
490 dist_path / MSI_FILENAME_PYTHON2_X64.format(version=version),
491 dist_path / MSI_FILENAME_PYTHON3_X86.format(version=version),
492 dist_path / MSI_FILENAME_PYTHON3_X64.format(version=version),
444 )
493 )
445
494
446
495
@@ -449,8 +498,10 b' def generate_latest_dat(version: str):'
449 python2_x64_exe_filename = EXE_FILENAME_PYTHON2_X64.format(version=version)
498 python2_x64_exe_filename = EXE_FILENAME_PYTHON2_X64.format(version=version)
450 python3_x86_exe_filename = EXE_FILENAME_PYTHON3_X86.format(version=version)
499 python3_x86_exe_filename = EXE_FILENAME_PYTHON3_X86.format(version=version)
451 python3_x64_exe_filename = EXE_FILENAME_PYTHON3_X64.format(version=version)
500 python3_x64_exe_filename = EXE_FILENAME_PYTHON3_X64.format(version=version)
452 x86_msi_filename = X86_MSI_FILENAME.format(version=version)
501 python2_x86_msi_filename = MSI_FILENAME_PYTHON2_X86.format(version=version)
453 x64_msi_filename = X64_MSI_FILENAME.format(version=version)
502 python2_x64_msi_filename = MSI_FILENAME_PYTHON2_X64.format(version=version)
503 python3_x86_msi_filename = MSI_FILENAME_PYTHON3_X86.format(version=version)
504 python3_x64_msi_filename = MSI_FILENAME_PYTHON3_X64.format(version=version)
454
505
455 entries = (
506 entries = (
456 (
507 (
@@ -485,15 +536,29 b' def generate_latest_dat(version: str):'
485 '10',
536 '10',
486 version,
537 version,
487 X86_USER_AGENT_PATTERN,
538 X86_USER_AGENT_PATTERN,
488 '%s/%s' % (MERCURIAL_SCM_BASE_URL, x86_msi_filename),
539 '%s/%s' % (MERCURIAL_SCM_BASE_URL, python3_x86_msi_filename),
489 X86_MSI_DESCRIPTION.format(version=version),
540 MSI_PYTHON3_X86_DESCRIPTION.format(version=version),
490 ),
541 ),
491 (
542 (
492 '10',
543 '10',
493 version,
544 version,
494 X64_USER_AGENT_PATTERN,
545 X64_USER_AGENT_PATTERN,
495 '%s/%s' % (MERCURIAL_SCM_BASE_URL, x64_msi_filename),
546 '%s/%s' % (MERCURIAL_SCM_BASE_URL, python3_x64_msi_filename),
496 X64_MSI_DESCRIPTION.format(version=version),
547 MSI_PYTHON3_X64_DESCRIPTION.format(version=version),
548 ),
549 (
550 '9',
551 version,
552 X86_USER_AGENT_PATTERN,
553 '%s/%s' % (MERCURIAL_SCM_BASE_URL, python2_x86_msi_filename),
554 MSI_PYTHON2_X86_DESCRIPTION.format(version=version),
555 ),
556 (
557 '9',
558 version,
559 X64_USER_AGENT_PATTERN,
560 '%s/%s' % (MERCURIAL_SCM_BASE_URL, python2_x64_msi_filename),
561 MSI_PYTHON2_X64_DESCRIPTION.format(version=version),
497 ),
562 ),
498 )
563 )
499
564
General Comments 0
You need to be logged in to leave comments. Login now