Skip to content

Commit

Permalink
[Python2 ]Update to 2.7.18 (#17798)
Browse files Browse the repository at this point in the history
* [Python2] Update to 2.7.18

* [vcpkg] update baseline
  • Loading branch information
lakor64 committed May 13, 2021
1 parent d850857 commit 104b3c7
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 116 deletions.
72 changes: 22 additions & 50 deletions ports/python2/001-build-msvc.patch
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
From 4988ea4f4ce6af0b567e6a2dc2c23aaf7cc5f12d Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
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
index 86a85c1..65a60b5 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -193,7 +193,7 @@ class build_ext (Command):
Expand All @@ -35,7 +12,7 @@ index 2c68be3..f1d184b 100644
if self.plat_name == 'win32':
suffix = ''
diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py
index 33d3e51..f6de11c 100644
index 33d3e51..9fe6417 100644
--- a/Lib/distutils/msvc9compiler.py
+++ b/Lib/distutils/msvc9compiler.py
@@ -662,11 +662,12 @@ class MSVCCompiler(CCompiler) :
Expand All @@ -50,26 +27,24 @@ index 33d3e51..f6de11c 100644
+ if self.__version < 10:
+ try:
+ self.spawn(['mt.exe', '-nologo', '-manifest',
+ temp_manifest, out_arg])
+ except PackagingExecError as msg:
+ mffilename, out_arg])
+ except DistutilsExecError, 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
index 3e58bac..cad9de5 100644
--- a/PC/dl_nt.c
+++ b/PC/dl_nt.c
@@ -18,7 +18,8 @@ char dllVersionBuffer[16] = ""; // a private buffer
@@ -18,6 +18,7 @@ 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.
// 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.
Expand All @@ -79,26 +54,26 @@ index ef1ce09..5ff07fd 100644

typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *);
typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *);
@@ -76,6 +79,8 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie)
@@ -75,6 +78,7 @@ void _Py_DeactivateActCtx(ULONG_PTR cookie)
if (!(*pfnDeactivateActCtx)(0, 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,
@@ -87,6 +91,7 @@ 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");
@@ -98,12 +103,15 @@ BOOL WINAPI DllMain (HANDLE hInst,
"activation context\n");
return FALSE;
}
+#endif
break;

Expand All @@ -110,8 +85,9 @@ index ef1ce09..5ff07fd 100644
break;
}
return TRUE;
}
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
index 44c82e4..68928dd 100644
index 44c82e4..091957e 100644
--- a/PC/msvcrtmodule.c
+++ b/PC/msvcrtmodule.c
@@ -25,6 +25,8 @@
Expand Down Expand Up @@ -140,11 +116,10 @@ index 44c82e4..68928dd 100644
#ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN
st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN",
_VC_ASSEMBLY_PUBLICKEYTOKEN);
@@ -427,4 +430,14 @@ initmsvcrt(void)
@@ -427,4 +430,13 @@ 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,
Expand All @@ -156,12 +131,12 @@ index 44c82e4..68928dd 100644
+#endif
}
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index 5d1c90a..b60af1e 100644
index 5fa6398..0cbd236 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -231,14 +231,19 @@ typedef int pid_t;
#define hypot _hypot
#endif
@@ -226,14 +226,19 @@ typedef int pid_t;
#define Py_IS_FINITE(X) _finite(X)
#define copysign _copysign

-#endif /* _MSC_VER */
+/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/
Expand Down Expand Up @@ -222,6 +197,3 @@ index 4e5555e..8626642 100644
}

/* restore old error mode settings */
--
2.5.0

70 changes: 17 additions & 53 deletions ports/python2/002-build-msvc.patch
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
From e6a1f39d2d876bbfc8b02e628dfd1d0fef4a0651 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
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
index ab10ec5..6c43d82 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -19,6 +19,8 @@ if os.name == "nt":
Expand All @@ -57,7 +24,7 @@ index ab10ec5..a163239 100644
# 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
index 65a60b5..b2ee260 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -196,7 +196,7 @@ class build_ext (Command):
Expand All @@ -70,7 +37,7 @@ index f1d184b..0851690 100644
# 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
index 9fe6417..57d42b7 100644
--- a/Lib/distutils/msvc9compiler.py
+++ b/Lib/distutils/msvc9compiler.py
@@ -182,6 +182,9 @@ def get_build_version():
Expand Down Expand Up @@ -98,7 +65,7 @@ index 0e69fd3..77025c6 100644
# 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
index 7a1a694..7d07150 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -558,15 +558,33 @@ _PyInt_FromDev(PY_LONG_LONG v)
Expand Down Expand Up @@ -138,7 +105,7 @@ index e73805f..90d5318 100644
#define FOPEN 0x01
#define _NO_CONSOLE_FILENO (intptr_t)-2
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 12c43b0..db190b8 100644
index 61b8d61..7678283 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -808,7 +808,7 @@ inittimezone(PyObject *m) {
Expand All @@ -160,10 +127,10 @@ index 12c43b0..db190b8 100644
#endif
PyModule_AddIntConstant(m, "daylight", daylight);
diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c
index f1cc7fe..5b11dcc 100644
index e3b52a8..a7d1c2c 100644
--- a/PC/bdist_wininst/install.c
+++ b/PC/bdist_wininst/install.c
@@ -1184,7 +1184,7 @@ static void CenterWindow(HWND hwnd)
@@ -1185,7 +1185,7 @@ static void CenterWindow(HWND hwnd)

#include <prsht.h>

Expand All @@ -172,7 +139,7 @@ index f1cc7fe..5b11dcc 100644
IntroDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnm;
@@ -1533,7 +1533,7 @@ SCHEME *GetScheme(int major, int minor)
@@ -1534,7 +1534,7 @@ SCHEME *GetScheme(int major, int minor)
return old_scheme;
}

