|
23 | 23 | CompileError, LibError, LinkError
|
24 | 24 | from distutils.ccompiler import CCompiler, gen_lib_options
|
25 | 25 | from distutils import log
|
26 |
| -from distutils.util import get_platform |
| 26 | +from distutils.util import get_target_platform |
27 | 27 |
|
28 | 28 | from itertools import count
|
29 | 29 |
|
@@ -88,13 +88,24 @@ def _find_vc2017():
|
88 | 88 |
|
89 | 89 | return None, None
|
90 | 90 |
|
| 91 | +PLAT_SPEC_TO_RUNTIME = { |
| 92 | + 'x86' : 'x86', |
| 93 | + 'x86_amd64' : 'x64', |
| 94 | + 'x86_arm' : 'arm', |
| 95 | +} |
| 96 | + |
91 | 97 | def _find_vcvarsall(plat_spec):
|
92 | 98 | _, best_dir = _find_vc2017()
|
93 | 99 | vcruntime = None
|
94 |
| - vcruntime_plat = 'x64' if 'amd64' in plat_spec else 'x86' |
| 100 | + |
| 101 | + if plat_spec in PLAT_SPEC_TO_RUNTIME: |
| 102 | + vcruntime_plat = PLAT_SPEC_TO_RUNTIME[plat_spec] |
| 103 | + else: |
| 104 | + vcruntime_plat = 'x64' if 'amd64' in plat_spec else 'x86' |
| 105 | + |
95 | 106 | if best_dir:
|
96 | 107 | vcredist = os.path.join(best_dir, "..", "..", "redist", "MSVC", "**",
|
97 |
| - "Microsoft.VC141.CRT", "vcruntime140.dll") |
| 108 | + vcruntime_plat, "Microsoft.VC141.CRT", "vcruntime140.dll") |
98 | 109 | try:
|
99 | 110 | import glob
|
100 | 111 | vcruntime = glob.glob(vcredist, recursive=True)[-1]
|
@@ -171,12 +182,13 @@ def _find_exe(exe, paths=None):
|
171 | 182 | return fn
|
172 | 183 | return exe
|
173 | 184 |
|
174 |
| -# A map keyed by get_platform() return values to values accepted by |
| 185 | +# A map keyed by get_target_platform() return values to values accepted by |
175 | 186 | # 'vcvarsall.bat'. Always cross-compile from x86 to work with the
|
176 | 187 | # lighter-weight MSVC installs that do not include native 64-bit tools.
|
177 | 188 | PLAT_TO_VCVARS = {
|
178 | 189 | 'win32' : 'x86',
|
179 | 190 | 'win-amd64' : 'x86_amd64',
|
| 191 | + 'win-arm' : 'x86_arm', |
180 | 192 | }
|
181 | 193 |
|
182 | 194 | # A set containing the DLLs that are guaranteed to be available for
|
@@ -226,7 +238,8 @@ def initialize(self, plat_name=None):
|
226 | 238 | # multi-init means we would need to check platform same each time...
|
227 | 239 | assert not self.initialized, "don't init multiple times"
|
228 | 240 | if plat_name is None:
|
229 |
| - plat_name = get_platform() |
| 241 | + plat_name = get_target_platform() |
| 242 | + |
230 | 243 | # sanity check for platforms to prevent obscure errors later.
|
231 | 244 | if plat_name not in PLAT_TO_VCVARS:
|
232 | 245 | raise DistutilsPlatformError("--plat-name must be one of {}"
|
|
0 commit comments