Skip to content

Commit 964996e

Browse files
authored
Merge pull request python#17 from paulmon/win-arm32-master
Win arm32 master
2 parents 1c3de54 + 91c3864 commit 964996e

File tree

127 files changed

+10813
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+10813
-133
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Doc/.env/
3232
Include/pydtrace_probes.h
3333
Lib/distutils/command/*.pdb
3434
Lib/lib2to3/*.pickle
35+
Lib/site-packages/**/*
3536
Lib/test/data/*
3637
Makefile
3738
Makefile.pre
@@ -69,11 +70,14 @@ PCbuild/*.VC.db
6970
PCbuild/*.VC.opendb
7071
PCbuild/.vs/
7172
PCbuild/amd64/
73+
PCbuild/arm32/
74+
PCbuild/iot/
7275
PCbuild/obj/
7376
PCbuild/win32/
7477
.purify
7578
Parser/pgen
7679
Parser/pgen.exe
80+
Scripts/*.exe
7781
__pycache__
7882
autom4te.cache
7983
build/

Include/internal/pycore_atomic.h

+2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ extern "C" {
1919

2020
#if defined(_MSC_VER)
2121
#include <intrin.h>
22+
#ifndef _M_ARM
2223
#include <immintrin.h>
2324
#endif
25+
#endif
2426

2527
/* This is modeled after the atomics interface from C1x, according to
2628
* the draft at

Include/pyport.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ extern "C" {
406406
#endif
407407

408408
/* get and set x87 control word for VisualStudio/x86 */
409-
#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */
409+
#if defined(_MSC_VER) && !defined(_WIN64) && !defined(_M_ARM) /* x87 not supported in 64-bit or ARM */
410410
#define HAVE_PY_SET_53BIT_PRECISION 1
411411
#define _Py_SET_53BIT_PRECISION_HEADER \
412412
unsigned int old_387controlword, new_387controlword, out_387controlword

Include/pythonrun.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
165165
to an 8k margin. */
166166
#define PYOS_STACK_MARGIN 2048
167167

168-
#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
168+
#if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300
169169
/* Enable stack checking under Microsoft C */
170170
#define USE_STACKCHECK
171171
#endif

Lib/ctypes/test/test_win32.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Windows specific tests
22

33
from ctypes import *
4-
import unittest, sys
4+
import unittest, sys, platform
55
from test import support
66

77
import _ctypes_test
@@ -11,6 +11,7 @@
1111
@unittest.skipUnless(sizeof(c_void_p) == sizeof(c_int),
1212
"sizeof c_void_p and c_int differ")
1313
class WindowsTestCase(unittest.TestCase):
14+
@unittest.skipIf(platform.win32_is_iot(), "API not present on Windows 10 IoT Core")
1415
def test_callconv_1(self):
1516
# Testing stdcall function
1617

@@ -26,6 +27,7 @@ def test_callconv_1(self):
2627
# (8 bytes in excess)
2728
self.assertRaises(ValueError, IsWindow, 0, 0, 0)
2829

30+
@unittest.skipIf(platform.win32_is_iot(), "API not present on Windows 10 IoT Core")
2931
def test_callconv_2(self):
3032
# Calling stdcall function as cdecl
3133

Lib/distutils/_msvccompiler.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
CompileError, LibError, LinkError
2424
from distutils.ccompiler import CCompiler, gen_lib_options
2525
from distutils import log
26-
from distutils.util import get_platform
26+
from distutils.util import get_target_platform
2727

2828
from itertools import count
2929

@@ -88,13 +88,24 @@ def _find_vc2017():
8888

8989
return None, None
9090

