contrib/automation/hgautomation/windows.py
branchstable
changeset 44768 9d441f820c8b
parent 43513 081a77df7bc6
child 44769 9ade217b550d
equal deleted inserted replaced
44767:234882d17814 44768:9d441f820c8b
    77 }}
    77 }}
    78 '''.lstrip()
    78 '''.lstrip()
    79 
    79 
    80 BUILD_WHEEL = r'''
    80 BUILD_WHEEL = r'''
    81 Set-Location C:\hgdev\src
    81 Set-Location C:\hgdev\src
    82 C:\hgdev\python27-{arch}\Scripts\pip.exe wheel --wheel-dir dist .
    82 C:\hgdev\python{python_version}-{arch}\python.exe -m pip wheel --wheel-dir dist .
    83 if ($LASTEXITCODE -ne 0) {{
    83 if ($LASTEXITCODE -ne 0) {{
    84     throw "process exited non-0: $LASTEXITCODE"
    84     throw "process exited non-0: $LASTEXITCODE"
    85 }}
    85 }}
    86 '''
    86 '''
    87 
    87 
    99 if ($LASTEXITCODE -ne 0) {{
    99 if ($LASTEXITCODE -ne 0) {{
   100     throw "process exited non-0: $LASTEXITCODE"
   100     throw "process exited non-0: $LASTEXITCODE"
   101 }}
   101 }}
   102 '''
   102 '''
   103 
   103 
   104 X86_WHEEL_FILENAME = 'mercurial-{version}-cp27-cp27m-win32.whl'
   104 WHEEL_FILENAME_PYTHON27_X86 = 'mercurial-{version}-cp27-cp27m-win32.whl'
   105 X64_WHEEL_FILENAME = 'mercurial-{version}-cp27-cp27m-win_amd64.whl'
   105 WHEEL_FILENAME_PYTHON27_X64 = 'mercurial-{version}-cp27-cp27m-win_amd64.whl'
       
   106 WHEEL_FILENAME_PYTHON37_X86 = 'mercurial-{version}-cp37-cp37m-win32.whl'
       
   107 WHEEL_FILENAME_PYTHON37_X64 = 'mercurial-{version}-cp37-cp37m-win_amd64.whl'
       
   108 WHEEL_FILENAME_PYTHON38_X86 = 'mercurial-{version}-cp38-cp38-win32.whl'
       
   109 WHEEL_FILENAME_PYTHON38_X64 = 'mercurial-{version}-cp38-cp38-win_amd64.whl'
       
   110 
   106 X86_EXE_FILENAME = 'Mercurial-{version}.exe'
   111 X86_EXE_FILENAME = 'Mercurial-{version}.exe'
   107 X64_EXE_FILENAME = 'Mercurial-{version}-x64.exe'
   112 X64_EXE_FILENAME = 'Mercurial-{version}-x64.exe'
   108 X86_MSI_FILENAME = 'mercurial-{version}-x86.msi'
   113 X86_MSI_FILENAME = 'mercurial-{version}-x86.msi'
   109 X64_MSI_FILENAME = 'mercurial-{version}-x64.msi'
   114 X64_MSI_FILENAME = 'mercurial-{version}-x64.msi'
   110 
   115 
   298     )
   303     )
   299     run_powershell(winrm_client, ps)
   304     run_powershell(winrm_client, ps)
   300     copy_latest_dist(winrm_client, '*.exe', dest_path)
   305     copy_latest_dist(winrm_client, '*.exe', dest_path)
   301 
   306 
   302 
   307 
   303 def build_wheel(winrm_client, arch: str, dest_path: pathlib.Path):
   308 def build_wheel(
       
   309     winrm_client, python_version: str, arch: str, dest_path: pathlib.Path
       
   310 ):
   304     """Build Python wheels on a remote machine.
   311     """Build Python wheels on a remote machine.
   305 
   312 
   306     Using a WinRM client, remote commands are executed to build a Python wheel
   313     Using a WinRM client, remote commands are executed to build a Python wheel
   307     for Mercurial.
   314     for Mercurial.
   308     """
   315     """
   309     print('Building Windows wheel for %s' % arch)
   316     print('Building Windows wheel for Python %s %s' % (python_version, arch))
   310     ps = get_vc_prefix(arch) + BUILD_WHEEL.format(arch=arch)
   317 
       
   318     ps = BUILD_WHEEL.format(
       
   319         python_version=python_version.replace(".", ""), arch=arch
       
   320     )
       
   321 
       
   322     # Python 2.7 requires an activated environment.
       
   323     if python_version == "2.7":
       
   324         ps = get_vc_prefix(arch) + ps
       
   325 
   311     run_powershell(winrm_client, ps)
   326     run_powershell(winrm_client, ps)
   312     copy_latest_dist(winrm_client, '*.whl', dest_path)
   327     copy_latest_dist(winrm_client, '*.whl', dest_path)
   313 
   328 
   314 
   329 
   315 def build_wix_installer(
   330 def build_wix_installer(
   354     run_powershell(winrm_client, ps)
   369     run_powershell(winrm_client, ps)
   355 
   370 
   356 
   371 
   357 def resolve_wheel_artifacts(dist_path: pathlib.Path, version: str):
   372 def resolve_wheel_artifacts(dist_path: pathlib.Path, version: str):
   358     return (
   373     return (
   359         dist_path / X86_WHEEL_FILENAME.format(version=version),
   374         dist_path / WHEEL_FILENAME_PYTHON27_X86.format(version=version),
   360         dist_path / X64_WHEEL_FILENAME.format(version=version),
   375         dist_path / WHEEL_FILENAME_PYTHON27_X64.format(version=version),
       
   376         dist_path / WHEEL_FILENAME_PYTHON37_X86.format(version=version),
       
   377         dist_path / WHEEL_FILENAME_PYTHON37_X64.format(version=version),
       
   378         dist_path / WHEEL_FILENAME_PYTHON38_X86.format(version=version),
       
   379         dist_path / WHEEL_FILENAME_PYTHON38_X64.format(version=version),
   361     )
   380     )
   362 
   381 
   363 
   382 
   364 def resolve_all_artifacts(dist_path: pathlib.Path, version: str):
   383 def resolve_all_artifacts(dist_path: pathlib.Path, version: str):
   365     return (
   384     return (
   366         dist_path / X86_WHEEL_FILENAME.format(version=version),
   385         dist_path / WHEEL_FILENAME_PYTHON27_X86.format(version=version),
   367         dist_path / X64_WHEEL_FILENAME.format(version=version),
   386         dist_path / WHEEL_FILENAME_PYTHON27_X64.format(version=version),
       
   387         dist_path / WHEEL_FILENAME_PYTHON37_X86.format(version=version),
       
   388         dist_path / WHEEL_FILENAME_PYTHON37_X64.format(version=version),
       
   389         dist_path / WHEEL_FILENAME_PYTHON38_X86.format(version=version),
       
   390         dist_path / WHEEL_FILENAME_PYTHON38_X64.format(version=version),
   368         dist_path / X86_EXE_FILENAME.format(version=version),
   391         dist_path / X86_EXE_FILENAME.format(version=version),
   369         dist_path / X64_EXE_FILENAME.format(version=version),
   392         dist_path / X64_EXE_FILENAME.format(version=version),
   370         dist_path / X86_MSI_FILENAME.format(version=version),
   393         dist_path / X86_MSI_FILENAME.format(version=version),
   371         dist_path / X64_MSI_FILENAME.format(version=version),
   394         dist_path / X64_MSI_FILENAME.format(version=version),
   372     )
   395     )