Skip to content

Commit

Permalink
refresh patches
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Sep 16, 2020
1 parent 6220041 commit 2888305
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 132 deletions.
8 changes: 4 additions & 4 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ source:
- patches/0014-Fix-cross-compilation-on-Debian-based-distros.patch
# - patches/0015-Disable-registry-lookup-unless-CONDA_PY_ALLOW_REG_PA.patch
- patches/0016-Unvendor-openssl.patch
# - patches/0017-Unvendor-sqlite3.patch
- patches/0017-Unvendor-sqlite3.patch
# https://bugs.python.org/issue35644
- patches/0018-venv-Revert-a-change-from-https-jackfan.us.kg-python-cp.patch
- patches/0019-Win-Add-back-the-DLLSuffix-used-to-find-the-openssl-.patch
- patches/0020-Use-ranlib-from-env-if-env-variable-is-set.patch
- patches/0021-roll-back-2e33ecd-for-py_compile.main.patch
# Python 3.8 is pretty broken without this.
# - patches/0022-Add-CondaEcosystemModifyDllSearchPath.patch
# - patches/0026-Revert-part-of-https-bugs.python.org-issue33895-http.patch
# Python 3.9 won't work on conda without this.
- patches/0022-Add-CondaEcosystemModifyDllSearchPath.patch
- patches/0026-Revert-part-of-https-bugs.python.org-issue33895-http.patch
- patches/0027-cross-compile-darwin.patch
- patches/gh21114.patch
- patches/gh21241.patch
Expand Down
78 changes: 29 additions & 49 deletions recipe/patches/0017-Unvendor-sqlite3.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
From c0f9f4c2a95741f31339ba6a1c86256c6b540f09 Mon Sep 17 00:00:00 2001
From: Nehal J Wani <[email protected]>
Date: Mon, 10 Dec 2018 12:22:37 -0600
Subject: [PATCH 17/22] Unvendor sqlite3

---
PCbuild/_sqlite3.vcxproj | 9 ++++-----
PCbuild/pcbuild.sln | 2 --
PCbuild/python.props | 2 +-
PCbuild/sqlite3.vcxproj | 12 ++++++------
4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/PCbuild/_sqlite3.vcxproj b/PCbuild/_sqlite3.vcxproj
index 61df796..414a369 100644
--- a/PCbuild/_sqlite3.vcxproj
+++ b/PCbuild/_sqlite3.vcxproj
diff -Naur Python-3.9.0rc1.orig/PCbuild/pcbuild.sln Python-3.9.0rc1/PCbuild/pcbuild.sln
--- Python-3.9.0rc1.orig/PCbuild/pcbuild.sln 2020-08-11 15:58:17.000000000 -0300
+++ Python-3.9.0rc1/PCbuild/pcbuild.sln 2020-09-16 16:52:52.767215971 -0300
@@ -57,8 +57,6 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcxproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcxproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_multiprocessing", "_multiprocessing.vcxproj", "{9E48B300-37D1-11DD-8C41-005056C00008}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python3dll", "python3dll.vcxproj", "{885D4898-D08D-4091-9C40-C700CFE3FC5A}"
diff -Naur Python-3.9.0rc1.orig/PCbuild/python.props Python-3.9.0rc1/PCbuild/python.props
--- Python-3.9.0rc1.orig/PCbuild/python.props 2020-08-11 15:58:17.000000000 -0300
+++ Python-3.9.0rc1/PCbuild/python.props 2020-09-16 16:54:20.154491752 -0300
@@ -56,7 +56,6 @@
<ExternalsDir>$(EXTERNALS_DIR)</ExternalsDir>
<ExternalsDir Condition="$(ExternalsDir) == ''">$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals`))</ExternalsDir>
<ExternalsDir Condition="!HasTrailingSlash($(ExternalsDir))">$(ExternalsDir)\</ExternalsDir>
- <sqlite3Dir>$(ExternalsDir)sqlite-3.32.3.0\</sqlite3Dir>
<bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
<lzmaDir>$(ExternalsDir)xz-5.2.2\</lzmaDir>
<libffiDir>$(ExternalsDir)libffi\</libffiDir>
diff -Naur Python-3.9.0rc1.orig/PCbuild/_sqlite3.vcxproj Python-3.9.0rc1/PCbuild/_sqlite3.vcxproj
--- Python-3.9.0rc1.orig/PCbuild/_sqlite3.vcxproj 2020-08-11 15:58:17.000000000 -0300
+++ Python-3.9.0rc1/PCbuild/_sqlite3.vcxproj 2020-09-16 16:51:11.640769649 -0300
@@ -93,9 +93,12 @@
</PropertyGroup>
<ItemDefinitionGroup>
Expand All @@ -39,36 +49,9 @@ index 61df796..414a369 100644
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/PCbuild/pcbuild.sln b/PCbuild/pcbuild.sln
index 477a107..37f1867 100644
--- a/PCbuild/pcbuild.sln
+++ b/PCbuild/pcbuild.sln
@@ -57,8 +57,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bdist_wininst", "..\PC\bdis
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcxproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcxproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_multiprocessing", "_multiprocessing.vcxproj", "{9E48B300-37D1-11DD-8C41-005056C00008}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python3dll", "python3dll.vcxproj", "{885D4898-D08D-4091-9C40-C700CFE3FC5A}"
diff --git a/PCbuild/python.props b/PCbuild/python.props
index b4a757a..caa3be4 100644
--- a/PCbuild/python.props
+++ b/PCbuild/python.props
@@ -56,7 +56,7 @@
<ExternalsDir>$(EXTERNALS_DIR)</ExternalsDir>
<ExternalsDir Condition="$(ExternalsDir) == ''">$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals`))</ExternalsDir>
<ExternalsDir Condition="!HasTrailingSlash($(ExternalsDir))">$(ExternalsDir)\</ExternalsDir>
- <sqlite3Dir>$(ExternalsDir)sqlite-3.31.1.0\</sqlite3Dir>
+ <sqlite3Dir>$(SQLITE3_DIR)\</sqlite3Dir>
<bz2Dir>$(ExternalsDir)bzip2-1.0.6\</bz2Dir>
<lzmaDir>$(ExternalsDir)xz-5.2.2\</lzmaDir>
<libffiDir>$(ExternalsDir)libffi\</libffiDir>
diff --git a/PCbuild/sqlite3.vcxproj b/PCbuild/sqlite3.vcxproj
index 1a82a65..497071a 100644
--- a/PCbuild/sqlite3.vcxproj
+++ b/PCbuild/sqlite3.vcxproj
diff -Naur Python-3.9.0rc1.orig/PCbuild/sqlite3.vcxproj Python-3.9.0rc1/PCbuild/sqlite3.vcxproj
--- Python-3.9.0rc1.orig/PCbuild/sqlite3.vcxproj 2020-08-11 15:58:17.000000000 -0300
+++ Python-3.9.0rc1/PCbuild/sqlite3.vcxproj 2020-09-16 16:54:50.758355443 -0300
@@ -88,12 +88,12 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
Expand All @@ -88,6 +71,3 @@ index 1a82a65..497071a 100644
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
--
2.20.1

