@@ -29,27 +29,6 @@ def add_dir_to_list(dirlist, dir):
2929 if dir is not None and os .path .isdir (dir ) and dir not in dirlist :
3030 dirlist .insert (0 , dir )
3131
32- def macosx_sdk_root ():
33- """
34- Return the directory of the current OSX SDK,
35- or '/' if no SDK was specified.
36- """
37- cflags = sysconfig .get_config_var ('CFLAGS' )
38- m = re .search (r'-isysroot\s+(\S+)' , cflags )
39- if m is None :
40- sysroot = '/'
41- else :
42- sysroot = m .group (1 )
43- return sysroot
44-
45- def is_macosx_sdk_path (path ):
46- """
47- Returns True if 'path' can be located in an OSX SDK
48- """
49- return path .startswith ('/usr/' ) or path .startswith ('/System/' )
50-
51-
52-
5332def find_file (filename , std_dirs , paths ):
5433 """Searches for the directory where a given file is located,
5534 and returns a possibly-empty list of additional directories, or None
@@ -61,28 +40,15 @@ def find_file(filename, std_dirs, paths):
6140 'paths' is a list of additional locations to check; if the file is
6241 found in one of them, the resulting list will contain the directory.
6342 """
64- if sys .platform == 'darwin' :
65- # Honor the MacOSX SDK setting when one was specified.
66- # An SDK is a directory with the same structure as a real
67- # system, but with only header files and libraries.
68- sysroot = macosx_sdk_root ()
6943
7044 # Check the standard locations
7145 for dir in std_dirs :
7246 f = os .path .join (dir , filename )
73-
74- if sys .platform == 'darwin' and is_macosx_sdk_path (dir ):
75- f = os .path .join (sysroot , dir [1 :], filename )
76-
7747 if os .path .exists (f ): return []
7848
7949 # Check the additional directories
8050 for dir in paths :
8151 f = os .path .join (dir , filename )
82-
83- if sys .platform == 'darwin' and dir .startswith ('/System' ) or dir .startswith ('/usr' ):
84- f = os .path .join (sysroot , dir [1 :], filename )
85-
8652 if os .path .exists (f ):
8753 return [dir ]
8854
@@ -94,19 +60,11 @@ def find_library_file(compiler, libname, std_dirs, paths):
9460 if result is None :
9561 return None
9662
97- if sys .platform == 'darwin' :
98- sysroot = macosx_sdk_root ()
99-
10063 # Check whether the found file is in one of the standard directories
10164 dirname = os .path .dirname (result )
10265 for p in std_dirs :
10366 # Ensure path doesn't end with path separator
10467 p = p .rstrip (os .sep )
105-
106- if sys .platform == 'darwin' and is_macosx_sdk_path (p ):
107- if os .path .join (sysroot , p [1 :]) == dirname :
108- return [ ]
109-
11068 if p == dirname :
11169 return [ ]
11270
@@ -115,11 +73,6 @@ def find_library_file(compiler, libname, std_dirs, paths):
11573 for p in paths :
11674 # Ensure path doesn't end with path separator
11775 p = p .rstrip (os .sep )
118-
119- if sys .platform == 'darwin' and is_macosx_sdk_path (p ):
120- if os .path .join (sysroot , p [1 :]) == dirname :
121- return [ p ]
122-
12376 if p == dirname :
12477 return [p ]
12578 else :
@@ -607,7 +560,7 @@ def detect_modules(self):
607560 # library and then a static library, instead of first looking
608561 # for dynamic libraries on the entiry path.
609562 # This way a staticly linked custom readline gets picked up
610- # before the (possibly broken) dynamic library in /usr/lib.
563+ # before the (broken) dynamic library in /usr/lib.
611564 readline_extra_link_args = ('-Wl,-search_paths_first' ,)
612565 else :
613566 readline_extra_link_args = ()
@@ -678,20 +631,24 @@ def detect_modules(self):
678631 openssl_ver = 0
679632 openssl_ver_re = re .compile (
680633 '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' )
634+ for ssl_inc_dir in inc_dirs + search_for_ssl_incs_in :
635+ name = os .path .join (ssl_inc_dir , 'openssl' , 'opensslv.h' )
636+ if os .path .isfile (name ):
637+ try :
638+ incfile = open (name , 'r' )
639+ for line in incfile :
640+ m = openssl_ver_re .match (line )
641+ if m :
642+ openssl_ver = eval (m .group (1 ))
643+ break
644+ except IOError :
645+ pass
681646
682- # look for the openssl version header on the compiler search path.
683- opensslv_h = find_file ('openssl/opensslv.h' , inc_dirs , search_for_ssl_incs_in )
684- if opensslv_h :
685- name = opensslv_h [0 ]
686- try :
687- incfile = open (name , 'r' )
688- for line in incfile :
689- m = openssl_ver_re .match (line )
690- if m :
691- openssl_ver = eval (m .group (1 ))
692- except IOError :
693- pass
647+ # first version found is what we'll use (as the compiler should)
648+ if openssl_ver :
649+ break
694650
651+ #print 'openssl_ver = 0x%08x' % openssl_ver
695652 min_openssl_ver = 0x00907000
696653 have_any_openssl = ssl_incs is not None and ssl_libs is not None
697654 have_usable_openssl = (have_any_openssl and
@@ -824,19 +781,12 @@ def gen_db_minor_ver_nums(major):
824781
825782 db_ver_inc_map = {}
826783
827- if sys .platform == 'darwin' :
828- sysroot = macosx_sdk_root ()
829-
830784 class db_found (Exception ): pass
831785 try :
832786 # See whether there is a Sleepycat header in the standard
833787 # search path.
834788 for d in inc_dirs + db_inc_paths :
835789 f = os .path .join (d , "db.h" )
836-
837- if sys .platform == 'darwin' and is_macosx_sdk_path (d ):
838- f = os .path .join (sysroot , d [1 :], "db.h" )
839-
840790 if db_setup_debug : print "db: looking for db.h in" , f
841791 if os .path .exists (f ):
842792 f = open (f ).read ()
@@ -883,20 +833,7 @@ class db_found(Exception): pass
883833 db_incdir .replace ("include" , 'lib64' ),
884834 db_incdir .replace ("include" , 'lib' ),
885835 ]
886-
887- if sys .platform != 'darwin' :
888- db_dirs_to_check = filter (os .path .isdir , db_dirs_to_check )
889-
890- else :
891- # Same as other branch, but takes OSX SDK into account
892- tmp = []
893- for dn in db_dirs_to_check :
894- if is_macosx_sdk_path (dn ):
895- if os .path .isdir (os .path .join (sysroot , dn [1 :])):
896- tmp .append (dn )
897- else :
898- if os .path .isdir (dn ):
899- tmp .append (dn )
836+ db_dirs_to_check = filter (os .path .isdir , db_dirs_to_check )
900837
901838 # Look for a version specific db-X.Y before an ambiguoius dbX
902839 # XXX should we -ever- look for a dbX name? Do any
@@ -958,15 +895,8 @@ class db_found(Exception): pass
958895 # Scan the default include directories before the SQLite specific
959896 # ones. This allows one to override the copy of sqlite on OSX,
960897 # where /usr/include contains an old version of sqlite.
961- if sys .platform == 'darwin' :
962- sysroot = macosx_sdk_root ()
963-
964898 for d in inc_dirs + sqlite_inc_paths :
965899 f = os .path .join (d , "sqlite3.h" )
966-
967- if sys .platform == 'darwin' and is_macosx_sdk_path (d ):
968- f = os .path .join (sysroot , d [1 :], "sqlite3.h" )
969-
970900 if os .path .exists (f ):
971901 if sqlite_setup_debug : print "sqlite: found %s" % f
972902 incf = open (f ).read ()
@@ -1054,12 +984,6 @@ class db_found(Exception): pass
1054984 # the more recent berkeleydb's db.h file first in the include path
1055985 # when attempting to compile and it will fail.
1056986 f = "/usr/include/db.h"
1057-
1058- if sys .platform == 'darwin' :
1059- if is_macosx_sdk_path (f ):
1060- sysroot = macosx_sdk_root ()
1061- f = os .path .join (sysroot , f [1 :])
1062-
1063987 if os .path .exists (f ) and not db_incs :
1064988 data = open (f ).read ()
1065989 m = re .search (r"#s*define\s+HASHVERSION\s+2\s*" , data )
@@ -1566,22 +1490,14 @@ def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
15661490 join (os .getenv ('HOME' ), '/Library/Frameworks' )
15671491 ]
15681492
1569- sysroot = macosx_sdk_root ()
1570-
15711493 # Find the directory that contains the Tcl.framework and Tk.framework
15721494 # bundles.
15731495 # XXX distutils should support -F!
15741496 for F in framework_dirs :
15751497 # both Tcl.framework and Tk.framework should be present
1576-
1577-
15781498 for fw in 'Tcl' , 'Tk' :
1579- if is_macosx_sdk_path (F ):
1580- if not exists (join (sysroot , F [1 :], fw + '.framework' )):
1581- break
1582- else :
1583- if not exists (join (F , fw + '.framework' )):
1584- break
1499+ if not exists (join (F , fw + '.framework' )):
1500+ break
15851501 else :
15861502 # ok, F is now directory with both frameworks. Continure
15871503 # building
@@ -1611,12 +1527,7 @@ def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
16111527 # architectures.
16121528 cflags = sysconfig .get_config_vars ('CFLAGS' )[0 ]
16131529 archs = re .findall ('-arch\s+(\w+)' , cflags )
1614-
1615- if is_macosx_sdk_path (F ):
1616- fp = os .popen ("file %s/Tk.framework/Tk | grep 'for architecture'" % (os .path .join (sysroot , F [1 :]),))
1617- else :
1618- fp = os .popen ("file %s/Tk.framework/Tk | grep 'for architecture'" % (F ,))
1619-
1530+ fp = os .popen ("file %s/Tk.framework/Tk | grep 'for architecture'" % (F ,))
16201531 detected_archs = []
16211532 for ln in fp :
16221533 a = ln .split ()[- 1 ]
0 commit comments