91+
PLAT_SPEC_TO_RUNTIME = {
92+
'x86' : 'x86',
93+
'x86_amd64' : 'x64',
94+
'x86_arm' : 'arm',
95+
}
96+
9197
def _find_vcvarsall(plat_spec):
9298
_, best_dir = _find_vc2017()
9399
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+
95106
if best_dir:
96107
vcredist = os.path.join(best_dir, "..", "..", "redist", "MSVC", "**",
97-
"Microsoft.VC141.CRT", "vcruntime140.dll")
108+
vcruntime_plat, "Microsoft.VC141.CRT", "vcruntime140.dll")
98109
try:
99110
import glob
100111
vcruntime = glob.glob(vcredist, recursive=True)[-1]
@@ -171,12 +182,13 @@ def _find_exe(exe, paths=None):
171182
return fn
172183
return exe
173184

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
175186
# 'vcvarsall.bat'. Always cross-compile from x86 to work with the
176187
# lighter-weight MSVC installs that do not include native 64-bit tools.
177188
PLAT_TO_VCVARS = {
178189
'win32' : 'x86',
179190
'win-amd64' : 'x86_amd64',
191+
'win-arm' : 'x86_arm',
180192
}
181193

182194
# A set containing the DLLs that are guaranteed to be available for
@@ -226,7 +238,8 @@ def initialize(self, plat_name=None):
226238
# multi-init means we would need to check platform same each time...
227239
assert not self.initialized, "don't init multiple times"
228240
if plat_name is None:
229-
plat_name = get_platform()
241+
plat_name = get_target_platform()
242+
230243
# sanity check for platforms to prevent obscure errors later.
231244
if plat_name not in PLAT_TO_VCVARS:
232245
raise DistutilsPlatformError("--plat-name must be one of {}"

Lib/distutils/command/bdist.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
from distutils.core import Command
88
from distutils.errors import *
9-
from distutils.util import get_platform
9+
from distutils.util import get_target_platform
1010

1111

1212
def show_formats():
@@ -29,7 +29,7 @@ class bdist(Command):
2929
"temporary directory for creating built distributions"),
3030
('plat-name=', 'p',
3131
"platform name to embed in generated filenames "
32-
"(default: %s)" % get_platform()),
32+
"(default: %s)" % get_target_platform()),
3333
('formats=', None,
3434
"formats for distribution (comma-separated list)"),
3535
('dist-dir=', 'd',
@@ -91,7 +91,7 @@ def finalize_options(self):
9191
# have to finalize 'plat_name' before 'bdist_base'
9292
if self.plat_name is None:
9393
if self.skip_build:
94-
self.plat_name = get_platform()
94+
self.plat_name = get_target_platform()
9595
else:
9696
self.plat_name = self.get_finalized_command('build').plat_name
9797

Lib/distutils/command/bdist_dumb.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import os
88
from distutils.core import Command
9-
from distutils.util import get_platform
9+
from distutils.util import get_target_platform
1010
from distutils.dir_util import remove_tree, ensure_relative
1111
from distutils.errors import *
1212
from distutils.sysconfig import get_python_version
@@ -20,7 +20,7 @@ class bdist_dumb(Command):
2020
"temporary directory for creating the distribution"),
2121
('plat-name=', 'p',
2222
"platform name to embed in generated filenames "
23-
"(default: %s)" % get_platform()),
23+
"(default: %s)" % get_target_platform()),
2424
('format=', 'f',
2525
"archive format to create (tar, gztar, bztar, xztar, "
2626
"ztar, zip)"),

Lib/distutils/command/bdist_msi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from distutils.sysconfig import get_python_version
1313
from distutils.version import StrictVersion
1414
from distutils.errors import DistutilsOptionError
15-
from distutils.util import get_platform
15+
from distutils.util import get_target_platform
1616
from distutils import log
1717
import msilib
1818
from msilib import schema, sequence, text
@@ -88,7 +88,7 @@ class bdist_msi(Command):
8888
"temporary directory for creating the distribution"),
8989
('plat-name=', 'p',
9090
"platform name to embed in generated filenames "
91-
"(default: %s)" % get_platform()),
91+
"(default: %s)" % get_target_platform()),
9292
('keep-temp', 'k',
9393
"keep the pseudo-installation tree around after " +
9494
"creating the distribution archive"),