47 changes: 13 additions & 34 deletions recipe/patches/0022-Add-CondaEcosystemModifyDllSearchPath.patch
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
From 45076be3111fa0c00b8e868bdb7a4224edf8c6b0 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <[email protected]>
Date: Tue, 24 Dec 2019 18:37:17 +0100
Subject: [PATCH 22/22] Add CondaEcosystemModifyDllSearchPath()

This changes the DLL search order so that C:\Windows\System32 does not
get searched in before entries in PATH.

Reviewed by Kai Tietz 7.2.2019

Updated a bit to include other directories.
---
Modules/main.c | 384 +++++++++++++++++++++++++++++++++++++++++++
Python/dynload_win.c | 7 +-
2 files changed, 389 insertions(+), 2 deletions(-)

diff --git a/Modules/main.c b/Modules/main.c
index 5150587..6e75e54 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -20,6 +20,10 @@
diff -Naur Python-3.9.0rc1.orig/Modules/main.c Python-3.9.0rc1/Modules/main.c
--- Python-3.9.0rc1.orig/Modules/main.c 2020-08-11 15:58:17.000000000 -0300
+++ Python-3.9.0rc1/Modules/main.c 2020-09-16 17:38:08.794223687 -0300
@@ -17,6 +17,10 @@
#endif
#ifdef MS_WINDOWS
# include <windows.h> /* STATUS_CONTROL_C_EXIT */
# include <windows.h> // STATUS_CONTROL_C_EXIT
+# include <shlwapi.h>
+# include <string.h>
+# include <malloc.h>
+# include <libloaderapi.h>
#endif
/* End of includes for exit_sigint() */

@@ -31,6 +35,8 @@
@@ -28,6 +32,8 @@
extern "C" {
#endif

Expand All @@ -38,7 +21,7 @@ index 5150587..6e75e54 100644
/* --- pymain_init() ---------------------------------------------- */

static PyStatus
@@ -699,10 +705,388 @@ Py_RunMain(void)
@@ -687,10 +693,388 @@
return exitcode;
}

