From 7c20d6a2a2ee725a32b641097e6fdfdc13cbe208 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Wed, 26 Jul 2017 17:05:50 -0400 Subject: [PATCH 1/2] Fix download of python source using "https" URL --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff15a9bad..6b711dd92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,7 +176,7 @@ get_filename_component(SRC_DIR "${SRC_DIR}" ABSOLUTE) get_filename_component(_parent_dir ${CMAKE_CURRENT_BINARY_DIR} PATH) string(REGEX REPLACE "rc[1-9]$" "" _py_version_patch_no_rc ${PY_VERSION_PATCH}) set(_py_version_no_rc "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.${_py_version_patch_no_rc}") -set(_download_link "http://www.python.org/ftp/python/${_py_version_no_rc}/Python-${PY_VERSION}.tgz") +set(_download_link "https://www.python.org/ftp/python/${_py_version_no_rc}/Python-${PY_VERSION}.tgz") # Variable below represent the set of supported python version. set(_download_2.7.3_md5 "2cf641732ac23b18d139be077bd906cd") set(_download_2.7.4_md5 "592603cfaf4490a980e93ecb92bde44a") From 18176d6c5c9d74661d30076ad1bf56bba70b46ae Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Tue, 1 Aug 2017 17:36:24 -0400 Subject: [PATCH 2/2] Fix python 2.7.15 vs2015 build and introduce patch management system Thanks: Adam Rankin Thanks: Dzenan Zukic Thanks: Franklin King --- CMakeLists.txt | 6 + CTestConfig.cmake | 1 + README.rst | 6 + appveyor.yml | 6 + cmake/PythonApplyPatches.cmake | 67 +++++ cmake/libpython/CMakeLists.txt | 7 + ...ackport-Fix-13210.-Port-the-Windows-.patch | 227 +++++++++++++++ ...ackport-Fix-13210.-Port-the-Windows-.patch | 227 +++++++++++++++ ...ackport-Fix-13210.-Port-the-Windows-.patch | 227 +++++++++++++++ ...ackport-Fix-13210.-Port-the-Windows-.patch | 227 +++++++++++++++ ...ackport-Issue-22919-Windows-build-up.patch | 264 ++++++++++++++++++ ...ackport-of-Issue-23524-Replace-_PyVe.patch | 219 +++++++++++++++ patches/2.7.13/Windows-MSVC/README.rst | 53 ++++ patches/README.rst | 49 ++++ 14 files changed, 1586 insertions(+) create mode 100644 cmake/PythonApplyPatches.cmake create mode 100644 patches/2.7.13/Windows-MSVC/1600/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch create mode 100644 patches/2.7.13/Windows-MSVC/1700/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch create mode 100644 patches/2.7.13/Windows-MSVC/1800/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch create mode 100644 patches/2.7.13/Windows-MSVC/1900/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch create mode 100644 patches/2.7.13/Windows-MSVC/1900/0002-VS2015-Support-Backport-Issue-22919-Windows-build-up.patch create mode 100644 patches/2.7.13/Windows-MSVC/1900/0003-VS2015-Support-Backport-of-Issue-23524-Replace-_PyVe.patch create mode 100644 patches/2.7.13/Windows-MSVC/README.rst create mode 100644 patches/README.rst diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b711dd92..eebe861df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,6 +235,12 @@ If you already downloaded the source, you could try to re-configure this project endif() message(STATUS "SRC_DIR: ${SRC_DIR}") +# Apply patches +option(PYTHON_APPLY_PATCHES "Apply patches" ON) +if(PYTHON_APPLY_PATCHES) + include(cmake/PythonApplyPatches.cmake) +endif() + # Extract version from python source (Copied from FindPythonLibs.cmake) file(STRINGS "${SRC_DIR}/Include/patchlevel.h" python_version_str REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 6805cad95..0d499e76f 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -5,3 +5,4 @@ set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=CPython") set(CTEST_DROP_SITE_CDASH TRUE) +set(CTEST_TEST_TIMEOUT "60") diff --git a/README.rst b/README.rst index e87471fc5..41bd3f976 100644 --- a/README.rst +++ b/README.rst @@ -61,6 +61,12 @@ options on the commandline with `-DOPTION=VALUE`, or use the "ccmake" gui. PYTHON_VERSION=major.minor.patch (defaults to 3.5.2) The version of Python to build. + PYTHON_APPLY_PATCHES=ON|OFF (defaults to ON) + Apply patches required to build CPython based on the system and compiler + found when configuring the project. Note that when cross-compiling, patches + coresponding to the target system are applied. + Patches can be found in "patches" directory. + CMAKE_BUILD_TYPE=Debug|Release Build with debugging symbols or with optimisations. diff --git a/appveyor.yml b/appveyor.yml index 5e51ee99b..5c1ca7389 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,6 @@ +image: Visual Studio 2015 + branches: only: - master @@ -17,6 +19,10 @@ environment: - PY_VERSION: 3.5.1 GENERATOR: Visual Studio 12 2013 Win64 - PY_VERSION: 2.7.13 + - PY_VERSION: 2.7.13 + GENERATOR: Visual Studio 12 2013 Win64 + - PY_VERSION: 2.7.13 + GENERATOR: Visual Studio 14 2015 Win64 - PY_VERSION: 2.7.12 - PY_VERSION: 2.7.11 - PY_VERSION: 2.7.10 diff --git a/cmake/PythonApplyPatches.cmake b/cmake/PythonApplyPatches.cmake new file mode 100644 index 000000000..45c430e31 --- /dev/null +++ b/cmake/PythonApplyPatches.cmake @@ -0,0 +1,67 @@ + +set(_x86 "(x86)") # Indirection required to avoid error related to CMP0053 +find_program(PATCH_EXECUTABLE + NAME patch + PATHS "$ENV{ProgramFiles}/Git/usr/bin" + "$ENV{ProgramFiles${_x86}}/Git/usr/bin" + "$ENV{ProgramFiles}/GnuWin32/bin" + "$ENV{ProgramFiles${_x86}}/GnuWin32/bin" + "$ENV{ProgramFiles}/Git/bin" + "$ENV{ProgramFiles${_x86}}/Git/bin" + ) +if(NOT PATCH_EXECUTABLE) + message(FATAL_ERROR "Could NOT find patch (missing: PATCH_EXECUTABLE)") +endif() + +set(patches_dir "${Python_SOURCE_DIR}/patches") + +function(_apply_patches _subdir) + if(NOT EXISTS ${patches_dir}/${_subdir}) + message(STATUS "Skipping patches: Directory '${patches_dir}/${_subdir}' does not exist") + return() + endif() + file(GLOB _patches RELATIVE ${patches_dir} "${patches_dir}/${_subdir}/*.patch") + if(NOT _patches) + return() + endif() + message(STATUS "") + list(SORT _patches) + foreach(patch IN LISTS _patches) + set(msg "Applying '${patch}'") + message(STATUS "${msg}") + set(applied ${PROJECT_BINARY_DIR}/CMakeFiles/patches/${patch}.applied) + if(EXISTS ${applied}) + message(STATUS "${msg} - skipping (already applied)") + continue() + endif() + execute_process( + COMMAND ${PATCH_EXECUTABLE} --quiet -p1 -i ${patches_dir}/${patch} + WORKING_DIRECTORY ${SRC_DIR} + RESULT_VARIABLE result + ERROR_VARIABLE error + ERROR_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(result EQUAL 0) + message(STATUS "${msg} - done") + get_filename_component(_dir ${applied} DIRECTORY) + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_dir}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${applied}) + else() + message(STATUS "${msg} - failed") + message(FATAL_ERROR "${output}\n${error}") + endif() + endforeach() + message(STATUS "") +endfunction() + +# Apply patches +_apply_patches("${PY_VERSION}") +_apply_patches("${PY_VERSION}/${CMAKE_SYSTEM_NAME}") +_apply_patches("${PY_VERSION}/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}") +set(_version ${CMAKE_C_COMPILER_VERSION}) +if(MSVC) + set(_version ${MSVC_VERSION}) +endif() +_apply_patches("${PY_VERSION}/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}/${_version}") diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index 6cdf3a4d6..bcc9e3a77 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -84,6 +84,13 @@ set(OBJECT2_SOURCES ${SRC_DIR}/Objects/intobject.c ${SRC_DIR}/Objects/stringobject.c ) +if(MSVC) + if(EXISTS ${SRC_DIR}/PC/invalid_parameter_handler.c) + list(APPEND OBJECT2_SOURCES + ${SRC_DIR}/PC/invalid_parameter_handler.c + ) + endif() +endif() set(OBJECT3_SOURCES ${SRC_DIR}/Objects/accu.c diff --git a/patches/2.7.13/Windows-MSVC/1600/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch b/patches/2.7.13/Windows-MSVC/1600/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch new file mode 100644 index 000000000..e16258e15 --- /dev/null +++ b/patches/2.7.13/Windows-MSVC/1600/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch @@ -0,0 +1,227 @@ +From 4988ea4f4ce6af0b567e6a2dc2c23aaf7cc5f12d Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 31 Jul 2017 10:59:47 -0400 +Subject: [PATCH 1/3] VS2010 Support: Backport "Fix #13210. Port the Windows + build from VS2008 to VS2010." + +This commit is a partial backport of python/cpython@401f9f3. It was +originally designed to work with python-cmake-buildsystem. + +The following modules have NOT been backported: + +* Tools/msi +* Tools/buildbot +* PCBuild +--- + Lib/distutils/command/build_ext.py | 2 +- + Lib/distutils/msvc9compiler.py | 11 ++++++----- + PC/dl_nt.c | 11 ++++++++++- + PC/msvcrtmodule.c | 15 ++++++++++++++- + PC/pyconfig.h | 9 +++++++-- + Python/dynload_win.c | 8 ++++++++ + 6 files changed, 46 insertions(+), 10 deletions(-) + +diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py +index 2c68be3..f1d184b 100644 +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -193,7 +193,7 @@ class build_ext (Command): + # Append the source distribution include and library directories, + # this allows distutils on windows to work in the source tree + self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) +- if MSVC_VERSION == 9: ++ if MSVC_VERSION >= 9: + # Use the .lib files for the correct architecture + if self.plat_name == 'win32': + suffix = '' +diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py +index 33d3e51..f6de11c 100644 +--- a/Lib/distutils/msvc9compiler.py ++++ b/Lib/distutils/msvc9compiler.py +@@ -662,11 +662,12 @@ class MSVCCompiler(CCompiler) : + if mfinfo is not None: + mffilename, mfid = mfinfo + out_arg = '-outputresource:%s;%s' % (output_filename, mfid) +- try: +- self.spawn(['mt.exe', '-nologo', '-manifest', +- mffilename, out_arg]) +- except DistutilsExecError, msg: +- raise LinkError(msg) ++ if self.__version < 10: ++ try: ++ self.spawn(['mt.exe', '-nologo', '-manifest', ++ temp_manifest, out_arg]) ++ except PackagingExecError as msg: ++ raise LinkError(msg) + else: + log.debug("skipping %s (up-to-date)", output_filename) + +diff --git a/PC/dl_nt.c b/PC/dl_nt.c +index ef1ce09..5ff07fd 100644 +--- a/PC/dl_nt.c ++++ b/PC/dl_nt.c +@@ -18,7 +18,8 @@ char dllVersionBuffer[16] = ""; // a private buffer + HMODULE PyWin_DLLhModule = NULL; + const char *PyWin_DLLVersionString = dllVersionBuffer; + +-// Windows "Activation Context" work: ++#if HAVE_SXS ++// Windows "Activation Context" work. + // Our .pyd extension modules are generally built without a manifest (ie, + // those included with Python and those built with a default distutils. + // This requires we perform some "activation context" magic when loading our +@@ -29,6 +30,8 @@ const char *PyWin_DLLVersionString = dllVersionBuffer; + // As an added complication, this magic only works on XP or later - we simply + // use the existence (or not) of the relevant function pointers from kernel32. + // See bug 4566 (http://python.org/sf/4566) for more details. ++// In Visual Studio 2010, side by side assemblies are no longer used by ++// default. + + typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *); + typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *); +@@ -76,6 +79,8 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie) + OutputDebugString("Python failed to de-activate the activation context\n"); + } + ++#endif /* HAVE_SXS */ ++ + BOOL WINAPI DllMain (HANDLE hInst, + ULONG ul_reason_for_call, + LPVOID lpReserved) +@@ -87,17 +92,21 @@ BOOL WINAPI DllMain (HANDLE hInst, + // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... + LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); + ++#if HAVE_SXS + // and capture our activation context for use when loading extensions. + _LoadActCtxPointers(); + if (pfnGetCurrentActCtx && pfnAddRefActCtx) + if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) + if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext)) + OutputDebugString("Python failed to load the default activation context\n"); ++#endif + break; + + case DLL_PROCESS_DETACH: ++#if HAVE_SXS + if (pfnReleaseActCtx) + (*pfnReleaseActCtx)(PyWin_DLLhActivationContext); ++#endif + break; + } + return TRUE; +diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c +index 44c82e4..68928dd 100644 +--- a/PC/msvcrtmodule.c ++++ b/PC/msvcrtmodule.c +@@ -25,6 +25,8 @@ + #ifdef _MSC_VER + #if _MSC_VER >= 1500 && _MSC_VER < 1600 + #include ++#elif _MSC_VER >= 1600 ++#include + #endif + #endif + +@@ -398,7 +400,7 @@ PyMODINIT_FUNC + initmsvcrt(void) + { + int st; +- PyObject *d; ++ PyObject *d, *version; + PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); + if (m == NULL) + return; +@@ -412,6 +414,7 @@ initmsvcrt(void) + insertint(d, "LK_UNLCK", _LK_UNLCK); + + /* constants for the crt versions */ ++ (void)st; + #ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN + st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", + _VC_ASSEMBLY_PUBLICKEYTOKEN); +@@ -427,4 +430,14 @@ initmsvcrt(void) + __LIBRARIES_ASSEMBLY_NAME_PREFIX); + if (st < 0)return; + #endif ++ ++/* constants for the 2010 crt versions */ ++#if defined(_VC_CRT_MAJOR_VERSION) && defined (_VC_CRT_MINOR_VERSION) && defined(_VC_CRT_BUILD_VERSION) && defined(_VC_CRT_RBUILD_VERSION) ++ version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION, ++ _VC_CRT_MINOR_VERSION, ++ _VC_CRT_BUILD_VERSION, ++ _VC_CRT_RBUILD_VERSION); ++ st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version); ++ if (st < 0) return NULL; ++#endif + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index 5d1c90a..b60af1e 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -231,14 +231,19 @@ typedef int pid_t; + #define hypot _hypot + #endif + +-#endif /* _MSC_VER */ ++/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/ ++#if _MSC_VER >= 1400 && _MSC_VER < 1600 ++#define HAVE_SXS 1 ++#endif + + /* define some ANSI types that are not defined in earlier Win headers */ +-#if defined(_MSC_VER) && _MSC_VER >= 1200 ++#if _MSC_VER >= 1200 + /* This file only exists in VC 6.0 or higher */ + #include + #endif + ++#endif /* _MSC_VER */ ++ + /* ------------------------------------------------------------------------*/ + /* The Borland compiler defines __BORLANDC__ */ + /* XXX These defines are likely incomplete, but should be easy to fix. */ +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 4e5555e..8626642 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -12,8 +12,10 @@ + #include + + // "activation context" magic - see dl_nt.c... ++#if HAVE_SXS + extern ULONG_PTR _Py_ActivateActCtx(); + void _Py_DeactivateActCtx(ULONG_PTR cookie); ++#endif + + const struct filedescr _PyImport_DynLoadFiletab[] = { + #ifdef _DEBUG +@@ -176,7 +178,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + char pathbuf[260]; + LPTSTR dummy; + unsigned int old_mode; ++#if HAVE_SXS + ULONG_PTR cookie = 0; ++#endif + /* We use LoadLibraryEx so Windows looks for dependent DLLs + in directory of pathname first. However, Windows95 + can sometimes not work correctly unless the absolute +@@ -190,11 +194,15 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + sizeof(pathbuf), + pathbuf, + &dummy)) { ++#if HAVE_SXS + ULONG_PTR cookie = _Py_ActivateActCtx(); ++#endif + /* XXX This call doesn't exist in Windows CE */ + hDLL = LoadLibraryEx(pathname, NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); ++#if HAVE_SXS + _Py_DeactivateActCtx(cookie); ++#endif + } + + /* restore old error mode settings */ +-- +2.5.0 + diff --git a/patches/2.7.13/Windows-MSVC/1700/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch b/patches/2.7.13/Windows-MSVC/1700/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch new file mode 100644 index 000000000..e16258e15 --- /dev/null +++ b/patches/2.7.13/Windows-MSVC/1700/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch @@ -0,0 +1,227 @@ +From 4988ea4f4ce6af0b567e6a2dc2c23aaf7cc5f12d Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 31 Jul 2017 10:59:47 -0400 +Subject: [PATCH 1/3] VS2010 Support: Backport "Fix #13210. Port the Windows + build from VS2008 to VS2010." + +This commit is a partial backport of python/cpython@401f9f3. It was +originally designed to work with python-cmake-buildsystem. + +The following modules have NOT been backported: + +* Tools/msi +* Tools/buildbot +* PCBuild +--- + Lib/distutils/command/build_ext.py | 2 +- + Lib/distutils/msvc9compiler.py | 11 ++++++----- + PC/dl_nt.c | 11 ++++++++++- + PC/msvcrtmodule.c | 15 ++++++++++++++- + PC/pyconfig.h | 9 +++++++-- + Python/dynload_win.c | 8 ++++++++ + 6 files changed, 46 insertions(+), 10 deletions(-) + +diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py +index 2c68be3..f1d184b 100644 +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -193,7 +193,7 @@ class build_ext (Command): + # Append the source distribution include and library directories, + # this allows distutils on windows to work in the source tree + self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) +- if MSVC_VERSION == 9: ++ if MSVC_VERSION >= 9: + # Use the .lib files for the correct architecture + if self.plat_name == 'win32': + suffix = '' +diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py +index 33d3e51..f6de11c 100644 +--- a/Lib/distutils/msvc9compiler.py ++++ b/Lib/distutils/msvc9compiler.py +@@ -662,11 +662,12 @@ class MSVCCompiler(CCompiler) : + if mfinfo is not None: + mffilename, mfid = mfinfo + out_arg = '-outputresource:%s;%s' % (output_filename, mfid) +- try: +- self.spawn(['mt.exe', '-nologo', '-manifest', +- mffilename, out_arg]) +- except DistutilsExecError, msg: +- raise LinkError(msg) ++ if self.__version < 10: ++ try: ++ self.spawn(['mt.exe', '-nologo', '-manifest', ++ temp_manifest, out_arg]) ++ except PackagingExecError as msg: ++ raise LinkError(msg) + else: + log.debug("skipping %s (up-to-date)", output_filename) + +diff --git a/PC/dl_nt.c b/PC/dl_nt.c +index ef1ce09..5ff07fd 100644 +--- a/PC/dl_nt.c ++++ b/PC/dl_nt.c +@@ -18,7 +18,8 @@ char dllVersionBuffer[16] = ""; // a private buffer + HMODULE PyWin_DLLhModule = NULL; + const char *PyWin_DLLVersionString = dllVersionBuffer; + +-// Windows "Activation Context" work: ++#if HAVE_SXS ++// Windows "Activation Context" work. + // Our .pyd extension modules are generally built without a manifest (ie, + // those included with Python and those built with a default distutils. + // This requires we perform some "activation context" magic when loading our +@@ -29,6 +30,8 @@ const char *PyWin_DLLVersionString = dllVersionBuffer; + // As an added complication, this magic only works on XP or later - we simply + // use the existence (or not) of the relevant function pointers from kernel32. + // See bug 4566 (http://python.org/sf/4566) for more details. ++// In Visual Studio 2010, side by side assemblies are no longer used by ++// default. + + typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *); + typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *); +@@ -76,6 +79,8 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie) + OutputDebugString("Python failed to de-activate the activation context\n"); + } + ++#endif /* HAVE_SXS */ ++ + BOOL WINAPI DllMain (HANDLE hInst, + ULONG ul_reason_for_call, + LPVOID lpReserved) +@@ -87,17 +92,21 @@ BOOL WINAPI DllMain (HANDLE hInst, + // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... + LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); + ++#if HAVE_SXS + // and capture our activation context for use when loading extensions. + _LoadActCtxPointers(); + if (pfnGetCurrentActCtx && pfnAddRefActCtx) + if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) + if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext)) + OutputDebugString("Python failed to load the default activation context\n"); ++#endif + break; + + case DLL_PROCESS_DETACH: ++#if HAVE_SXS + if (pfnReleaseActCtx) + (*pfnReleaseActCtx)(PyWin_DLLhActivationContext); ++#endif + break; + } + return TRUE; +diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c +index 44c82e4..68928dd 100644 +--- a/PC/msvcrtmodule.c ++++ b/PC/msvcrtmodule.c +@@ -25,6 +25,8 @@ + #ifdef _MSC_VER + #if _MSC_VER >= 1500 && _MSC_VER < 1600 + #include ++#elif _MSC_VER >= 1600 ++#include + #endif + #endif + +@@ -398,7 +400,7 @@ PyMODINIT_FUNC + initmsvcrt(void) + { + int st; +- PyObject *d; ++ PyObject *d, *version; + PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); + if (m == NULL) + return; +@@ -412,6 +414,7 @@ initmsvcrt(void) + insertint(d, "LK_UNLCK", _LK_UNLCK); + + /* constants for the crt versions */ ++ (void)st; + #ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN + st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", + _VC_ASSEMBLY_PUBLICKEYTOKEN); +@@ -427,4 +430,14 @@ initmsvcrt(void) + __LIBRARIES_ASSEMBLY_NAME_PREFIX); + if (st < 0)return; + #endif ++ ++/* constants for the 2010 crt versions */ ++#if defined(_VC_CRT_MAJOR_VERSION) && defined (_VC_CRT_MINOR_VERSION) && defined(_VC_CRT_BUILD_VERSION) && defined(_VC_CRT_RBUILD_VERSION) ++ version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION, ++ _VC_CRT_MINOR_VERSION, ++ _VC_CRT_BUILD_VERSION, ++ _VC_CRT_RBUILD_VERSION); ++ st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version); ++ if (st < 0) return NULL; ++#endif + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index 5d1c90a..b60af1e 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -231,14 +231,19 @@ typedef int pid_t; + #define hypot _hypot + #endif + +-#endif /* _MSC_VER */ ++/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/ ++#if _MSC_VER >= 1400 && _MSC_VER < 1600 ++#define HAVE_SXS 1 ++#endif + + /* define some ANSI types that are not defined in earlier Win headers */ +-#if defined(_MSC_VER) && _MSC_VER >= 1200 ++#if _MSC_VER >= 1200 + /* This file only exists in VC 6.0 or higher */ + #include + #endif + ++#endif /* _MSC_VER */ ++ + /* ------------------------------------------------------------------------*/ + /* The Borland compiler defines __BORLANDC__ */ + /* XXX These defines are likely incomplete, but should be easy to fix. */ +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 4e5555e..8626642 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -12,8 +12,10 @@ + #include + + // "activation context" magic - see dl_nt.c... ++#if HAVE_SXS + extern ULONG_PTR _Py_ActivateActCtx(); + void _Py_DeactivateActCtx(ULONG_PTR cookie); ++#endif + + const struct filedescr _PyImport_DynLoadFiletab[] = { + #ifdef _DEBUG +@@ -176,7 +178,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + char pathbuf[260]; + LPTSTR dummy; + unsigned int old_mode; ++#if HAVE_SXS + ULONG_PTR cookie = 0; ++#endif + /* We use LoadLibraryEx so Windows looks for dependent DLLs + in directory of pathname first. However, Windows95 + can sometimes not work correctly unless the absolute +@@ -190,11 +194,15 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + sizeof(pathbuf), + pathbuf, + &dummy)) { ++#if HAVE_SXS + ULONG_PTR cookie = _Py_ActivateActCtx(); ++#endif + /* XXX This call doesn't exist in Windows CE */ + hDLL = LoadLibraryEx(pathname, NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); ++#if HAVE_SXS + _Py_DeactivateActCtx(cookie); ++#endif + } + + /* restore old error mode settings */ +-- +2.5.0 + diff --git a/patches/2.7.13/Windows-MSVC/1800/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch b/patches/2.7.13/Windows-MSVC/1800/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch new file mode 100644 index 000000000..e16258e15 --- /dev/null +++ b/patches/2.7.13/Windows-MSVC/1800/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch @@ -0,0 +1,227 @@ +From 4988ea4f4ce6af0b567e6a2dc2c23aaf7cc5f12d Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 31 Jul 2017 10:59:47 -0400 +Subject: [PATCH 1/3] VS2010 Support: Backport "Fix #13210. Port the Windows + build from VS2008 to VS2010." + +This commit is a partial backport of python/cpython@401f9f3. It was +originally designed to work with python-cmake-buildsystem. + +The following modules have NOT been backported: + +* Tools/msi +* Tools/buildbot +* PCBuild +--- + Lib/distutils/command/build_ext.py | 2 +- + Lib/distutils/msvc9compiler.py | 11 ++++++----- + PC/dl_nt.c | 11 ++++++++++- + PC/msvcrtmodule.c | 15 ++++++++++++++- + PC/pyconfig.h | 9 +++++++-- + Python/dynload_win.c | 8 ++++++++ + 6 files changed, 46 insertions(+), 10 deletions(-) + +diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py +index 2c68be3..f1d184b 100644 +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -193,7 +193,7 @@ class build_ext (Command): + # Append the source distribution include and library directories, + # this allows distutils on windows to work in the source tree + self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) +- if MSVC_VERSION == 9: ++ if MSVC_VERSION >= 9: + # Use the .lib files for the correct architecture + if self.plat_name == 'win32': + suffix = '' +diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py +index 33d3e51..f6de11c 100644 +--- a/Lib/distutils/msvc9compiler.py ++++ b/Lib/distutils/msvc9compiler.py +@@ -662,11 +662,12 @@ class MSVCCompiler(CCompiler) : + if mfinfo is not None: + mffilename, mfid = mfinfo + out_arg = '-outputresource:%s;%s' % (output_filename, mfid) +- try: +- self.spawn(['mt.exe', '-nologo', '-manifest', +- mffilename, out_arg]) +- except DistutilsExecError, msg: +- raise LinkError(msg) ++ if self.__version < 10: ++ try: ++ self.spawn(['mt.exe', '-nologo', '-manifest', ++ temp_manifest, out_arg]) ++ except PackagingExecError as msg: ++ raise LinkError(msg) + else: + log.debug("skipping %s (up-to-date)", output_filename) + +diff --git a/PC/dl_nt.c b/PC/dl_nt.c +index ef1ce09..5ff07fd 100644 +--- a/PC/dl_nt.c ++++ b/PC/dl_nt.c +@@ -18,7 +18,8 @@ char dllVersionBuffer[16] = ""; // a private buffer + HMODULE PyWin_DLLhModule = NULL; + const char *PyWin_DLLVersionString = dllVersionBuffer; + +-// Windows "Activation Context" work: ++#if HAVE_SXS ++// Windows "Activation Context" work. + // Our .pyd extension modules are generally built without a manifest (ie, + // those included with Python and those built with a default distutils. + // This requires we perform some "activation context" magic when loading our +@@ -29,6 +30,8 @@ const char *PyWin_DLLVersionString = dllVersionBuffer; + // As an added complication, this magic only works on XP or later - we simply + // use the existence (or not) of the relevant function pointers from kernel32. + // See bug 4566 (http://python.org/sf/4566) for more details. ++// In Visual Studio 2010, side by side assemblies are no longer used by ++// default. + + typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *); + typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *); +@@ -76,6 +79,8 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie) + OutputDebugString("Python failed to de-activate the activation context\n"); + } + ++#endif /* HAVE_SXS */ ++ + BOOL WINAPI DllMain (HANDLE hInst, + ULONG ul_reason_for_call, + LPVOID lpReserved) +@@ -87,17 +92,21 @@ BOOL WINAPI DllMain (HANDLE hInst, + // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... + LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); + ++#if HAVE_SXS + // and capture our activation context for use when loading extensions. + _LoadActCtxPointers(); + if (pfnGetCurrentActCtx && pfnAddRefActCtx) + if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) + if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext)) + OutputDebugString("Python failed to load the default activation context\n"); ++#endif + break; + + case DLL_PROCESS_DETACH: ++#if HAVE_SXS + if (pfnReleaseActCtx) + (*pfnReleaseActCtx)(PyWin_DLLhActivationContext); ++#endif + break; + } + return TRUE; +diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c +index 44c82e4..68928dd 100644 +--- a/PC/msvcrtmodule.c ++++ b/PC/msvcrtmodule.c +@@ -25,6 +25,8 @@ + #ifdef _MSC_VER + #if _MSC_VER >= 1500 && _MSC_VER < 1600 + #include ++#elif _MSC_VER >= 1600 ++#include + #endif + #endif + +@@ -398,7 +400,7 @@ PyMODINIT_FUNC + initmsvcrt(void) + { + int st; +- PyObject *d; ++ PyObject *d, *version; + PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); + if (m == NULL) + return; +@@ -412,6 +414,7 @@ initmsvcrt(void) + insertint(d, "LK_UNLCK", _LK_UNLCK); + + /* constants for the crt versions */ ++ (void)st; + #ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN + st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", + _VC_ASSEMBLY_PUBLICKEYTOKEN); +@@ -427,4 +430,14 @@ initmsvcrt(void) + __LIBRARIES_ASSEMBLY_NAME_PREFIX); + if (st < 0)return; + #endif ++ ++/* constants for the 2010 crt versions */ ++#if defined(_VC_CRT_MAJOR_VERSION) && defined (_VC_CRT_MINOR_VERSION) && defined(_VC_CRT_BUILD_VERSION) && defined(_VC_CRT_RBUILD_VERSION) ++ version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION, ++ _VC_CRT_MINOR_VERSION, ++ _VC_CRT_BUILD_VERSION, ++ _VC_CRT_RBUILD_VERSION); ++ st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version); ++ if (st < 0) return NULL; ++#endif + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index 5d1c90a..b60af1e 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -231,14 +231,19 @@ typedef int pid_t; + #define hypot _hypot + #endif + +-#endif /* _MSC_VER */ ++/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/ ++#if _MSC_VER >= 1400 && _MSC_VER < 1600 ++#define HAVE_SXS 1 ++#endif + + /* define some ANSI types that are not defined in earlier Win headers */ +-#if defined(_MSC_VER) && _MSC_VER >= 1200 ++#if _MSC_VER >= 1200 + /* This file only exists in VC 6.0 or higher */ + #include + #endif + ++#endif /* _MSC_VER */ ++ + /* ------------------------------------------------------------------------*/ + /* The Borland compiler defines __BORLANDC__ */ + /* XXX These defines are likely incomplete, but should be easy to fix. */ +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 4e5555e..8626642 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -12,8 +12,10 @@ + #include + + // "activation context" magic - see dl_nt.c... ++#if HAVE_SXS + extern ULONG_PTR _Py_ActivateActCtx(); + void _Py_DeactivateActCtx(ULONG_PTR cookie); ++#endif + + const struct filedescr _PyImport_DynLoadFiletab[] = { + #ifdef _DEBUG +@@ -176,7 +178,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + char pathbuf[260]; + LPTSTR dummy; + unsigned int old_mode; ++#if HAVE_SXS + ULONG_PTR cookie = 0; ++#endif + /* We use LoadLibraryEx so Windows looks for dependent DLLs + in directory of pathname first. However, Windows95 + can sometimes not work correctly unless the absolute +@@ -190,11 +194,15 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + sizeof(pathbuf), + pathbuf, + &dummy)) { ++#if HAVE_SXS + ULONG_PTR cookie = _Py_ActivateActCtx(); ++#endif + /* XXX This call doesn't exist in Windows CE */ + hDLL = LoadLibraryEx(pathname, NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); ++#if HAVE_SXS + _Py_DeactivateActCtx(cookie); ++#endif + } + + /* restore old error mode settings */ +-- +2.5.0 + diff --git a/patches/2.7.13/Windows-MSVC/1900/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch b/patches/2.7.13/Windows-MSVC/1900/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch new file mode 100644 index 000000000..e16258e15 --- /dev/null +++ b/patches/2.7.13/Windows-MSVC/1900/0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch @@ -0,0 +1,227 @@ +From 4988ea4f4ce6af0b567e6a2dc2c23aaf7cc5f12d Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 31 Jul 2017 10:59:47 -0400 +Subject: [PATCH 1/3] VS2010 Support: Backport "Fix #13210. Port the Windows + build from VS2008 to VS2010." + +This commit is a partial backport of python/cpython@401f9f3. It was +originally designed to work with python-cmake-buildsystem. + +The following modules have NOT been backported: + +* Tools/msi +* Tools/buildbot +* PCBuild +--- + Lib/distutils/command/build_ext.py | 2 +- + Lib/distutils/msvc9compiler.py | 11 ++++++----- + PC/dl_nt.c | 11 ++++++++++- + PC/msvcrtmodule.c | 15 ++++++++++++++- + PC/pyconfig.h | 9 +++++++-- + Python/dynload_win.c | 8 ++++++++ + 6 files changed, 46 insertions(+), 10 deletions(-) + +diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py +index 2c68be3..f1d184b 100644 +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -193,7 +193,7 @@ class build_ext (Command): + # Append the source distribution include and library directories, + # this allows distutils on windows to work in the source tree + self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) +- if MSVC_VERSION == 9: ++ if MSVC_VERSION >= 9: + # Use the .lib files for the correct architecture + if self.plat_name == 'win32': + suffix = '' +diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py +index 33d3e51..f6de11c 100644 +--- a/Lib/distutils/msvc9compiler.py ++++ b/Lib/distutils/msvc9compiler.py +@@ -662,11 +662,12 @@ class MSVCCompiler(CCompiler) : + if mfinfo is not None: + mffilename, mfid = mfinfo + out_arg = '-outputresource:%s;%s' % (output_filename, mfid) +- try: +- self.spawn(['mt.exe', '-nologo', '-manifest', +- mffilename, out_arg]) +- except DistutilsExecError, msg: +- raise LinkError(msg) ++ if self.__version < 10: ++ try: ++ self.spawn(['mt.exe', '-nologo', '-manifest', ++ temp_manifest, out_arg]) ++ except PackagingExecError as msg: ++ raise LinkError(msg) + else: + log.debug("skipping %s (up-to-date)", output_filename) + +diff --git a/PC/dl_nt.c b/PC/dl_nt.c +index ef1ce09..5ff07fd 100644 +--- a/PC/dl_nt.c ++++ b/PC/dl_nt.c +@@ -18,7 +18,8 @@ char dllVersionBuffer[16] = ""; // a private buffer + HMODULE PyWin_DLLhModule = NULL; + const char *PyWin_DLLVersionString = dllVersionBuffer; + +-// Windows "Activation Context" work: ++#if HAVE_SXS ++// Windows "Activation Context" work. + // Our .pyd extension modules are generally built without a manifest (ie, + // those included with Python and those built with a default distutils. + // This requires we perform some "activation context" magic when loading our +@@ -29,6 +30,8 @@ const char *PyWin_DLLVersionString = dllVersionBuffer; + // As an added complication, this magic only works on XP or later - we simply + // use the existence (or not) of the relevant function pointers from kernel32. + // See bug 4566 (http://python.org/sf/4566) for more details. ++// In Visual Studio 2010, side by side assemblies are no longer used by ++// default. + + typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *); + typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *); +@@ -76,6 +79,8 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie) + OutputDebugString("Python failed to de-activate the activation context\n"); + } + ++#endif /* HAVE_SXS */ ++ + BOOL WINAPI DllMain (HANDLE hInst, + ULONG ul_reason_for_call, + LPVOID lpReserved) +@@ -87,17 +92,21 @@ BOOL WINAPI DllMain (HANDLE hInst, + // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... + LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); + ++#if HAVE_SXS + // and capture our activation context for use when loading extensions. + _LoadActCtxPointers(); + if (pfnGetCurrentActCtx && pfnAddRefActCtx) + if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) + if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext)) + OutputDebugString("Python failed to load the default activation context\n"); ++#endif + break; + + case DLL_PROCESS_DETACH: ++#if HAVE_SXS + if (pfnReleaseActCtx) + (*pfnReleaseActCtx)(PyWin_DLLhActivationContext); ++#endif + break; + } + return TRUE; +diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c +index 44c82e4..68928dd 100644 +--- a/PC/msvcrtmodule.c ++++ b/PC/msvcrtmodule.c +@@ -25,6 +25,8 @@ + #ifdef _MSC_VER + #if _MSC_VER >= 1500 && _MSC_VER < 1600 + #include ++#elif _MSC_VER >= 1600 ++#include + #endif + #endif + +@@ -398,7 +400,7 @@ PyMODINIT_FUNC + initmsvcrt(void) + { + int st; +- PyObject *d; ++ PyObject *d, *version; + PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); + if (m == NULL) + return; +@@ -412,6 +414,7 @@ initmsvcrt(void) + insertint(d, "LK_UNLCK", _LK_UNLCK); + + /* constants for the crt versions */ ++ (void)st; + #ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN + st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", + _VC_ASSEMBLY_PUBLICKEYTOKEN); +@@ -427,4 +430,14 @@ initmsvcrt(void) + __LIBRARIES_ASSEMBLY_NAME_PREFIX); + if (st < 0)return; + #endif ++ ++/* constants for the 2010 crt versions */ ++#if defined(_VC_CRT_MAJOR_VERSION) && defined (_VC_CRT_MINOR_VERSION) && defined(_VC_CRT_BUILD_VERSION) && defined(_VC_CRT_RBUILD_VERSION) ++ version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION, ++ _VC_CRT_MINOR_VERSION, ++ _VC_CRT_BUILD_VERSION, ++ _VC_CRT_RBUILD_VERSION); ++ st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version); ++ if (st < 0) return NULL; ++#endif + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index 5d1c90a..b60af1e 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -231,14 +231,19 @@ typedef int pid_t; + #define hypot _hypot + #endif + +-#endif /* _MSC_VER */ ++/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/ ++#if _MSC_VER >= 1400 && _MSC_VER < 1600 ++#define HAVE_SXS 1 ++#endif + + /* define some ANSI types that are not defined in earlier Win headers */ +-#if defined(_MSC_VER) && _MSC_VER >= 1200 ++#if _MSC_VER >= 1200 + /* This file only exists in VC 6.0 or higher */ + #include + #endif + ++#endif /* _MSC_VER */ ++ + /* ------------------------------------------------------------------------*/ + /* The Borland compiler defines __BORLANDC__ */ + /* XXX These defines are likely incomplete, but should be easy to fix. */ +diff --git a/Python/dynload_win.c b/Python/dynload_win.c +index 4e5555e..8626642 100644 +--- a/Python/dynload_win.c ++++ b/Python/dynload_win.c +@@ -12,8 +12,10 @@ + #include + + // "activation context" magic - see dl_nt.c... ++#if HAVE_SXS + extern ULONG_PTR _Py_ActivateActCtx(); + void _Py_DeactivateActCtx(ULONG_PTR cookie); ++#endif + + const struct filedescr _PyImport_DynLoadFiletab[] = { + #ifdef _DEBUG +@@ -176,7 +178,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + char pathbuf[260]; + LPTSTR dummy; + unsigned int old_mode; ++#if HAVE_SXS + ULONG_PTR cookie = 0; ++#endif + /* We use LoadLibraryEx so Windows looks for dependent DLLs + in directory of pathname first. However, Windows95 + can sometimes not work correctly unless the absolute +@@ -190,11 +194,15 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, + sizeof(pathbuf), + pathbuf, + &dummy)) { ++#if HAVE_SXS + ULONG_PTR cookie = _Py_ActivateActCtx(); ++#endif + /* XXX This call doesn't exist in Windows CE */ + hDLL = LoadLibraryEx(pathname, NULL, + LOAD_WITH_ALTERED_SEARCH_PATH); ++#if HAVE_SXS + _Py_DeactivateActCtx(cookie); ++#endif + } + + /* restore old error mode settings */ +-- +2.5.0 + diff --git a/patches/2.7.13/Windows-MSVC/1900/0002-VS2015-Support-Backport-Issue-22919-Windows-build-up.patch b/patches/2.7.13/Windows-MSVC/1900/0002-VS2015-Support-Backport-Issue-22919-Windows-build-up.patch new file mode 100644 index 000000000..a75821abb --- /dev/null +++ b/patches/2.7.13/Windows-MSVC/1900/0002-VS2015-Support-Backport-Issue-22919-Windows-build-up.patch @@ -0,0 +1,264 @@ +From e6a1f39d2d876bbfc8b02e628dfd1d0fef4a0651 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Tue, 1 Aug 2017 15:40:29 -0400 +Subject: [PATCH 2/3] VS2015 Support: Backport "Issue #22919: Windows build + updated to support VC 14.0 (Visual Studio 2015), which will be used for the + official 3.5 release." + +This commit is a partial backport of python/cpython@65e4cb1. It was +originally designed to work with python-cmake-buildsystem. + +This patch do not backport the define "timezone" as "_timezone" as it was done in Python 3.x. +Keeping "timezone" is required in Python 2.7.x to avoid the following build issue +``error C2032: '__timezone': function cannot be member of struct '__timeb64'`` +associated with `sys/timeb.h`. The need for `sys/timeb.h` was removed in Python 3.x in python/cpython@6fc4ade and python/cpython@0011124 +but is still used in Python 2.7.x. + +The following modules have NOT been backported: + +* Lib/distutils/sysconfig +* Modules/socketmodule.c .... : Not required since changes related to WSA have been introduced in Python 3.x (see python/cpython@6b4883d) +* Tools/buildbot +* PCBuild +--- + Lib/ctypes/util.py | 6 +++++- + Lib/distutils/command/build_ext.py | 2 +- + Lib/distutils/msvc9compiler.py | 3 +++ + Lib/distutils/msvccompiler.py | 3 +++ + Modules/posixmodule.c | 22 ++++++++++++++++++++-- + Modules/timemodule.c | 4 ++-- + PC/bdist_wininst/install.c | 29 ++++++----------------------- + PC/pyconfig.h | 7 +++++++ + 8 files changed, 47 insertions(+), 29 deletions(-) + +diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py +index ab10ec5..a163239 100644 +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -19,6 +19,8 @@ if os.name == "nt": + i = i + len(prefix) + s, rest = sys.version[i:].split(" ", 1) + majorVersion = int(s[:-2]) - 6 ++ if majorVersion >= 13: ++ majorVersion += 1 + minorVersion = int(s[2:3]) / 10.0 + # I don't think paths are affected by minor version in version 6 + if majorVersion == 6: +@@ -36,8 +38,10 @@ if os.name == "nt": + return None + if version <= 6: + clibname = 'msvcrt' +- else: ++ elif version <= 13: + clibname = 'msvcr%d' % (version * 10) ++ else: ++ clibname = 'appcrt%d' % (version * 10) + + # If python was built with in debug mode + import imp +diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py +index f1d184b..0851690 100644 +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -196,7 +196,7 @@ class build_ext (Command): + if MSVC_VERSION >= 9: + # Use the .lib files for the correct architecture + if self.plat_name == 'win32': +- suffix = '' ++ suffix = 'win32' + else: + # win-amd64 or win-ia64 + suffix = self.plat_name[4:] +diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py +index f6de11c..ee61ac2 100644 +--- a/Lib/distutils/msvc9compiler.py ++++ b/Lib/distutils/msvc9compiler.py +@@ -182,6 +182,9 @@ def get_build_version(): + i = i + len(prefix) + s, rest = sys.version[i:].split(" ", 1) + majorVersion = int(s[:-2]) - 6 ++ if majorVersion >= 13: ++ # v13 was skipped and should be v14 ++ majorVersion += 1 + minorVersion = int(s[2:3]) / 10.0 + # I don't think paths are affected by minor version in version 6 + if majorVersion == 6: +diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py +index 0e69fd3..77025c6 100644 +--- a/Lib/distutils/msvccompiler.py ++++ b/Lib/distutils/msvccompiler.py +@@ -164,6 +164,9 @@ def get_build_version(): + i = i + len(prefix) + s, rest = sys.version[i:].split(" ", 1) + majorVersion = int(s[:-2]) - 6 ++ if majorVersion >= 13: ++ # v13 was skipped and should be v14 ++ majorVersion += 1 + minorVersion = int(s[2:3]) / 10.0 + # I don't think paths are affected by minor version in version 6 + if majorVersion == 6: +diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index e73805f..90d5318 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -553,15 +553,33 @@ _PyInt_FromDev(PY_LONG_LONG v) + /* The actual size of the structure is determined at runtime. + * Only the first items must be present. + */ ++ ++#if _MSC_VER >= 1900 ++ ++typedef struct { ++ CRITICAL_SECTION lock; ++ intptr_t osfhnd; ++ __int64 startpos; ++ char osfile; ++} my_ioinfo; ++ ++#define IOINFO_L2E 6 ++#define IOINFO_ARRAYS 128 ++ ++#else ++ + typedef struct { + intptr_t osfhnd; + char osfile; + } my_ioinfo; + +-extern __declspec(dllimport) char * __pioinfo[]; + #define IOINFO_L2E 5 +-#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) + #define IOINFO_ARRAYS 64 ++ ++#endif ++ ++extern __declspec(dllimport) char * __pioinfo[]; ++#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) + #define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS) + #define FOPEN 0x01 + #define _NO_CONSOLE_FILENO (intptr_t)-2 +diff --git a/Modules/timemodule.c b/Modules/timemodule.c +index 12c43b0..db190b8 100644 +--- a/Modules/timemodule.c ++++ b/Modules/timemodule.c +@@ -710,7 +710,7 @@ inittimezone(PyObject *m) { + #ifdef PYOS_OS2 + PyModule_AddIntConstant(m, "timezone", _timezone); + #else /* !PYOS_OS2 */ +- PyModule_AddIntConstant(m, "timezone", timezone); ++ PyModule_AddIntConstant(m, "timezone", _timezone); + #endif /* PYOS_OS2 */ + #ifdef HAVE_ALTZONE + PyModule_AddIntConstant(m, "altzone", altzone); +@@ -718,7 +718,7 @@ inittimezone(PyObject *m) { + #ifdef PYOS_OS2 + PyModule_AddIntConstant(m, "altzone", _timezone-3600); + #else /* !PYOS_OS2 */ +- PyModule_AddIntConstant(m, "altzone", timezone-3600); ++ PyModule_AddIntConstant(m, "altzone", _timezone-3600); + #endif /* PYOS_OS2 */ + #endif + PyModule_AddIntConstant(m, "daylight", daylight); +diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c +index f1cc7fe..5b11dcc 100644 +--- a/PC/bdist_wininst/install.c ++++ b/PC/bdist_wininst/install.c +@@ -1184,7 +1184,7 @@ static void CenterWindow(HWND hwnd) + + #include + +-BOOL CALLBACK ++INT_PTR CALLBACK + IntroDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + { + LPNMHDR lpnm; +@@ -1533,7 +1533,7 @@ SCHEME *GetScheme(int major, int minor) + return old_scheme; + } + +-BOOL CALLBACK ++INT_PTR CALLBACK + SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + { + LPNMHDR lpnm; +@@ -1835,7 +1835,7 @@ static void CloseLogfile(void) + fclose(logfile); + } + +-BOOL CALLBACK ++INT_PTR CALLBACK + InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + { + LPNMHDR lpnm; +@@ -1990,7 +1990,7 @@ InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + } + + +-BOOL CALLBACK ++INT_PTR CALLBACK + FinishedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + { + LPNMHDR lpnm; +@@ -2166,23 +2166,6 @@ BOOL NeedAutoUAC() + return TRUE; + } + +-// Returns TRUE if the platform supports UAC. +-BOOL PlatformSupportsUAC() +-{ +- // Note that win2k does seem to support ShellExecute with 'runas', +- // but does *not* support IsUserAnAdmin - so we just pretend things +- // only work on XP and later. +- BOOL bIsWindowsXPorLater; +- OSVERSIONINFO winverinfo; +- winverinfo.dwOSVersionInfoSize = sizeof(winverinfo); +- if (!GetVersionEx(&winverinfo)) +- return FALSE; // something bad has gone wrong +- bIsWindowsXPorLater = +- ( (winverinfo.dwMajorVersion > 5) || +- ( (winverinfo.dwMajorVersion == 5) && (winverinfo.dwMinorVersion >= 1) )); +- return bIsWindowsXPorLater; +-} +- + // Spawn ourself as an elevated application. On failure, a message is + // displayed to the user - but this app will always terminate, even + // on error. +@@ -2238,7 +2221,7 @@ int DoInstall(void) + + // See if we need to do the Vista UAC magic. + if (strcmp(user_access_control, "force")==0) { +- if (PlatformSupportsUAC() && !MyIsUserAnAdmin()) { ++ if (!MyIsUserAnAdmin()) { + SpawnUAC(); + return 0; + } +@@ -2246,7 +2229,7 @@ int DoInstall(void) + } else if (strcmp(user_access_control, "auto")==0) { + // Check if it looks like we need UAC control, based + // on how Python itself was installed. +- if (PlatformSupportsUAC() && !MyIsUserAnAdmin() && NeedAutoUAC()) { ++ if (!MyIsUserAnAdmin() && NeedAutoUAC()) { + SpawnUAC(); + return 0; + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index b60af1e..b517146 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -231,6 +231,13 @@ typedef int pid_t; + #define hypot _hypot + #endif + ++/* VS 2015 defines these names with a leading underscore */ ++#if _MSC_VER >= 1900 ++// #define timezone _timezone ++#define daylight _daylight ++#define tzname _tzname ++#endif ++ + /* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/ + #if _MSC_VER >= 1400 && _MSC_VER < 1600 + #define HAVE_SXS 1 +-- +2.5.0 + diff --git a/patches/2.7.13/Windows-MSVC/1900/0003-VS2015-Support-Backport-of-Issue-23524-Replace-_PyVe.patch b/patches/2.7.13/Windows-MSVC/1900/0003-VS2015-Support-Backport-of-Issue-23524-Replace-_PyVe.patch new file mode 100644 index 000000000..da8990378 --- /dev/null +++ b/patches/2.7.13/Windows-MSVC/1900/0003-VS2015-Support-Backport-of-Issue-23524-Replace-_PyVe.patch @@ -0,0 +1,219 @@ +From 00164b4a9821e82f513183035587bea9243a7d5e Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Tue, 1 Aug 2017 14:13:24 -0400 +Subject: [PATCH 3/3] VS2015 Support: Backport of "Issue #23524: Replace + _PyVerify_fd function with calling + _set_thread_local_invalid_parameter_handler on every thread." + +This commit is a partial backport of python/cpython@d81431f. It was +originally designed to work with python-cmake-buildsystem. + +Implementation of "_PyVerify_fd" in "Python/fileutils.c" found only in +Python 3.x has been copied into "Modules/posixmodule.c" + +The following modules have NOT been backported: + +* PCbuild +--- + Modules/_io/fileio.c | 2 +- + Modules/posixmodule.c | 54 +++++++++++++++++++++++------------------- + PC/invalid_parameter_handler.c | 22 +++++++++++++++++ + Python/pystate.c | 12 ++++++++++ + 4 files changed, 64 insertions(+), 26 deletions(-) + create mode 100644 PC/invalid_parameter_handler.c + +diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c +index 0678ef8..8d0383c 100644 +--- a/Modules/_io/fileio.c ++++ b/Modules/_io/fileio.c +@@ -159,7 +159,7 @@ check_fd(int fd) + { + #if defined(HAVE_FSTAT) + struct stat buf; +- if (!_PyVerify_fd(fd) || (fstat(fd, &buf) < 0 && errno == EBADF)) { ++ if (fstat(fd, &buf) < 0 && errno == EBADF) { + PyObject *exc; + char *msg = strerror(EBADF); + exc = PyObject_CallFunction(PyExc_OSError, "(is)", +diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c +index 90d5318..6a180a0 100644 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -272,6 +272,7 @@ extern int lstat(const char *, struct stat *); + #include "osdefs.h" + #include + #include ++#include + #include /* for ShellExecute() */ + #define popen _popen + #define pclose _pclose +@@ -528,8 +529,28 @@ _PyInt_FromDev(PY_LONG_LONG v) + # define _PyInt_FromDev PyInt_FromLong + #endif + ++#ifdef _MSC_VER ++#if _MSC_VER >= 1900 ++ ++/* This function lets the Windows CRT validate the file handle without ++ terminating the process if it's invalid. */ ++int ++_PyVerify_fd(int fd) ++{ ++ intptr_t osh; ++ /* Fast check for the only condition we know */ ++ if (fd < 0) { ++ _set_errno(EBADF); ++ return 0; ++ } ++ osh = _get_osfhandle(fd); ++ return osh != (intptr_t)-1; ++} ++ ++#define _PyVerify_fd_dup2(fd1, fd2) (_PyVerify_fd(fd1) && (fd2) >= 0) ++ ++#elif _MSC_VER >= 1400 + +-#if defined _MSC_VER && _MSC_VER >= 1400 + /* Microsoft CRT in VS2005 and higher will verify that a filehandle is + * valid and raise an assertion if it isn't. + * Normally, an invalid fd is likely to be a C program error and therefore +@@ -554,35 +575,18 @@ _PyInt_FromDev(PY_LONG_LONG v) + * Only the first items must be present. + */ + +-#if _MSC_VER >= 1900 +- +-typedef struct { +- CRITICAL_SECTION lock; +- intptr_t osfhnd; +- __int64 startpos; +- char osfile; +-} my_ioinfo; +- +-#define IOINFO_L2E 6 +-#define IOINFO_ARRAYS 128 +- +-#else +- + typedef struct { + intptr_t osfhnd; + char osfile; + } my_ioinfo; + +-#define IOINFO_L2E 5 +-#define IOINFO_ARRAYS 64 +- +-#endif +- + extern __declspec(dllimport) char * __pioinfo[]; + #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) + #define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS) + #define FOPEN 0x01 + #define _NO_CONSOLE_FILENO (intptr_t)-2 ++#define IOINFO_L2E 5 ++#define IOINFO_ARRAYS 64 + + /* This function emulates what the windows CRT does to validate file handles */ + int +@@ -640,6 +644,8 @@ _PyVerify_fd_dup2(int fd1, int fd2) + #define _PyVerify_fd_dup2(A, B) (1) + #endif + ++#endif /* defined _MSC_VER */ ++ + /* Return a dictionary corresponding to the POSIX environment table */ + #if defined(WITH_NEXT_FRAMEWORK) || (defined(__APPLE__) && defined(Py_ENABLE_SHARED)) + /* On Darwin/MacOSX a shared library or framework has no access to +@@ -1242,14 +1248,10 @@ win32_fstat(int file_number, struct win32_stat *result) + + h = (HANDLE)_get_osfhandle(file_number); + +- /* Protocol violation: we explicitly clear errno, instead of +- setting it to a POSIX error. Callers should use GetLastError. */ + errno = 0; + + if (h == INVALID_HANDLE_VALUE) { +- /* This is really a C library error (invalid file handle). +- We set the Win32 error to the closes one matching. */ +- SetLastError(ERROR_INVALID_HANDLE); ++ errno = EBADF; + return -1; + } + memset(result, 0, sizeof(*result)); +@@ -1258,6 +1260,7 @@ win32_fstat(int file_number, struct win32_stat *result) + if (type == FILE_TYPE_UNKNOWN) { + DWORD error = GetLastError(); + if (error != 0) { ++ errno = EINVAL; + return -1; + } + /* else: valid but unknown file */ +@@ -1272,6 +1275,7 @@ win32_fstat(int file_number, struct win32_stat *result) + } + + if (!GetFileInformationByHandle(h, &info)) { ++ errno = EINVAL; + return -1; + } + +diff --git a/PC/invalid_parameter_handler.c b/PC/invalid_parameter_handler.c +new file mode 100644 +index 0000000..3bc0104 +--- /dev/null ++++ b/PC/invalid_parameter_handler.c +@@ -0,0 +1,22 @@ ++#ifdef _MSC_VER ++ ++#include ++ ++#if _MSC_VER >= 1900 ++/* pyconfig.h uses this function in the _Py_BEGIN/END_SUPPRESS_IPH ++ * macros. It does not need to be defined when building using MSVC ++ * earlier than 14.0 (_MSC_VER == 1900). ++ */ ++ ++static void __cdecl _silent_invalid_parameter_handler( ++ wchar_t const* expression, ++ wchar_t const* function, ++ wchar_t const* file, ++ unsigned int line, ++ uintptr_t pReserved) { } ++ ++void *_Py_silent_invalid_parameter_handler = ++ (void*)_silent_invalid_parameter_handler; ++#endif ++ ++#endif +diff --git a/Python/pystate.c b/Python/pystate.c +index eb992c1..1c0f970 100644 +--- a/Python/pystate.c ++++ b/Python/pystate.c +@@ -22,6 +22,12 @@ the expense of doing their own locking). + #endif + #endif + ++#if defined _MSC_VER && _MSC_VER >= 1900 ++/* Issue #23524: Temporary fix to disable termination due to invalid parameters */ ++PyAPI_DATA(void*) _Py_silent_invalid_parameter_handler; ++#include ++#endif ++ + #ifdef __cplusplus + extern "C" { + #endif +@@ -202,6 +208,12 @@ new_threadstate(PyInterpreterState *interp, int init) + tstate->next = interp->tstate_head; + interp->tstate_head = tstate; + HEAD_UNLOCK(); ++ ++#if defined _MSC_VER && _MSC_VER >= 1900 ++ /* Issue #23524: Temporary fix to disable termination due to invalid parameters */ ++ _set_thread_local_invalid_parameter_handler((_invalid_parameter_handler)_Py_silent_invalid_parameter_handler); ++#endif ++ + } + + return tstate; +-- +2.5.0 + diff --git a/patches/2.7.13/Windows-MSVC/README.rst b/patches/2.7.13/Windows-MSVC/README.rst new file mode 100644 index 000000000..21de3ab93 --- /dev/null +++ b/patches/2.7.13/Windows-MSVC/README.rst @@ -0,0 +1,53 @@ + + +* ``0001-VS2010-Support-Backport-Fix-13210.-Port-the-Windows-.patch``: This patch + is a partial backport of `python/cpython@401f9f3 `_. + + Changes to the following modules have **NOT** been backported: + + * ``Tools/msi`` + * ``Tools/buildbot`` + * ``PCBuild`` + + It applies to the following versions of Visual Studio: + + * 1600: VS2010 + * 1700: VS2012 + * 1800: VS2013 + * 1900: VS2015 + +* ``0002-VS2015-Support-Backport-Issue-22919-Windows-build-up.patch``: This patch + is a partial backport of `python/cpython@65e4cb1 `_. + + Changes to the following modules have **NOT** been backported: + + * ``Lib/distutils/sysconfig`` + * ``Modules/socketmodule.c``: Not required since changes related to WSA have been introduced + in Python 3.x (see `python/cpython@6b4883d `) + * ``Tools/buildbot`` + * ``PCBuild`` + + It applies to the following versions of Visual Studio: + + * 1900: VS2015 + + +* ``0003-VS2015-Support-Backport-of-Issue-23524-Replace-_PyVe.patch``: This patch + is a partical backport of `python/cpython@d81431f `_ + + This patch do not backport the define of "timezone" as "_timezone" as it was done in Python 3.x. + Keeping "timezone" is required in Python 2.7.x to avoid the following build issue + ``error C2032: '__timezone': function cannot be member of struct '__timeb64'`` associated with ``sys/timeb.h``. + The need for ``sys/timeb.h`` was removed in Python 3.x in `python/cpython@6fc4ade `_ + and `python/cpython@0011124 `_ but is still used in Python 2.7.x. + + Changes to the following modules have **NOT** been backported: + + * ``PCbuild`` + + +References +---------- + +* Microsoft Visual C++ - Internal version numbering + See https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering diff --git a/patches/README.rst b/patches/README.rst new file mode 100644 index 000000000..af0902d35 --- /dev/null +++ b/patches/README.rst @@ -0,0 +1,49 @@ +CPython Patches +=============== + +Fixes and improvements to CPython should first be contributed upstream. The +`Python Developer’s Guide `_ is a great +resource to guide you through the process. + +That said, there are few scenarios where using `python-cmake-buildsystem` to +patch CPython is relevant. Learn more about these at https://github.com/python-cmake-buildsystem/cpython. + +By default, patches are applied at configuration time. Setting the option +``PYTHON_APPLY_PATCHES`` to ``OFF`` allows to change this. Note that the +build system keep track which patches have been applied. + +Each patch is documented by adding an entry to the `README.rst` file +found in the same directory (or a parent directory). Whenever possible, +references to `bugs.python.org `_(bpo) issues, +corresponding `GitHub PRs `_ and +any related discussions on forums or mailing lists are also provided. + +Patches are organized per python version. Patches specific to a system, +a system+compiler, or a system+compiler+compiler_version are organized in +corresponding sub-directories:: + + patches/ + patches// + patches//- + patches//-/ + +where + +* ```` is of the form ``X.Y.Z`` + +* ```` is a value like ``Darwin``, ``Linux`` or ``Windows``. See + corresponding CMake documentation for more details. + +* ```` is a valid like ``Clang``, ``GNU`` or ``MSVC``. See + corresponding CMake documentation for more details. + +* ```` is set to the value of ``CMAKE_C_COMPILER_VERSION`` (e.g ``5.2.1``) + except when using Microsoft compiler where it is set to the value of ``MSVC_VERSION`` (e.g ``1900``). + +Before being applied, patches are sorted alphabetically. This ensures that +patch starting with `0001-` is applied before the one starting with `0002-`. + + +Note that for historical reasons, there are still patches found in ``cmake/patches`` +and ``cmake/patches-win32`` subdirectories. These will gradually be organized as +described above.