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