1--- misc/Python-2.7.9/setup.py	2013-07-01 17:51:46.237674580 +0200
2+++ misc/build/Python-2.7.9/setup.py	2013-07-01 17:51:24.230453108 +0200
3@@ -80,61 +80,62 @@
4         # system, but with only header files and libraries.
5         sysroot = macosx_sdk_root()
6
7-    # Check the standard locations
8-    for dir in std_dirs:
9+    # Check the additional directories
10+    for dir in paths:
11         f = os.path.join(dir, filename)
12
13         if host_platform == 'darwin' and is_macosx_sdk_path(dir):
14             f = os.path.join(sysroot, dir[1:], filename)
15
16-        if os.path.exists(f): return []
17+        if os.path.exists(f):
18+            return [dir]
19
20-    # Check the additional directories
21-    for dir in paths:
22+    # Check the standard locations
23+    for dir in std_dirs:
24         f = os.path.join(dir, filename)
25
26         if host_platform == 'darwin' and is_macosx_sdk_path(dir):
27             f = os.path.join(sysroot, dir[1:], filename)
28
29         if os.path.exists(f):
30-            return [dir]
31+            return []
32
33     # Not found anywhere
34     return None
35
36 def find_library_file(compiler, libname, std_dirs, paths):
37-    result = compiler.find_library_file(std_dirs + paths, libname)
38+    result = compiler.find_library_file(paths+std_dirs, libname)
39     if result is None:
40         return None
41
42     if host_platform == 'darwin':
43         sysroot = macosx_sdk_root()
44
45-    # Check whether the found file is in one of the standard directories
46     dirname = os.path.dirname(result)
47-    for p in std_dirs:
48+    # Otherwise, it must have been in one of the additional directories,
49+    # so we have to figure out which one.
50+    for p in paths:
51         # Ensure path doesn't end with path separator
52         p = p.rstrip(os.sep)
53
54         if host_platform == 'darwin' and is_macosx_sdk_path(p):
55             if os.path.join(sysroot, p[1:]) == dirname:
56-                return [ ]
57+                return [ p ]
58
59         if p == dirname:
60-            return [ ]
61+            return [p]
62
63-    # Otherwise, it must have been in one of the additional directories,
64-    # so we have to figure out which one.
65-    for p in paths:
66+    # Check whether the found file is in one of the standard directories
67+    for p in std_dirs:
68         # Ensure path doesn't end with path separator
69         p = p.rstrip(os.sep)
70
71         if host_platform == 'darwin' and is_macosx_sdk_path(p):
72             if os.path.join(sysroot, p[1:]) == dirname:
73-                return [ p ]
74+                return [ ]
75
76         if p == dirname:
77-            return [p]
78+            return [ ]
79     else:
80         assert False, "Internal error: Path not found in std_dirs or paths"
81
82@@ -810,6 +811,7 @@
83             exts.append( Extension('_ssl', ['_ssl.c'],
84                                    include_dirs = ssl_incs,
85                                    library_dirs = ssl_libs,
86+                                   extra_link_args = ['-Wl,--exclude-libs,ALL'],
87                                    libraries = ['ssl', 'crypto'],
88                                    depends = ['socketmodule.h']), )
89         else:
90@@ -849,6 +851,7 @@
91                 exts.append( Extension('_hashlib', ['_hashopenssl.c'],
92                                        include_dirs = ssl_incs,
93                                        library_dirs = ssl_libs,
94+                                       extra_link_args = ['-Wl,--exclude-libs,ALL'],
95                                        libraries = ['ssl', 'crypto']) )
96             else:
97                 print ("warning: openssl 0x%08x is too old for _hashlib" %
98