Expand All @@ -181,7 +148,7 @@ index f1cc7fe..5b11dcc 100644
SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnm;
@@ -1835,7 +1835,7 @@ static void CloseLogfile(void)
@@ -1836,7 +1836,7 @@ static void CloseLogfile(void)
fclose(logfile);
}

Expand All @@ -190,7 +157,7 @@ index f1cc7fe..5b11dcc 100644
InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnm;
@@ -1990,7 +1990,7 @@ InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1991,7 +1991,7 @@ InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}


Expand All @@ -199,7 +166,7 @@ index f1cc7fe..5b11dcc 100644
FinishedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnm;
@@ -2166,23 +2166,6 @@ BOOL NeedAutoUAC()
@@ -2167,23 +2167,6 @@ BOOL NeedAutoUAC()
return TRUE;
}

Expand All @@ -223,7 +190,7 @@ index f1cc7fe..5b11dcc 100644
// 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)
@@ -2239,7 +2222,7 @@ int DoInstall(void)

// See if we need to do the Vista UAC magic.
if (strcmp(user_access_control, "force")==0) {
Expand All @@ -232,7 +199,7 @@ index f1cc7fe..5b11dcc 100644
SpawnUAC();
return 0;
}
@@ -2246,7 +2229,7 @@ int DoInstall(void)
@@ -2247,7 +2230,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.
Expand All @@ -242,12 +209,12 @@ index f1cc7fe..5b11dcc 100644
return 0;
}
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index b60af1e..b517146 100644
index 0cbd236..d896a38 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -231,6 +231,13 @@ typedef int pid_t;
#define hypot _hypot
#endif
@@ -226,6 +226,13 @@ typedef int pid_t;
#define Py_IS_FINITE(X) _finite(X)
#define copysign _copysign

+/* VS 2015 defines these names with a leading underscore */
+#if _MSC_VER >= 1900
Expand All @@ -259,6 +226,3 @@ index b60af1e..b517146 100644
/* 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

7 changes: 4 additions & 3 deletions ports/python2/004-static-library-msvc.patch
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 92b32da..8dac984 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -41,7 +41,7 @@
Expand All @@ -13,8 +15,8 @@
<ClCompile>
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(PySourcePath)Python;$(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_NO_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;_CRT_SECURE_NO_WARNINGS;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_NO_ENABLE_SHARED;_CRT_SECURE_NO_WARNINGS;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -35,4 +37,3 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\Include\abstract.h" />
--
6 changes: 3 additions & 3 deletions ports/python2/005-static-crt-msvc.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 8dac984..c18ad1e 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -71,6 +71,10 @@
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>$(PySourcePath)Python;$(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_NO_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_NO_ENABLE_SHARED;_CRT_SECURE_NO_WARNINGS;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MultiThreadedDebug</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
--

2 changes: 1 addition & 1 deletion ports/python2/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Source: python2
Version: 2.7.15-2
Version: 2.7.18
Description: The Python programming language as an embeddable library
4 changes: 2 additions & 2 deletions ports/python2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif()

set(PYTHON_VERSION_MAJOR 2)
set(PYTHON_VERSION_MINOR 7)
set(PYTHON_VERSION_PATCH 15)
set(PYTHON_VERSION_PATCH 18)
set(PYTHON_VERSION ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH})

set(_PYTHON_PATCHES "")
Expand All @@ -27,7 +27,7 @@ endif()
vcpkg_download_distfile(ARCHIVE
URLS https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz
FILENAME Python-${PYTHON_VERSION}.tar.xz
SHA512 27ea43eb45fc68f3d2469d5f07636e10801dee11635a430ec8ec922ed790bb426b072da94df885e4dfa1ea8b7a24f2f56dd92f9b0f51e162330f161216bd6de6
SHA512 a7bb62b51f48ff0b6df0b18f5b0312a523e3110f49c3237936bfe56ed0e26838c0274ff5401bda6fc21bf24337477ccac49e8026c5d651e4b4cafb5eb5086f6c
)

vcpkg_extract_source_archive_ex(
Expand Down
Loading

0 comments on commit 104b3c7

Please sign in to comment.