Lib/distutils/command/bdist_wininst.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import sys, os
77
from distutils.core import Command
8-
from distutils.util import get_platform
8+
from distutils.util import get_target_platform
99
from distutils.dir_util import create_tree, remove_tree
1010
from distutils.errors import *
1111
from distutils.sysconfig import get_python_version
@@ -19,7 +19,7 @@ class bdist_wininst(Command):
1919
"temporary directory for creating the distribution"),
2020
('plat-name=', 'p',
2121
"platform name to embed in generated filenames "
22-
"(default: %s)" % get_platform()),
22+
"(default: %s)" % get_target_platform()),
2323
('keep-temp', 'k',
2424
"keep the pseudo-installation tree around after " +
2525
"creating the distribution archive"),

Lib/distutils/command/build.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys, os
66
from distutils.core import Command
77
from distutils.errors import DistutilsOptionError
8-
from distutils.util import get_platform
8+
from distutils.util import get_target_platform
99

1010

1111
def show_compilers():
@@ -33,7 +33,7 @@ class build(Command):
3333
"temporary build directory"),
3434
('plat-name=', 'p',
3535
"platform name to build for, if supported "
36-
"(default: %s)" % get_platform()),
36+
"(default: %s)" % get_target_platform()),
3737
('compiler=', 'c',
3838
"specify the compiler type"),
3939
('parallel=', 'j',
@@ -71,7 +71,7 @@ def initialize_options(self):
7171

7272
def finalize_options(self):
7373
if self.plat_name is None:
74-
self.plat_name = get_platform()
74+
self.plat_name = get_target_platform()
7575
else:
7676
# plat-name only supported for windows (other platforms are
7777
# supported via ./configure flags, if at all). Avoid misleading

Lib/distutils/command/build_ext.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from distutils.sysconfig import get_config_h_filename
1515
from distutils.dep_util import newer_group
1616
from distutils.extension import Extension
17-
from distutils.util import get_platform
17+
from distutils.util import get_platform, get_target_platform
1818
from distutils import log
1919

2020
from site import USER_BASE
@@ -60,7 +60,7 @@ class build_ext(Command):
6060
"directory for temporary files (build by-products)"),
6161
('plat-name=', 'p',
6262
"platform name to cross-compile for, if supported "
63-
"(default: %s)" % get_platform()),
63+
"(default: %s)" % get_target_platform()),
6464
('inplace', 'i',
6565
"ignore build-lib and put compiled extensions into the source " +
6666
"directory alongside your pure Python modules"),
@@ -679,6 +679,7 @@ def get_ext_filename(self, ext_name):
679679
from distutils.sysconfig import get_config_var
680680
ext_path = ext_name.split('.')
681681
ext_suffix = get_config_var('EXT_SUFFIX')
682+
682683
return os.path.join(*ext_path) + ext_suffix
683684

684685
def get_export_symbols(self, ext):

Lib/distutils/msvc9compiler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from distutils.ccompiler import CCompiler, gen_preprocess_options, \
2323
gen_lib_options
2424
from distutils import log
25-
from distutils.util import get_platform
25+
from distutils.util import get_platform, get_target_platform
2626

2727
import winreg
2828

@@ -49,7 +49,7 @@
4949
WINSDK_BASE = r"Software\Microsoft\Microsoft SDKs\Windows"
5050
NET_BASE = r"Software\Microsoft\.NETFramework"
5151

