Blame 0845-Remove-compiler-lib-dirs-from-extension-lib-dirs.patch

ddb6764
diff -rupN Python-2.7.13/setup.py Python-2.7.13-new/setup.py
ddb6764
--- Python-2.7.13/setup.py	2017-01-21 01:46:13.750530214 +0100
ddb6764
+++ Python-2.7.13-new/setup.py	2017-01-21 01:46:13.751530204 +0100
ddb6764
@@ -1840,6 +1840,23 @@ class PyBuildExt(build_ext):
ddb6764
         if '_tkinter' not in [e.name for e in self.extensions]:
ddb6764
             missing.append('_tkinter')
ddb6764
 
ddb6764
+        # Remove any extensions.library_dirs that are also in compiler.library_dirs
ddb6764
+        # Rationale: It's wrong. Ok, better. The compiler.library_dirs appear first
ddb6764
+        #            in the link command line and (finally, not yet) include "." which
ddb6764
+        #            causes the build dir to be searched in for -lpython2.7 before
ddb6764
+        #            $sysroot/lib. This is necessary as otherwise the old python import
ddb6764
+        #            library is used instead of the new one. This affects sqlite (and
ddb6764
+        #            some others). I could go into fixing these individually .. but I
ddb6764
+        #            worry I'll be back here in 6 months fixing the same bug again if
ddb6764
+        #            I do for some other module(s) in Python 2.7.12. In our case,
ddb6764
+        #            C:/msys64/mingw64/lib was turning up as that's where libsqlite was
ddb6764
+        #            and this prevented me from switching from an installed release to
ddb6764
+        #            an new debug Python. We should be building in clean sysroots but
ddb6764
+        #            that's another matter really.
ddb6764
+        for ext in self.extensions:
ddb6764
+            ext.library_dirs = [dir for dir in ext.library_dirs
ddb6764
+                                if dir not in self.compiler.library_dirs]
ddb6764
+
ddb6764
 ##         # Uncomment these lines if you want to play with xxmodule.c
ddb6764
 ##         ext = Extension('xx', ['xxmodule.c'])
ddb6764
 ##         self.extensions.append(ext)