setup_crypto.py 988 B

1234567891011121314151617181920212223242526272829303132
  1. # Support code for building a C extension with crypto code
  2. import os
  3. import sys
  4. is_win32 = sys.platform.startswith('win32')
  5. def multi_join(paths, *path_segments):
  6. """apply os.path.join on a list of paths"""
  7. return [os.path.join(*(path_segments + (path,))) for path in paths]
  8. def crypto_ext_kwargs(pc, system_prefix):
  9. if system_prefix:
  10. print('Detected OpenSSL [via BORG_OPENSSL_PREFIX]')
  11. if is_win32:
  12. lib_dir = system_prefix
  13. lib_name = 'libcrypto'
  14. else:
  15. lib_dir = os.path.join(system_prefix, 'lib')
  16. lib_name = 'crypto'
  17. return dict(include_dirs=[os.path.join(system_prefix, 'include')],
  18. library_dirs=[lib_dir],
  19. libraries=[lib_name])
  20. if pc and pc.exists('libcrypto'):
  21. print('Detected OpenSSL [via pkg-config]')
  22. return pc.parse('libcrypto')
  23. raise Exception('Could not find OpenSSL lib/headers, please set BORG_OPENSSL_PREFIX')