Skip to content

Instantly share code, notes, and snippets.

@romuloceccon
Created December 14, 2017 13:22
Show Gist options
  • Select an option

  • Save romuloceccon/a7a116288136fb668cfb45db27281dd4 to your computer and use it in GitHub Desktop.

Select an option

Save romuloceccon/a7a116288136fb668cfb45db27281dd4 to your computer and use it in GitHub Desktop.
A patch to compile Python 2.6 in a 64-bit Linux distribution with a custom OpenSSL version
--- a/setup.py 2013-10-29 16:04:39.000000000 +0100
+++ b/setup.py 2017-12-14 12:30:22.280645847 +0100
@@ -137,6 +137,20 @@
log.info("WARNING: multiple copies of %s found"%module)
return os.path.join(list[0], module)
+def find_compiler_search_dirs(compiler):
+ child = os.popen('%s -Xlinker --verbose 2>&1' % (compiler,))
+
+ for line in child.read().split('\n'):
+ if line.find('SEARCH') < 0:
+ continue
+ for dir in line.split(';'):
+ p = dir.find('(')
+ q = dir.rfind(')')
+ if p >= 0 and p < q:
+ yield dir[p + 3:q - 1]
+
+ child.close()
+
class PyBuildExt(build_ext):
def __init__(self, dist):
@@ -355,9 +369,8 @@
return sys.platform
def detect_modules(self):
- # Ensure that /usr/local is always used
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+ for dir in find_compiler_search_dirs(self.compiler.compiler[0]):
+ add_dir_to_list(self.compiler.library_dirs, dir)
# Add paths specified in the environment variables LDFLAGS and
# CPPFLAGS for header and library files.
--- a/Modules/Setup.dist 2013-10-29 16:04:38.000000000 +0100
+++ b/Modules/Setup.dist 2017-12-14 14:09:03.496776308 +0100
@@ -207,14 +207,17 @@
#_csv _csv.c
# Socket module helper for socket(2)
-#_socket socketmodule.c
+_socket socketmodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
-#SSL=/usr/local/ssl
-#_ssl _ssl.c \
-# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-# -L$(SSL)/lib -lssl -lcrypto
+SSL=/home/romulo/opt/openssl/openssl-0.9.8zh
+_ssl _ssl.c \
+ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
+ -L$(SSL)/lib -lssl -lcrypto -Wl,-rpath,$(SSL)/lib
+_hashlib _hashopenssl.c \
+ -I$(SSL)/include \
+ -L$(SSL)/lib -lssl -lcrypto -Wl,-rpath,$(SSL)/lib
# The crypt module is now disabled by default because it breaks builds
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment