setup_crypto.py 691 B

1234567891011121314151617181920
  1. # Support code for building a C extension with crypto from OpenSSL / LibreSSL
  2. import os
  3. def crypto_ext_kwargs():
  4. system_prefix = os.environ.get('BORG_OPENSSL_PREFIX')
  5. if system_prefix:
  6. print('Detected OpenSSL [via BORG_OPENSSL_PREFIX]')
  7. return dict(include_dirs=[os.path.join(system_prefix, 'include')],
  8. library_dirs=[os.path.join(system_prefix, 'lib')],
  9. libraries=['crypto'])
  10. import pkgconfig
  11. if pkgconfig.exists('libcrypto'):
  12. print('Detected OpenSSL [via pkg-config]')
  13. return pkgconfig.parse('libcrypto')
  14. raise Exception('Could not find OpenSSL lib/headers, please set BORG_OPENSSL_PREFIX')