2019-03-13 19:15:17 -04:00
|
|
|
# Support code for building a C extension with crypto code
|
2019-03-11 22:15:59 -04:00
|
|
|
|
|
|
|
|
import os
|
2019-08-25 17:57:05 -04:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
is_win32 = sys.platform.startswith('win32')
|
2019-03-11 22:15:59 -04:00
|
|
|
|
|
|
|
|
|
2019-03-13 19:15:17 -04:00
|
|
|
def multi_join(paths, *path_segments):
|
|
|
|
|
"""apply os.path.join on a list of paths"""
|
|
|
|
|
return [os.path.join(*(path_segments + (path,))) for path in paths]
|
|
|
|
|
|
|
|
|
|
|
2019-03-15 16:23:46 -04:00
|
|
|
def crypto_ext_kwargs(pc, system_prefix):
|
2019-03-11 22:15:59 -04:00
|
|
|
if system_prefix:
|
2019-03-13 00:40:25 -04:00
|
|
|
print('Detected OpenSSL [via BORG_OPENSSL_PREFIX]')
|
2019-08-25 17:57:05 -04:00
|
|
|
if is_win32:
|
|
|
|
|
lib_dir = system_prefix
|
|
|
|
|
lib_name = 'libcrypto'
|
|
|
|
|
else:
|
|
|
|
|
lib_dir = os.path.join(system_prefix, 'lib')
|
|
|
|
|
lib_name = 'crypto'
|
|
|
|
|
|
2019-03-13 00:40:25 -04:00
|
|
|
return dict(include_dirs=[os.path.join(system_prefix, 'include')],
|
2019-08-25 17:57:05 -04:00
|
|
|
library_dirs=[lib_dir],
|
|
|
|
|
libraries=[lib_name])
|
2019-03-13 00:40:25 -04:00
|
|
|
|
2019-03-13 18:59:04 -04:00
|
|
|
if pc and pc.exists('libcrypto'):
|
2019-03-13 00:40:25 -04:00
|
|
|
print('Detected OpenSSL [via pkg-config]')
|
2019-03-13 18:59:04 -04:00
|
|
|
return pc.parse('libcrypto')
|
2019-03-11 22:15:59 -04:00
|
|
|
|
2019-03-13 00:40:25 -04:00
|
|
|
raise Exception('Could not find OpenSSL lib/headers, please set BORG_OPENSSL_PREFIX')
|