diff contrib/automation/hgautomation/cli.py @ 44753:9d441f820c8b stable

automation: support building Windows wheels for Python 3.7 and 3.8 The time has come to support Python 3 on Windows. Let's teach our automation code to produce Windows wheels for Python 3.7 and 3.8. We could theoretically support 3.5 and 3.6. But I don't think it is worth it. People on Windows generally use the Mercurial installers, not wheels. And I'd prefer we limit variability and not have to worry about supporting earlier Python versions if it can be helped. As part of this, we change the invocation of pip to `python.exe -m pip`, as this is what is being recommended in Python docs these days. And it seemed to be required to avoid a weird build error. Why, I'm not sure. But it looks like pip was having trouble finding a Visual Studio files when invoked as `pip.exe` but not when using `python.exe -m pip`. Who knows. Differential Revision: https://phab.mercurial-scm.org/D8478
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 23 Apr 2020 17:24:37 -0700
parents 2372284d9457
children 802ee93c205d
line wrap: on
line diff
--- a/contrib/automation/hgautomation/cli.py	Mon Apr 20 17:42:50 2020 -0700
+++ b/contrib/automation/hgautomation/cli.py	Thu Apr 23 17:24:37 2020 -0700
@@ -99,7 +99,12 @@
 
 
 def build_windows_wheel(
-    hga: HGAutomation, aws_region, arch, revision, base_image_name
+    hga: HGAutomation,
+    aws_region,
+    python_version,
+    arch,
+    revision,
+    base_image_name,
 ):
     c = hga.aws_connection(aws_region)
     image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
@@ -110,8 +115,11 @@
 
         windows.synchronize_hg(SOURCE_ROOT, revision, instance)
 
-        for a in arch:
-            windows.build_wheel(instance.winrm_client, a, DIST_PATH)
+        for py_version in python_version:
+            for a in arch:
+                windows.build_wheel(
+                    instance.winrm_client, py_version, a, DIST_PATH
+                )
 
 
 def build_all_windows_packages(
@@ -128,10 +136,18 @@
 
         windows.synchronize_hg(SOURCE_ROOT, revision, instance)
 
+        for py_version in ("2.7", "3.7", "3.8"):
+            for arch in ("x86", "x64"):
+                windows.purge_hg(winrm_client)
+                windows.build_wheel(
+                    winrm_client,
+                    python_version=py_version,
+                    arch=arch,
+                    dest_path=DIST_PATH,
+                )
+
         for arch in ('x86', 'x64'):
             windows.purge_hg(winrm_client)
-            windows.build_wheel(winrm_client, arch, DIST_PATH)
-            windows.purge_hg(winrm_client)
             windows.build_inno_installer(
                 winrm_client, arch, DIST_PATH, version=version
             )
@@ -316,6 +332,13 @@
         'build-windows-wheel', help='Build Windows wheel(s)',
     )
     sp.add_argument(
+        '--python-version',
+        help='Python version to build for',
+        choices={'2.7', '3.7', '3.8'},
+        nargs='*',
+        default=['3.8'],
+    )
+    sp.add_argument(
         '--arch',
         help='Architecture to build for',
         choices={'x86', 'x64'},