diff options
| author | Adam Johnson <AdamJohnso@gmail.com> | 2021-03-29 13:09:14 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-29 10:09:14 -0700 |
| commit | aaa6a031ced87d5b2c04023029bc5746dac52cb4 (patch) | |
| tree | 871b1ee880668dc1de107308ca69c9d3003d5712 /ports/python3 | |
| parent | 76ab38bbd94001701d678643bf3a4d1cc43d7ca4 (diff) | |
| download | vcpkg-aaa6a031ced87d5b2c04023029bc5746dac52cb4.tar.gz vcpkg-aaa6a031ced87d5b2c04023029bc5746dac52cb4.zip | |
[python3] Add feature deprecated-win7-support. (#16420)
* [python3] Move /MACHINE into MSBuild file.
This prevents potential patch application conflicts.
* [python3] Add feature deprecated-win7-support.
This backports the fix for bpo-39401 from the Python 3.8 branch instead
of the one from the Python 3.9 branch, which dropped support for Windows
7.
* [python3] Bump port version.
* [python3] Fix goof in static patch that omitted pathcch.lib.
* x-add-version
* [python3] Revert trivial patch changes
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'ports/python3')
| -rw-r--r-- | ports/python3/0001-static-library.patch | 41 | ||||
| -rw-r--r-- | ports/python3/0007-restore-support-for-windows-7.patch | 124 | ||||
| -rw-r--r-- | ports/python3/portfile.cmake | 9 | ||||
| -rw-r--r-- | ports/python3/python_vcpkg.props.in | 6 | ||||
| -rw-r--r-- | ports/python3/vcpkg.json | 8 |
5 files changed, 159 insertions, 29 deletions
diff --git a/ports/python3/0001-static-library.patch b/ports/python3/0001-static-library.patch index f7d46d094..93a89a2e3 100644 --- a/ports/python3/0001-static-library.patch +++ b/ports/python3/0001-static-library.patch @@ -1,19 +1,19 @@ -From 4bd06273a9ed63f17966f113dc61a6051bad8b86 Mon Sep 17 00:00:00 2001 +From 14d91e4f4a9377f47cc4cc33faeeb7c82f64b176 Mon Sep 17 00:00:00 2001 From: Adam Johnson <AdamJohnso@gmail.com> Date: Thu, 28 May 2020 17:25:21 -0400 -Subject: [PATCH 1/6] static library +Subject: [PATCH 1/7] static library builds the pythoncore as a static library instead of a DLL --- - PC/pyconfig.h | 7 +++++++ - PCbuild/pythoncore.vcxproj | 16 ++++++++++++++-- - 2 files changed, 21 insertions(+), 2 deletions(-) + PC/pyconfig.h | 9 +++++++++ + PCbuild/pythoncore.vcxproj | 4 ++-- + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/PC/pyconfig.h b/PC/pyconfig.h -index 02216b5068..7e0ba881a5 100644 +index d7d3cf081e..34269f0b75 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h -@@ -252,6 +252,7 @@ typedef int pid_t; +@@ -251,6 +251,7 @@ typedef int pid_t; /* For Windows the Python core is in a DLL by default. Test Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ @@ -21,7 +21,7 @@ index 02216b5068..7e0ba881a5 100644 #if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED) # define Py_ENABLE_SHARED 1 /* standard symbol for shared library */ # define MS_COREDLL /* deprecated old symbol */ -@@ -277,6 +278,12 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ +@@ -276,6 +277,14 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ # endif /* _DEBUG */ # endif /* _MSC_VER */ # endif /* Py_BUILD_CORE */ @@ -30,12 +30,14 @@ index 02216b5068..7e0ba881a5 100644 +# pragma comment(lib, "version.lib") +# pragma comment(lib, "shlwapi.lib") +# pragma comment(lib, "ws2_32.lib") -+# pragma comment(lib, "pathcch.lib") ++# if Py_WINVER > 0x0601 ++# pragma comment(lib, "pathcch.lib") ++# endif /* Py_WINVER */ #endif /* MS_COREDLL */ #if defined(MS_WIN64) diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj -index 2625d0293d..dbe236829a 100644 +index 2625d0293d..2f8bdaa931 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -73,7 +73,7 @@ @@ -47,7 +49,7 @@ index 2625d0293d..dbe236829a 100644 <UseOfMfc>false</UseOfMfc> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> -@@ -102,12 +102,24 @@ +@@ -102,7 +102,7 @@ <AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions> <AdditionalIncludeDirectories>$(PySourcePath)Python;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories Condition="$(IncludeExternals)">$(zlibDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> @@ -56,23 +58,6 @@ index 2625d0293d..dbe236829a 100644 <PreprocessorDefinitions Condition="$(IncludeExternals)">_Py_HAVE_ZLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> <Link> - <AdditionalDependencies>version.lib;shlwapi.lib;ws2_32.lib;pathcch.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> -+ <Lib> -+ <TargetMachine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MachineX86</TargetMachine> -+ </Lib> -+ <Lib> -+ <TargetMachine Condition="'$(Configuration)|$(Platform)'=='PGInstrument|Win32'">MachineX86</TargetMachine> -+ </Lib> -+ <Lib> -+ <TargetMachine Condition="'$(Configuration)|$(Platform)'=='PGUpdate|Win32'">MachineX86</TargetMachine> -+ </Lib> -+ <Lib> -+ <TargetMachine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MachineX86</TargetMachine> -+ </Lib> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="..\Include\Python-ast.h" /> -- 2.28.0.windows.1 diff --git a/ports/python3/0007-restore-support-for-windows-7.patch b/ports/python3/0007-restore-support-for-windows-7.patch new file mode 100644 index 000000000..4efb19012 --- /dev/null +++ b/ports/python3/0007-restore-support-for-windows-7.patch @@ -0,0 +1,124 @@ +From e30a560527d17ae81685dd11d3268bc982af2048 Mon Sep 17 00:00:00 2001 +From: Adam Johnson <AdamJohnso@gmail.com> +Date: Tue, 16 Feb 2021 18:03:07 -0500 +Subject: [PATCH 7/7] restore support for windows 7 + +this backports the windows 7 compatible fix for bpo-39401 from gh-18234, +originally authored by Steve Dower, and removes explicit dependencies on +pathcch. +--- + PC/getpathp.c | 55 +++++++++++++++++++++++++++++++++++--- + PC/pyconfig.h | 4 +-- + PCbuild/pythoncore.vcxproj | 2 +- + 3 files changed, 54 insertions(+), 7 deletions(-) + +diff --git a/PC/getpathp.c b/PC/getpathp.c +index 53da3a6d05..3d58bbfe70 100644 +--- a/PC/getpathp.c ++++ b/PC/getpathp.c +@@ -250,14 +250,43 @@ ismodule(wchar_t *filename, int update_filename) + stuff as fits will be appended. + */ + ++ ++static int _PathCchCombineEx_Initialized = 0; ++typedef HRESULT(__stdcall *PPathCchCombineEx) (PWSTR pszPathOut, size_t cchPathOut, ++ PCWSTR pszPathIn, PCWSTR pszMore, ++ unsigned long dwFlags); ++static PPathCchCombineEx _PathCchCombineEx; ++ + static void + join(wchar_t *buffer, const wchar_t *stuff) + { +- if (FAILED(PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { +- Py_FatalError("buffer overflow in getpathp.c's join()"); ++ if (_PathCchCombineEx_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ if (pathapi) { ++ _PathCchCombineEx = (PPathCchCombineEx)GetProcAddress(pathapi, "PathCchCombineEx"); ++ } ++ else { ++ _PathCchCombineEx = NULL; ++ } ++ _PathCchCombineEx_Initialized = 1; ++ } ++ if (_PathCchCombineEx) { ++ if (FAILED(_PathCchCombineEx(buffer, MAXPATHLEN+1, buffer, stuff, 0))) { ++ Py_FatalError("buffer overflow in getpathp.c's join()"); ++ } ++ } else { ++ if (!PathCombineW(buffer, buffer, stuff)) { ++ Py_FatalError("buffer overflow in getpathp.c's join()"); ++ } + } + } + ++static int _PathCchCanonicalizeEx_Initialized = 0; ++typedef HRESULT(__stdcall *PPathCchCanonicalizeEx) (PWSTR pszPathOut, size_t cchPathOut, ++ PCWSTR pszPathIn, unsigned long dwFlags); ++static PPathCchCanonicalizeEx _PathCchCanonicalizeEx; ++ + /* Call PathCchCanonicalizeEx(path): remove navigation elements such as "." + and ".." to produce a direct, well-formed path. */ + static PyStatus +@@ -267,8 +296,26 @@ canonicalize(wchar_t *buffer, const wchar_t *path) + return _PyStatus_NO_MEMORY(); + } + +- if (FAILED(PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { +- return INIT_ERR_BUFFER_OVERFLOW(); ++ if (_PathCchCanonicalizeEx_Initialized == 0) { ++ HMODULE pathapi = LoadLibraryExW(L"api-ms-win-core-path-l1-1-0.dll", NULL, ++ LOAD_LIBRARY_SEARCH_SYSTEM32); ++ if (pathapi) { ++ _PathCchCanonicalizeEx = (PPathCchCanonicalizeEx)GetProcAddress(pathapi, "PathCchCanonicalizeEx"); ++ } ++ else { ++ _PathCchCanonicalizeEx = NULL; ++ } ++ _PathCchCanonicalizeEx_Initialized = 1; ++ } ++ if (_PathCchCanonicalizeEx) { ++ if (FAILED(_PathCchCanonicalizeEx(buffer, MAXPATHLEN + 1, path, 0))) { ++ return INIT_ERR_BUFFER_OVERFLOW(); ++ } ++ } ++ else { ++ if (!PathCanonicalizeW(buffer, path)) { ++ return INIT_ERR_BUFFER_OVERFLOW(); ++ } + } + return _PyStatus_OK(); + } +diff --git a/PC/pyconfig.h b/PC/pyconfig.h +index 34269f0b75..812f6d9353 100644 +--- a/PC/pyconfig.h ++++ b/PC/pyconfig.h +@@ -136,8 +136,8 @@ WIN32 is still required for the locale module. + + /* set the version macros for the windows headers */ + /* Python 3.9+ requires Windows 8 or greater */ +-#define Py_WINVER 0x0602 /* _WIN32_WINNT_WIN8 */ +-#define Py_NTDDI NTDDI_WIN8 ++#define Py_WINVER 0x0601 /* _WIN32_WINNT_WIN7 */ ++#define Py_NTDDI NTDDI_WIN7 + + /* We only set these values when building Python - we don't want to force + these values on extensions, as that will affect the prototypes and +diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj +index d8e8d2d086..df2892b0de 100644 +--- a/PCbuild/pythoncore.vcxproj ++++ b/PCbuild/pythoncore.vcxproj +@@ -106,7 +106,7 @@ + <PreprocessorDefinitions Condition="$(IncludeExternals)">_Py_HAVE_ZLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> +- <AdditionalDependencies>version.lib;shlwapi.lib;ws2_32.lib;pathcch.lib;%(AdditionalDependencies)</AdditionalDependencies> ++ <AdditionalDependencies>version.lib;shlwapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + </ItemDefinitionGroup> + <ItemGroup> +-- +2.28.0.windows.1 + diff --git a/ports/python3/portfile.cmake b/ports/python3/portfile.cmake index ee19476cf..3a90a7913 100644 --- a/ports/python3/portfile.cmake +++ b/ports/python3/portfile.cmake @@ -19,6 +19,15 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") list(PREPEND PATCHES 0001-static-library.patch) endif() +# Python 3.9 removed support for Windows 7. This patch re-adds support for Windows 7 and is therefore +# required to build this port on Windows 7 itself due to Python using itself in its own build system. +if("deprecated-win7-support" IN_LIST FEATURES) + list(APPEND PATCHES 0007-restore-support-for-windows-7.patch) + message(WARNING "Windows 7 support is deprecated and may be removed at any time.") +elseif(VCPKG_TARGET_IS_WINDOWS AND CMAKE_SYSTEM_VERSION EQUAL 6.1) + message(FATAL_ERROR "python3 requires the feature deprecated-win7-support when building on Windows 7.") +endif() + vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO python/cpython diff --git a/ports/python3/python_vcpkg.props.in b/ports/python3/python_vcpkg.props.in index c786e5fa0..e5b6093a5 100644 --- a/ports/python3/python_vcpkg.props.in +++ b/ports/python3/python_vcpkg.props.in @@ -31,5 +31,11 @@ ${BZ2_DEBUG};${EXPAT_DEBUG};${FFI_DEBUG};${LZMA_DEBUG};${SQLITE_DEBUG};%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
+
+ <Lib>
+ <!-- Required to prevent linker errors on Visual Studio 2017 with static CRT -->
+ <TargetMachine Condition="'${VCPKG_TARGET_ARCHITECTURE}'=='x86'">MachineX86</TargetMachine>
+ <TargetMachine Condition="'${VCPKG_TARGET_ARCHITECTURE}'=='x64'">MachineX64</TargetMachine>
+ </Lib>
</ItemDefinitionGroup>
</Project>
diff --git a/ports/python3/vcpkg.json b/ports/python3/vcpkg.json index 0a0b7778f..f997398f8 100644 --- a/ports/python3/vcpkg.json +++ b/ports/python3/vcpkg.json @@ -1,6 +1,7 @@ { "name": "python3", "version-string": "3.9.2", + "port-version": 1, "description": "The Python programming language", "homepage": "https://github.com/python/cpython", "supports": "!(arm | uwp)", @@ -35,5 +36,10 @@ "platform": "!(windows & static)" }, "zlib" - ] + ], + "features": { + "deprecated-win7-support": { + "description": "Deprecated support for the Windows 7 platform -- may be removed at any time." + } + } } |
