setup_crypto.py 827 B

123456789101112131415161718192021222324252627
  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 crypto_ext_kwargs(pc, system_prefix):
  6. if system_prefix:
  7. print('Detected OpenSSL [via BORG_OPENSSL_PREFIX]')
  8. if is_win32:
  9. lib_dir = system_prefix
  10. lib_name = 'libcrypto'
  11. else:
  12. lib_dir = os.path.join(system_prefix, 'lib')
  13. lib_name = 'crypto'
  14. return dict(include_dirs=[os.path.join(system_prefix, 'include')],
  15. library_dirs=[lib_dir],
  16. libraries=[lib_name])
  17. if pc and pc.exists('libcrypto'):
  18. print('Detected OpenSSL [via pkg-config]')
  19. return pc.parse('libcrypto')
  20. raise Exception('Could not find OpenSSL lib/headers, please set BORG_OPENSSL_PREFIX')