Skip to content

Commit 20ea5b4

Browse files
i-shenlMatthewZMD
authored andcommitted
Remove ssl version checking and use ours from AS_DEPENDENCIES_DIR
1 parent 92599cd commit 20ea5b4

1 file changed

Lines changed: 22 additions & 50 deletions

File tree

setup.py

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -854,22 +854,24 @@ def detect_modules(self):
854854
depends=['socketmodule.h'],
855855
libraries=math_libs) )
856856
# Detect SSL support for the socket module (via _ssl)
857-
search_for_ssl_incs_in = [
858-
'/usr/local/ssl/include',
859-
'/usr/contrib/ssl/include/'
860-
]
861-
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
862-
search_for_ssl_incs_in
863-
)
857+
if 'AS_DEPENDENCIES_DIR' in os.environ:
858+
ssl_path = os.getenv('AS_DEPENDENCIES_DIR', '')
859+
search_for_ssl_incs_in = [os.path.join(ssl_path, "usr", "include")]
860+
search_for_ssl_libs_in = [os.path.join(ssl_path, "usr","lib")]
861+
else:
862+
search_for_ssl_incs_in = []
863+
search_for_ssl_libs_in = []
864+
865+
ssl_incs = find_file('openssl/ssl.h', [], search_for_ssl_incs_in)
866+
ssl_libs = find_library_file(self.compiler, 'ssl', [],
867+
search_for_ssl_libs_in)
868+
869+
864870
if ssl_incs is not None:
865871
krb5_h = find_file('krb5.h', inc_dirs,
866872
['/usr/kerberos/include'])
867873
if krb5_h:
868874
ssl_incs += krb5_h
869-
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
870-
['/usr/local/ssl/lib',
871-
'/usr/contrib/ssl/lib/'
872-
] )
873875

874876
if (ssl_incs is not None and
875877
ssl_libs is not None):
@@ -881,46 +883,17 @@ def detect_modules(self):
881883
else:
882884
missing.append('_ssl')
883885

884-
# find out which version of OpenSSL we have
885-
openssl_ver = 0
886-
openssl_ver_re = re.compile(
887-
'^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' )
888-
889-
# look for the openssl version header on the compiler search path.
890-
opensslv_h = find_file('openssl/opensslv.h', [],
891-
inc_dirs + search_for_ssl_incs_in)
892-
if opensslv_h:
893-
name = os.path.join(opensslv_h[0], 'openssl/opensslv.h')
894-
if host_platform == 'darwin' and is_macosx_sdk_path(name):
895-
name = os.path.join(macosx_sdk_root(), name[1:])
896-
try:
897-
incfile = open(name, 'r')
898-
for line in incfile:
899-
m = openssl_ver_re.match(line)
900-
if m:
901-
openssl_ver = eval(m.group(1))
902-
except IOError, msg:
903-
print "IOError while reading opensshv.h:", msg
904-
pass
905-
906-
min_openssl_ver = 0x00907000
907886
have_any_openssl = ssl_incs is not None and ssl_libs is not None
908-
have_usable_openssl = (have_any_openssl and
909-
openssl_ver >= min_openssl_ver)
910887

911888
if have_any_openssl:
912-
if have_usable_openssl:
913-
# The _hashlib module wraps optimized implementations
914-
# of hash functions from the OpenSSL library.
915-
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
916-
include_dirs = ssl_incs,
917-
library_dirs = ssl_libs,
918-
libraries = ['ssl', 'crypto']) )
919-
else:
920-
print ("warning: openssl 0x%08x is too old for _hashlib" %
921-
openssl_ver)
922-
missing.append('_hashlib')
923-
if COMPILED_WITH_PYDEBUG or not have_usable_openssl:
889+
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
890+
include_dirs = ssl_incs,
891+
library_dirs = ssl_libs,
892+
libraries = ['ssl', 'crypto']) )
893+
else:
894+
print ("Warning - no suitable openssl found for hashlib - omitting..")
895+
missing.append('_hashlib')
896+
if COMPILED_WITH_PYDEBUG or not have_any_openssl:
924897
# The _sha module implements the SHA1 hash algorithm.
925898
exts.append( Extension('_sha', ['shamodule.c']) )
926899
# The _md5 module implements the RSA Data Security, Inc. MD5
@@ -930,8 +903,7 @@ def detect_modules(self):
930903
sources = ['md5module.c', 'md5.c'],
931904
depends = ['md5.h']) )
932905

933-
min_sha2_openssl_ver = 0x00908000
934-
if COMPILED_WITH_PYDEBUG or openssl_ver < min_sha2_openssl_ver:
906+
if COMPILED_WITH_PYDEBUG:
935907
# OpenSSL doesn't do these until 0.9.8 so we'll bring our own hash
936908
exts.append( Extension('_sha256', ['sha256module.c']) )
937909
exts.append( Extension('_sha512', ['sha512module.c']) )

0 commit comments

Comments
 (0)