summarylogtreecommitdiffstats
path: root/0099-Change-the-get_platform-method-in-sysconfig-and-dist.patch
blob: 07dd2e3f79433cd426e1319b3ab6edac40756652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From 0e71a45f5306c61085b972fb6799dad58cc51b83 Mon Sep 17 00:00:00 2001
From: Naveen M K <naveen521kk@gmail.com>
Date: Mon, 28 Jun 2021 17:31:35 +0530
Subject: [PATCH 099/N] Change the `get_platform()` method in sysconfig and
 distutils

This would possibly fix building wheels when mingw python
is used and would be unique to each python same as EXT_SUFFIX.

Also, this modifies the `sys.version` argument to include UCRT
in it.

Signed-off-by: Naveen M K <naveen521kk@gmail.com>
---
 Lib/distutils/util.py | 16 ++++++++++++++--
 Lib/sysconfig.py      | 16 ++++++++++++++--
 Python/getcompiler.c  |  4 ++++
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 75a369d..5b51c76 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -36,8 +36,20 @@ def get_host_platform():
 
     """
     if os.name == 'nt':
-        if 'GCC' in sys.version:
-            return 'mingw'
+        if 'gcc' in sys.version.lower():
+            if 'ucrt' in sys.version.lower():
+                if 'amd64' in sys.version.lower():
+                    return 'mingw_x86_64_ucrt'
+                return 'mingw_i686_ucrt'
+            if 'clang' in sys.version.lower():
+                if 'amd64' in sys.version.lower():
+                    return 'mingw_x86_64_clang'
+                if 'arm64' in sys.version.lower():
+                    return 'mingw_aarch64'
+                return 'mingw_i686_clang'
+            if 'amd64' in sys.version.lower():
+                return 'mingw_x86_64'
+            return 'mingw_i686'
         if 'amd64' in sys.version.lower():
             return 'win-amd64'
         if '(arm)' in sys.version.lower():
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index c0695e2..854b382 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -667,8 +667,20 @@ def get_platform():
 
     """
     if os.name == 'nt':
-        if 'GCC' in sys.version:
-            return 'mingw'
+        if 'gcc' in sys.version.lower():
+            if 'ucrt' in sys.version.lower():
+                if 'amd64' in sys.version.lower():
+                    return 'mingw_x86_64_ucrt'
+                return 'mingw_i686_ucrt'
+            if 'clang' in sys.version.lower():
+                if 'amd64' in sys.version.lower():
+                    return 'mingw_x86_64_clang'
+                if 'arm64' in sys.version.lower():
+                    return 'mingw_aarch64'
+                return 'mingw_i686_clang'
+            if 'amd64' in sys.version.lower():
+                return 'mingw_x86_64'
+            return 'mingw_i686'
         if 'amd64' in sys.version.lower():
             return 'win-amd64'
         if '(arm)' in sys.version.lower():
diff --git a/Python/getcompiler.c b/Python/getcompiler.c
index b529e29..2d935fe 100644
--- a/Python/getcompiler.c
+++ b/Python/getcompiler.c
@@ -33,8 +33,12 @@
 #define COMPILER COMP_SEP "[GCC Clang " xstr(__clang_major__) "." \
         xstr(__clang_minor__) "." xstr(__clang_patchlevel__) ARCH_SUFFIX "]"
 #else
+#if defined(_UCRT)
+#define COMPILER COMP_SEP "[GCC UCRT " __VERSION__ ARCH_SUFFIX "]"
+#else
 #define COMPILER COMP_SEP "[GCC " __VERSION__ ARCH_SUFFIX "]"
 #endif
+#endif
 // Generic fallbacks.
 #elif defined(__cplusplus)
 #define COMPILER "[C++]"
-- 
2.32.0