52-
# A map keyed by get_platform() return values to values accepted by
52+
# A map keyed by get_target_platform() return values to values accepted by
5353
# 'vcvarsall.bat'. Note a cross-compile may combine these (eg, 'x86_amd64' is
5454
# the param to cross-compile on x86 targeting amd64.)
5555
PLAT_TO_VCVARS = {
@@ -341,7 +341,7 @@ def initialize(self, plat_name=None):
341341
# multi-init means we would need to check platform same each time...
342342
assert not self.initialized, "don't init multiple times"
343343
if plat_name is None:
344-
plat_name = get_platform()
344+
plat_name = get_target_platform()
345345
# sanity check for platforms to prevent obscure errors later.
346346
ok_plats = 'win32', 'win-amd64'
347347
if plat_name not in ok_plats:

Lib/distutils/sysconfig.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616

1717
from .errors import DistutilsPlatformError
18+
from .util import get_platform, get_target_platform
1819

1920
# These are needed in a couple of spots, so just compute them once.
2021
PREFIX = os.path.normpath(sys.prefix)
@@ -436,7 +437,14 @@ def _init_nt():
436437
# XXX hmmm.. a normal install puts include files here
437438
g['INCLUDEPY'] = get_python_inc(plat_specific=0)
438439

439-
g['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
440+
# if cross-compiling replace hardcoded platform-specific EXT_SUFFIX
441+
# with an EXT_SUFFIX that matches the target platform
442+
if get_platform() == get_target_platform():
443+
g['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
444+
else:
445+
plat_tag = get_target_platform().replace('-', '_')
446+
g['EXT_SUFFIX'] = '.cp{0.major}{0.minor}-{1}.pyd'.format(sys.version_info, plat_tag)
447+
440448
g['EXE'] = ".exe"
441449
g['VERSION'] = get_python_version().replace(".", "")
442450
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))

Lib/distutils/tests/test_bdist.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"""Tests for distutils.command.bdist."""
22
import os
3+
import platform
34
import unittest
45
from test.support import run_unittest
56

67
from distutils.command.bdist import bdist
78
from distutils.tests import support
89

910

11+
@unittest.skipIf(platform.win32_is_iot(), "These tests don't work on Windows IoT Core or nanoserver")
1012
class BuildTestCase(support.TempdirManager,
1113
unittest.TestCase):
1214

Lib/distutils/tests/test_bdist_msi.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
"""Tests for distutils.command.bdist_msi."""
2+
import platform
23
import sys
34
import unittest
45
from test.support import run_unittest
56
from distutils.tests import support
67

78

8-
@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows')
9+
SKIP_MESSAGE = (None if sys.platform == 'win32' and not platform.win32_is_iot() else
10+
"These tests require Windows x86 or x64. Windows IoT Core and nanoserver are not supported")
11+
12+
@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)
913
class BDistMSITestCase(support.TempdirManager,
1014
support.LoggingSilencer,
1115
unittest.TestCase):

Lib/distutils/tests/test_bdist_wininst.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for distutils.command.bdist_wininst."""
2+
import platform
23
import unittest
34
from test.support import run_unittest
45

Lib/distutils/tests/test_build_ext.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import os
3+
import platform
34
from io import StringIO
45
import textwrap
56

@@ -20,7 +21,7 @@
2021
# Don't load the xx module more than once.
2122
ALREADY_TESTED = False
2223

23-
24+
@unittest.skipIf(platform.win32_is_iot(), "These tests don't work on Windows IoT Core or nanoserver")
2425
class BuildExtTestCase(TempdirManager,
2526
LoggingSilencer,
2627
unittest.TestCase):

Lib/distutils/tests/test_msvc9compiler.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for distutils.msvc9compiler."""
2+
import platform
23
import sys
34
import unittest
45
import os
@@ -90,14 +91,14 @@
9091
</dependency>
9192
</assembly>"""
9293

93-
if sys.platform=="win32":
94+
if sys.platform=="win32" and not platform.win32_is_iot():
9495
from distutils.msvccompiler import get_build_version
9596
if get_build_version()>=8.0:
9697
SKIP_MESSAGE = None
9798
else:
9899
SKIP_MESSAGE = "These tests are only for MSVC8.0 or above"
99100
else:
100-
SKIP_MESSAGE = "These tests are only for win32"
101+
SKIP_MESSAGE = "These tests are only for win32 and do not work Windows IoT Core or nanoserver"
101102

102103
@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)
103104
class msvc9compilerTestCase(support.TempdirManager,

0 commit comments

Comments
 (0)