Skip to content

Commit

Permalink
[python3] Use vcpkg expat port instead of vendored code.
Browse files Browse the repository at this point in the history
This fixes an observed build failure on x86-windows when the vcpkg expat
port is installed before the python3 port is built.
  • Loading branch information
Hoikas committed Sep 25, 2020
1 parent cad9b66 commit 5d9fbb7
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ports/python3/0001-static-library.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 79ec7506399bc3846bb0631827e3880f5468e507 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Sun, 13 Sep 2020 21:33:33 -0400
Subject: [PATCH 1/7] Static library
Subject: [PATCH 1/8] Static library


diff --git a/PC/pyconfig.h b/PC/pyconfig.h
Expand Down
2 changes: 1 addition & 1 deletion ports/python3/0002-always-use-vcpkg-zlib.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 175b0e8c0d5d4ba1da3d9313a0208c8b814792f0 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Wed, 9 Sep 2020 15:20:36 -0400
Subject: [PATCH 2/7] Always use vcpkg zlib
Subject: [PATCH 2/8] Always use vcpkg zlib

Building without zlib is not a supported configuration, per the warning
messages.
Expand Down
2 changes: 1 addition & 1 deletion ports/python3/0003-remove-external-dependencies.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From d69746248f01a3eca82f441e789279e9d0acaf08 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Wed, 9 Sep 2020 15:24:38 -0400
Subject: [PATCH 3/7] Remove external dependencies
Subject: [PATCH 3/8] Remove external dependencies

The externally fetched libraries may cause linker errors resulting from
duplicate symbols in downstream projects.
Expand Down
2 changes: 1 addition & 1 deletion ports/python3/0004-don-t-copy-vcruntime.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 04b72da23e00abb1a5ff02aa5b0cb54576d45051 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Wed, 9 Sep 2020 16:12:49 -0400
Subject: [PATCH 4/7] Don't copy vcruntime
Subject: [PATCH 4/8] Don't copy vcruntime

VCRUNTIME140.dll should not be redistributed, ever.

Expand Down
2 changes: 1 addition & 1 deletion ports/python3/0005-only-build-required-projects.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From dfb70394a19e657f2700fa31b784b0ea538b2a70 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Wed, 9 Sep 2020 20:15:58 -0400
Subject: [PATCH 5/7] Only build required projects
Subject: [PATCH 5/8] Only build required projects

Strips out tests and unsupported externals (eg tkinter).

Expand Down
2 changes: 1 addition & 1 deletion ports/python3/0006-fix-duplicate-symbols.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 4d698284921b48b963caa26a352ef414f36f36d4 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Fri, 11 Sep 2020 12:35:36 -0400
Subject: [PATCH 6/7] fix duplicate symbols
Subject: [PATCH 6/8] fix duplicate symbols


diff --git a/Modules/_winapi.c b/Modules/_winapi.c
Expand Down
2 changes: 1 addition & 1 deletion ports/python3/0007-disable-static-PYD-loading.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From eaf5d60b5de65f8d1f8f32535cd2e42da3115f00 Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Sun, 13 Sep 2020 19:38:30 -0400
Subject: [PATCH 7/7] Disable static PYD loading
Subject: [PATCH 7/8] Disable static PYD loading

Loading shared *.pyd extensions with a static python on Windows crashes
the interpreter. Don't do that.
Expand Down
37 changes: 37 additions & 0 deletions ports/python3/0008-always-use-vcpkg-expat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From 0fb7abf948c0c6157a49126c90ef661ef59cd11f Mon Sep 17 00:00:00 2001
From: Adam Johnson <[email protected]>
Date: Wed, 16 Sep 2020 16:48:38 -0400
Subject: [PATCH 8/8] Always use vcpkg expat

The vendored expat library causes errors when building the port on
x86-windows after the expat port has been built.

