Skip to content

Instantly share code, notes, and snippets.

@rkitover
Last active February 4, 2021 09:59
Show Gist options
  • Save rkitover/2d9e5baff1f1cc4f2618dee53083bd35 to your computer and use it in GitHub Desktop.
Save rkitover/2d9e5baff1f1cc4f2618dee53083bd35 to your computer and use it in GitHub Desktop.
static openssl patch for python 2.7.14
diff -ruN Python-2.7.14.orig/setup.py Python-2.7.14.new/setup.py
--- Python-2.7.14.orig/setup.py 2017-09-16 10:38:35.000000000 -0700
+++ Python-2.7.14.new/setup.py 2017-11-16 07:48:31.368080272 -0800
@@ -808,10 +808,15 @@
depends=['socketmodule.h'],
libraries=math_libs) )
# Detect SSL support for the socket module (via _ssl)
+ openssl_root = os.getenv('OPENSSL_ROOT')
+
search_for_ssl_incs_in = [
'/usr/local/ssl/include',
'/usr/contrib/ssl/include/'
]
+ if openssl_root is not None:
+ search_for_ssl_incs_in.insert(0, os.path.join(openssl_root, 'include'))
+
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
search_for_ssl_incs_in
)
@@ -824,14 +829,25 @@
['/usr/local/ssl/lib',
'/usr/contrib/ssl/lib/'
] )
+ if openssl_root is not None:
+ ssl_libs.insert(0, os.path.join(openssl_root, 'lib'))
if (ssl_incs is not None and
ssl_libs is not None):
- exts.append( Extension('_ssl', ['_ssl.c'],
- include_dirs = ssl_incs,
- library_dirs = ssl_libs,
- libraries = ['ssl', 'crypto'],
- depends = ['socketmodule.h']), )
+ if openssl_root is not None:
+ exts.append( Extension('_ssl', ['_ssl.c'],
+ include_dirs = ssl_incs,
+ library_dirs = [],
+ libraries = [],
+ extra_link_args = [ os.path.join(openssl_root, 'lib/libssl.a'),
+ os.path.join(openssl_root, 'lib/libcrypto.a'), '-ldl' ],
+ depends = ['socketmodule.h']))
+ else:
+ exts.append( Extension('_ssl', ['_ssl.c'],
+ include_dirs = ssl_incs,
+ library_dirs = ssl_libs,
+ libraries = ['ssl', 'crypto'],
+ depends = ['socketmodule.h']))
else:
missing.append('_ssl')
@@ -866,10 +882,18 @@
if have_usable_openssl:
# The _hashlib module wraps optimized implementations
# of hash functions from the OpenSSL library.
- exts.append( Extension('_hashlib', ['_hashopenssl.c'],
- include_dirs = ssl_incs,
- library_dirs = ssl_libs,
- libraries = ['ssl', 'crypto']) )
+ if openssl_root is not None:
+ exts.append( Extension('_hashlib', ['_hashopenssl.c'],
+ include_dirs = ssl_incs,
+ library_dirs = [],
+ libraries = [],
+ extra_link_args = [ os.path.join(openssl_root, 'lib/libssl.a'),
+ os.path.join(openssl_root, 'lib/libcrypto.a'), '-ldl' ]))
+ else:
+ exts.append( Extension('_hashlib', ['_hashopenssl.c'],
+ include_dirs = ssl_incs,
+ library_dirs = ssl_libs,
+ libraries = ['ssl', 'crypto']))
else:
print ("warning: openssl 0x%08x is too old for _hashlib" %
openssl_ver)
@rkitover
Copy link
Author

@rkitover
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment