summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJim Carroll <jim@caroll.com>2016-07-28 17:47:58 -0400
committerMatěj Cepl <mcepl@cepl.eu>2017-09-19 16:16:21 +0200
commitdde6115ca6be108e71e312ec59371edc580aba57 (patch)
treeda8ad6b23a6b4d5c555f011630fc80ae5d294fdb /setup.py
parent24ffc7d2b64918a3d557a31ae0027d72b340f01e (diff)
downloadm2crypto-dde6115ca6be108e71e312ec59371edc580aba57.tar.gz
Fixes of setup.py for OpenSSL 1.1.0 on RHEL-6.
* Added code to detect & set OPENSSL_VERSION_NUMBER * Changed windows builds to use official installation directory for OpenSSL 1.1.0 * Hacky solution for _MSC_VER setting on windows (will come up with something better shortly. * Took over the unused 'my_extra_compile_args' to silence MSVC, CRT_SECURE_WARNINGS * Changed to support 2.6 for CentOS (subprocess on 2.6 does not support check_output()) * Refined swig options that only belong to windows * Remove 'L' long integer suffix for python 3 build support * Fixup for python3 bytes vs string * Use <windows.i> instead of hacking around __inline issue. Swig provides <windows.i> which provides a collection of workarounds to Microsoft calling conventions. Make sure to include it BEFORE including safestack.h
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/setup.py b/setup.py
index 7b563f5..cf70fe5 100644
--- a/setup.py
+++ b/setup.py
@@ -13,6 +13,7 @@ Copyright 2008-2011 Heikki Toivonen. All rights reserved.
import glob
import os
import platform
+import re
import string
import subprocess
import sys
@@ -110,8 +111,20 @@ class _M2CryptoBuildExt(build_ext.build_ext):
# openssl is the attribute corresponding to openssl directory prefix
# command line option
if os.name == 'nt':
- self.libraries = ['ssleay32', 'libeay32']
- self.openssl = 'c:\\pkg'
+ if openssl_version('1.1.0'):
+ self.libraries = ['ssleay32', 'libeay32']
+ self.openssl = 'c:\\pkg'
+ else:
+ self.libraries = ['libssl', 'libcrypto']
+ if platform.architecture()[0] == '32bit':
+ self.openssl = os.environ.get('ProgramFiles(86)')
+ if not self.openssl:
+ self.openssl = os.environ.get('ProgramFiles')
+ else:
+ self.openssl = os.environ.get('ProgramW6432')
+ if not self.openssl:
+ raise RuntimeError('cannot detect platform')
+ self.openssl = os.path.join(self.openssl, 'OpenSSL')
else:
self.libraries = ['ssl', 'crypto']
self.openssl = '/usr'
@@ -159,6 +172,13 @@ class _M2CryptoBuildExt(build_ext.build_ext):
self.swig_opts.append('-modern')
self.swig_opts.append('-builtin')
+ # Swig doesn't know the version of MSVC, which causes errors in e_os2.h
+ # trying to import stdint.h. Since python 2.7 is intimately tied to
+ # MSVC 2008, it's harmless for now to define this. Will come back to
+ # this shortly to come up with a better fix.
+ if os.name == 'nt':
+ self.swig_opts.append('-D_MSC_VER=1500')
+
# These two lines are a workaround for
# http://bugs.python.org/issue2624 , hard-coding that we are only
# building a single extension with a known path; a proper patch to
@@ -214,9 +234,12 @@ def swig_version(req_ver):
if sys.platform == 'darwin':
- my_extra_compile_args = ["-Wno-deprecated-declarations"]
+ x_comp_args = ["-Wno-deprecated-declarations"]
+elif sys.platform == 'win32':
+ x_comp_args = ['-DTHREADING', '-D_CRT_SECURE_NO_WARNINGS']
else:
- my_extra_compile_args = []
+ x_comp_args = ['-DTHREADING']
+
# Don't try to run swig on the ancient platforms
if swig_version(REQUIRED_SWIG_VERSION):
@@ -227,7 +250,7 @@ else:
m2crypto = setuptools.Extension(name='M2Crypto._m2crypto',
sources=lib_sources,
- extra_compile_args=['-DTHREADING'],
+ extra_compile_args=x_comp_args,
# Uncomment to build Universal Mac binaries
# extra_link_args =
# ['-Wl,-search_paths_first'],