Skip to content

Commit

Permalink
Merge pull request python#17 from paulmon/win-arm32-master
Browse files Browse the repository at this point in the history
Win arm32 master
  • Loading branch information
paulmon authored Dec 14, 2018
2 parents 1c3de54 + 91c3864 commit 964996e
Show file tree
Hide file tree
Showing 127 changed files with 10,813 additions and 133 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Doc/.env/
Include/pydtrace_probes.h
Lib/distutils/command/*.pdb
Lib/lib2to3/*.pickle
Lib/site-packages/**/*
Lib/test/data/*
Makefile
Makefile.pre
Expand Down Expand Up @@ -69,11 +70,14 @@ PCbuild/*.VC.db
PCbuild/*.VC.opendb
PCbuild/.vs/
PCbuild/amd64/
PCbuild/arm32/
PCbuild/iot/
PCbuild/obj/
PCbuild/win32/
.purify
Parser/pgen
Parser/pgen.exe
Scripts/*.exe
__pycache__
autom4te.cache
build/
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ extern "C" {

#if defined(_MSC_VER)
#include <intrin.h>
#ifndef _M_ARM
#include <immintrin.h>
#endif
#endif

/* This is modeled after the atomics interface from C1x, according to
* the draft at
Expand Down
2 changes: 1 addition & 1 deletion Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ extern "C" {
#endif

/* get and set x87 control word for VisualStudio/x86 */
#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */
#if defined(_MSC_VER) && !defined(_WIN64) && !defined(_M_ARM) /* x87 not supported in 64-bit or ARM */
#define HAVE_PY_SET_53BIT_PRECISION 1
#define _Py_SET_53BIT_PRECISION_HEADER \
unsigned int old_387controlword, new_387controlword, out_387controlword
Expand Down
2 changes: 1 addition & 1 deletion Include/pythonrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
to an 8k margin. */
#define PYOS_STACK_MARGIN 2048

#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
#if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300
/* Enable stack checking under Microsoft C */
#define USE_STACKCHECK
#endif
Expand Down
4 changes: 3 additions & 1 deletion Lib/ctypes/test/test_win32.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Windows specific tests

from ctypes import *
import unittest, sys
import unittest, sys, platform
from test import support

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

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

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

Expand Down
23 changes: 18 additions & 5 deletions Lib/distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
CompileError, LibError, LinkError
from distutils.ccompiler import CCompiler, gen_lib_options
from distutils import log
from distutils.util import get_platform
from distutils.util import get_target_platform

from itertools import count

Expand Down Expand Up @@ -88,13 +88,24 @@ def _find_vc2017():

return None, None

PLAT_SPEC_TO_RUNTIME = {
'x86' : 'x86',
'x86_amd64' : 'x64',
'x86_arm' : 'arm',
}

def _find_vcvarsall(plat_spec):
_, best_dir = _find_vc2017()
vcruntime = None
vcruntime_plat = 'x64' if 'amd64' in plat_spec else 'x86'

if plat_spec in PLAT_SPEC_TO_RUNTIME:
vcruntime_plat = PLAT_SPEC_TO_RUNTIME[plat_spec]
else:
vcruntime_plat = 'x64' if 'amd64' in plat_spec else 'x86'

if best_dir:
vcredist = os.path.join(best_dir, "..", "..", "redist", "MSVC", "**",
"Microsoft.VC141.CRT", "vcruntime140.dll")
vcruntime_plat, "Microsoft.VC141.CRT", "vcruntime140.dll")
try:
import glob
vcruntime = glob.glob(vcredist, recursive=True)[-1]
Expand Down Expand Up @@ -171,12 +182,13 @@ def _find_exe(exe, paths=None):
return fn
return exe

# A map keyed by get_platform() return values to values accepted by
# A map keyed by get_target_platform() return values to values accepted by
# 'vcvarsall.bat'. Always cross-compile from x86 to work with the
# lighter-weight MSVC installs that do not include native 64-bit tools.
PLAT_TO_VCVARS = {
'win32' : 'x86',
'win-amd64' : 'x86_amd64',
'win-arm' : 'x86_arm',
}

# A set containing the DLLs that are guaranteed to be available for
Expand Down Expand Up @@ -226,7 +238,8 @@ def initialize(self, plat_name=None):
# multi-init means we would need to check platform same each time...
assert not self.initialized, "don't init multiple times"
if plat_name is None:
plat_name = get_platform()
plat_name = get_target_platform()

# sanity check for platforms to prevent obscure errors later.
if plat_name not in PLAT_TO_VCVARS:
raise DistutilsPlatformError("--plat-name must be one of {}"
Expand Down
6 changes: 3 additions & 3 deletions Lib/distutils/command/bdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from distutils.core import Command
from distutils.errors import *
from distutils.util import get_platform
from distutils.util import get_target_platform


def show_formats():
Expand All @@ -29,7 +29,7 @@ class bdist(Command):
"temporary directory for creating built distributions"),
('plat-name=', 'p',
"platform name to embed in generated filenames "
"(default: %s)" % get_platform()),
"(default: %s)" % get_target_platform()),
('formats=', None,
"formats for distribution (comma-separated list)"),
('dist-dir=', 'd',
Expand Down Expand Up @@ -91,7 +91,7 @@ def finalize_options(self):
# have to finalize 'plat_name' before 'bdist_base'
if self.plat_name is None:
if self.skip_build:
self.plat_name = get_platform()
self.plat_name = get_target_platform()
else:
self.plat_name = self.get_finalized_command('build').plat_name

Expand Down
4 changes: 2 additions & 2 deletions Lib/distutils/command/bdist_dumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import os
from distutils.core import Command
from distutils.util import get_platform
from distutils.util import get_target_platform
from distutils.dir_util import remove_tree, ensure_relative
from distutils.errors import *
from distutils.sysconfig import get_python_version
Expand All @@ -20,7 +20,7 @@ class bdist_dumb(Command):
"temporary directory for creating the distribution"),
('plat-name=', 'p',
"platform name to embed in generated filenames "
"(default: %s)" % get_platform()),
"(default: %s)" % get_target_platform()),
('format=', 'f',
"archive format to create (tar, gztar, bztar, xztar, "
"ztar, zip)"),
Expand Down
4 changes: 2 additions & 2 deletions Lib/distutils/command/bdist_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from distutils.sysconfig import get_python_version
from distutils.version import StrictVersion
from distutils.errors import DistutilsOptionError
from distutils.util import get_platform
from distutils.util import get_target_platform
from distutils import log
import msilib
from msilib import schema, sequence, text
Expand Down Expand Up @@ -88,7 +88,7 @@ class bdist_msi(Command):
"temporary directory for creating the distribution"),
('plat-name=', 'p',
"platform name to embed in generated filenames "
"(default: %s)" % get_platform()),
"(default: %s)" % get_target_platform()),
('keep-temp', 'k',
"keep the pseudo-installation tree around after " +
"creating the distribution archive"),
Expand Down
4 changes: 2 additions & 2 deletions Lib/distutils/command/bdist_wininst.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import sys, os
from distutils.core import Command
from distutils.util import get_platform
from distutils.util import get_target_platform
from distutils.dir_util import create_tree, remove_tree
from distutils.errors import *
from distutils.sysconfig import get_python_version
Expand All @@ -19,7 +19,7 @@ class bdist_wininst(Command):
"temporary directory for creating the distribution"),
('plat-name=', 'p',
"platform name to embed in generated filenames "
"(default: %s)" % get_platform()),
"(default: %s)" % get_target_platform()),
('keep-temp', 'k',
"keep the pseudo-installation tree around after " +
"creating the distribution archive"),
Expand Down
6 changes: 3 additions & 3 deletions Lib/distutils/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys, os
from distutils.core import Command
from distutils.errors import DistutilsOptionError
from distutils.util import get_platform
from distutils.util import get_target_platform


def show_compilers():
Expand Down Expand Up @@ -33,7 +33,7 @@ class build(Command):
"temporary build directory"),
('plat-name=', 'p',
"platform name to build for, if supported "
"(default: %s)" % get_platform()),
"(default: %s)" % get_target_platform()),
('compiler=', 'c',
"specify the compiler type"),
('parallel=', 'j',
Expand Down Expand Up @@ -71,7 +71,7 @@ def initialize_options(self):

def finalize_options(self):
if self.plat_name is None:
self.plat_name = get_platform()
self.plat_name = get_target_platform()
else:
# plat-name only supported for windows (other platforms are
# supported via ./configure flags, if at all). Avoid misleading
Expand Down
5 changes: 3 additions & 2 deletions Lib/distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from distutils.sysconfig import get_config_h_filename
from distutils.dep_util import newer_group
from distutils.extension import Extension
from distutils.util import get_platform
from distutils.util import get_platform, get_target_platform
from distutils import log

from site import USER_BASE
Expand Down Expand Up @@ -60,7 +60,7 @@ class build_ext(Command):
"directory for temporary files (build by-products)"),
('plat-name=', 'p',
"platform name to cross-compile for, if supported "
"(default: %s)" % get_platform()),
"(default: %s)" % get_target_platform()),
('inplace', 'i',
"ignore build-lib and put compiled extensions into the source " +
"directory alongside your pure Python modules"),
Expand Down Expand Up @@ -679,6 +679,7 @@ def get_ext_filename(self, ext_name):
from distutils.sysconfig import get_config_var
ext_path = ext_name.split('.')
ext_suffix = get_config_var('EXT_SUFFIX')

return os.path.join(*ext_path) + ext_suffix

def get_export_symbols(self, ext):
Expand Down
6 changes: 3 additions & 3 deletions Lib/distutils/msvc9compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from distutils.ccompiler import CCompiler, gen_preprocess_options, \
gen_lib_options
from distutils import log
from distutils.util import get_platform
from distutils.util import get_platform, get_target_platform

import winreg

Expand All @@ -49,7 +49,7 @@
WINSDK_BASE = r"Software\Microsoft\Microsoft SDKs\Windows"
NET_BASE = r"Software\Microsoft\.NETFramework"

# A map keyed by get_platform() return values to values accepted by
# A map keyed by get_target_platform() return values to values accepted by
# 'vcvarsall.bat'. Note a cross-compile may combine these (eg, 'x86_amd64' is
# the param to cross-compile on x86 targeting amd64.)
PLAT_TO_VCVARS = {
Expand Down Expand Up @@ -341,7 +341,7 @@ def initialize(self, plat_name=None):
# multi-init means we would need to check platform same each time...
assert not self.initialized, "don't init multiple times"
if plat_name is None:
plat_name = get_platform()
plat_name = get_target_platform()
# sanity check for platforms to prevent obscure errors later.
ok_plats = 'win32', 'win-amd64'
if plat_name not in ok_plats:
Expand Down
10 changes: 9 additions & 1 deletion Lib/distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import sys

from .errors import DistutilsPlatformError
from .util import get_platform, get_target_platform

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

g['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
# if cross-compiling replace hardcoded platform-specific EXT_SUFFIX
# with an EXT_SUFFIX that matches the target platform
if get_platform() == get_target_platform():
g['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
else:
plat_tag = get_target_platform().replace('-', '_')
g['EXT_SUFFIX'] = '.cp{0.major}{0.minor}-{1}.pyd'.format(sys.version_info, plat_tag)

g['EXE'] = ".exe"
g['VERSION'] = get_python_version().replace(".", "")
g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
Expand Down
2 changes: 2 additions & 0 deletions Lib/distutils/tests/test_bdist.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Tests for distutils.command.bdist."""
import os
import platform
import unittest
from test.support import run_unittest

from distutils.command.bdist import bdist
from distutils.tests import support


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

Expand Down
6 changes: 5 additions & 1 deletion Lib/distutils/tests/test_bdist_msi.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"""Tests for distutils.command.bdist_msi."""
import platform
import sys
import unittest
from test.support import run_unittest
from distutils.tests import support


@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows')
SKIP_MESSAGE = (None if sys.platform == 'win32' and not platform.win32_is_iot() else
"These tests require Windows x86 or x64. Windows IoT Core and nanoserver are not supported")

@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)
class BDistMSITestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions Lib/distutils/tests/test_bdist_wininst.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for distutils.command.bdist_wininst."""
import platform
import unittest
from test.support import run_unittest

Expand Down
3 changes: 2 additions & 1 deletion Lib/distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import platform
from io import StringIO
import textwrap

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


@unittest.skipIf(platform.win32_is_iot(), "These tests don't work on Windows IoT Core or nanoserver")
class BuildExtTestCase(TempdirManager,
LoggingSilencer,
unittest.TestCase):
Expand Down
5 changes: 3 additions & 2 deletions Lib/distutils/tests/test_msvc9compiler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for distutils.msvc9compiler."""
import platform
import sys
import unittest
import os
Expand Down Expand Up @@ -90,14 +91,14 @@
</dependency>
</assembly>"""

if sys.platform=="win32":
if sys.platform=="win32" and not platform.win32_is_iot():
from distutils.msvccompiler import get_build_version
if get_build_version()>=8.0:
SKIP_MESSAGE = None
else:
SKIP_MESSAGE = "These tests are only for MSVC8.0 or above"
else:
SKIP_MESSAGE = "These tests are only for win32"
SKIP_MESSAGE = "These tests are only for win32 and do not work Windows IoT Core or nanoserver"

@unittest.skipUnless(SKIP_MESSAGE is None, SKIP_MESSAGE)
class msvc9compilerTestCase(support.TempdirManager,
Expand Down
Loading

0 comments on commit 964996e

Please sign in to comment.