diff --git a/PCbuild/pyexpat.vcxproj b/PCbuild/pyexpat.vcxproj
index b2d9f5d57d..4efb826a05 100644
--- a/PCbuild/pyexpat.vcxproj
+++ b/PCbuild/pyexpat.vcxproj
@@ -89,17 +89,19 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
- <ClCompile>
+ <ClCompile Condition="false">
<AdditionalIncludeDirectories>$(PySourcePath)Modules\expat;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;PYEXPAT_EXPORTS;HAVE_EXPAT_H;XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
- <ItemGroup>
+ <ItemGroup Condition="false">
<ClInclude Include="..\Modules\expat\xmlrole.h" />
<ClInclude Include="..\Modules\expat\xmltok.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Modules\pyexpat.c" />
+ </ItemGroup>
+ <ItemGroup Condition="false">
<ClCompile Include="..\Modules\expat\xmlparse.c" />
<ClCompile Include="..\Modules\expat\xmlrole.c" />
<ClCompile Include="..\Modules\expat\xmltok.c" />
--
2.28.0.windows.1

10 changes: 9 additions & 1 deletion ports/python3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(PATCHES
0005-only-build-required-projects.patch
0006-fix-duplicate-symbols.patch
0007-disable-static-PYD-loading.patch
0008-always-use-vcpkg-expat.patch
)

vcpkg_from_github(
Expand All @@ -40,6 +41,8 @@ if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)
find_library(BZ2_DEBUG NAMES bz2 bz2d PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(CRYPTO_RELEASE NAMES libcrypto PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(CRYPTO_DEBUG NAMES libcrypto PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(EXPAT_RELEASE NAMES libexpat PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(EXPAT_DEBUG NAMES libexpat libexpatd PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(FFI_RELEASE NAMES libffi PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(FFI_DEBUG NAMES libffi PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(LZMA_RELEASE NAMES lzma PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
Expand Down Expand Up @@ -140,7 +143,12 @@ if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP)

vcpkg_clean_msbuild()
else()
set(OPTIONS "--with-openssl=${CURRENT_INSTALLED_DIR}" "--with-ensurepip" [[--with-suffix=""]])
set(OPTIONS
"--with-openssl=${CURRENT_INSTALLED_DIR}"
"--with-ensurepip"
[[--with-suffix=""]]
"--with-system-expat"
)
if(VCPKG_TARGET_IS_OSX)
list(APPEND OPTIONS "LIBS=-liconv -lintl")
endif()
Expand Down
5 changes: 3 additions & 2 deletions ports/python3/python_vcpkg.props.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<CLCompile>
<!-- Use vcpkg ports instead of vendored externals -->
<PreprocessorDefinitions>_Py_HAVE_ZLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="${VCPKG_LIBRARY_LINKAGE} == 'static'">XML_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
${CURRENT_INSTALLED_DIR}/include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
Expand All @@ -24,10 +25,10 @@

<!-- Extension modules -->
<AdditionalDependencies Condition="'$(Configuration)|$(IncludeExtensions)' == 'Release|true'">
${BZ2_RELEASE};${FFI_RELEASE};${LZMA_RELEASE};${SQLITE_RELEASE};%(AdditionalDependencies)
${BZ2_RELEASE};${EXPAT_RELEASE};${FFI_RELEASE};${LZMA_RELEASE};${SQLITE_RELEASE};%(AdditionalDependencies)
</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(IncludeExtensions)' == 'Debug|true'">
${BZ2_DEBUG};${FFI_DEBUG};${LZMA_DEBUG};${SQLITE_DEBUG};%(AdditionalDependencies)
${BZ2_DEBUG};${EXPAT_DEBUG};${FFI_DEBUG};${LZMA_DEBUG};${SQLITE_DEBUG};%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
Expand Down
1 change: 1 addition & 0 deletions ports/python3/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"name": "bzip2",
"platform": "!(windows & static)"
},
"expat",
{
"name": "gettext",
"platform": "!(windows | uwp)"
Expand Down

0 comments on commit 5d9fbb7

Please sign in to comment.