Expand Down Expand Up @@ -427,11 +410,10 @@ index 5150587..6e75e54 100644
PyStatus status = pymain_init(args);
if (_PyStatus_IS_EXIT(status)) {
pymain_free();
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index 4896c6d..cf5cb5c 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -199,10 +199,13 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
diff -Naur Python-3.9.0rc1.orig/Python/dynload_win.c Python-3.9.0rc1/Python/dynload_win.c
--- Python-3.9.0rc1.orig/Python/dynload_win.c 2020-08-11 15:58:17.000000000 -0300
+++ Python-3.9.0rc1/Python/dynload_win.c 2020-09-16 19:19:24.931179882 -0300
@@ -187,10 +187,13 @@
to avoid DLL preloading attacks and enable use of the
AddDllDirectory function. We add SEARCH_DLL_LOAD_DIR to
ensure DLLs adjacent to the PYD are preferred. */
Expand All @@ -445,8 +427,5 @@ index 4896c6d..cf5cb5c 100644
- LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
+ LOAD_WITH_ALTERED_SEARCH_PATH);
Py_END_ALLOW_THREADS
#if HAVE_SXS
_Py_DeactivateActCtx(cookie);
--
2.20.1


/* restore old error mode settings */
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
From 24b3965a20114878dd6c31b07f4386074aa97fb4 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <[email protected]>
Date: Tue, 18 Feb 2020 17:38:32 +0100
Subject: [PATCH 26/26] Revert part of https://bugs.python.org/issue33895
https://github.com/python/cpython/commit/4860f01ac0f07cdc8fc0cc27c33f5a64e5cfec9f

LIEF crashes because Python code gets called from its static initialization code (CreateModule2 gets called, more?)

So we disable some of this commit and add a new env. var CONDA_DLL_SEARCH_MODIFICATION_DROP_GIL_AS_PER_UPSTREAM
to revert to upstream's decision here.

There really isn't any way to get the ProcAddress without allowing static initialization to happen and
for LIEF, that calls back into Python. It is unclear why this isn't a problem for other extension modules.
This could be an issue with LIEF too, of course.

Pinging @tonyroberts, @romainthomas and @zooba for your thoughts.

This issue has been a bit of a nightmare for me. In the process I did make great strides making our CPython
more debuggable which should pay off in future.
---
Python/dynload_win.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index 56d8913455..dd5b200861 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -190,6 +190,11 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
#if HAVE_SXS
ULONG_PTR cookie = 0;
#endif
--- Python-3.9.0rc1.orig/Python/dynload_win.c 2020-08-11 15:58:17.000000000 -0300
+++ Python-3.9.0rc1/Python/dynload_win.c 2020-09-16 19:22:11.452938237 -0300
@@ -179,6 +179,11 @@
{
HINSTANCE hDLL = NULL;
unsigned int old_mode;
+ /* The fix in https://bugs.python.org/issue33895 breaks 'import lief'. The fix means that any static initialization
+ cannot call into Python (or if it does it needs to aquire the GIL itself.
+ Other worse ideas:
Expand All @@ -37,19 +12,19 @@ index 56d8913455..dd5b200861 100644

/* Don't display a message box when Python can't load a DLL */
old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
@@ -202,13 +207,21 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
@@ -187,11 +192,20 @@
to avoid DLL preloading attacks and enable use of the
AddDllDirectory function. We add SEARCH_DLL_LOAD_DIR to
ensure DLLs adjacent to the PYD are preferred. */
/* This resyncs values in PATH to AddDllDirectory() */
+
+
extern int CondaEcosystemModifyDllSearchPath(int, int);
CondaEcosystemModifyDllSearchPath(1, 1);

- Py_BEGIN_ALLOW_THREADS
- hDLL = LoadLibraryExW(wpathname, NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH);
- LOAD_LIBRARY_SEARCH_DEFAULT_DIRS |
- LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
- Py_END_ALLOW_THREADS
+ /* This resyncs values in PATH to AddDllDirectory() */
+ extern int CondaEcosystemModifyDllSearchPath(int, int);
+ CondaEcosystemModifyDllSearchPath(1, 1);
+
+ if (drop_gil) {
+ Py_BEGIN_ALLOW_THREADS
+ hDLL = LoadLibraryExW(wpathname, NULL,
Expand All @@ -60,9 +35,6 @@ index 56d8913455..dd5b200861 100644
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+ }
+
#if HAVE_SXS
_Py_DeactivateActCtx(cookie);
#endif
--
2.23.0


/* restore old error mode settings */
SetErrorMode(old_mode);

0 comments on commit 2888305

Please sign in to comment.