mirror of
https://github.com/borgbackup/borg.git
synced 2026-02-22 01:10:24 -05:00
1. BORG_*_PREFIX is checked (avoids lib detection via pkg-config). 2. pkg-config is tried 3. fallback to bundled C code (or failure in case of OpenSSL) also: - simplified code again - removed (c) headers, nothing left of original code
20 lines
691 B
Python
20 lines
691 B
Python
# Support code for building a C extension with crypto from OpenSSL / LibreSSL
|
|
|
|
import os
|
|
|
|
|
|
def crypto_ext_kwargs():
|
|
system_prefix = os.environ.get('BORG_OPENSSL_PREFIX')
|
|
if system_prefix:
|
|
print('Detected OpenSSL [via BORG_OPENSSL_PREFIX]')
|
|
return dict(include_dirs=[os.path.join(system_prefix, 'include')],
|
|
library_dirs=[os.path.join(system_prefix, 'lib')],
|
|
libraries=['crypto'])
|
|
|
|
import pkgconfig
|
|
|
|
if pkgconfig.exists('libcrypto'):
|
|
print('Detected OpenSSL [via pkg-config]')
|
|
return pkgconfig.parse('libcrypto')
|
|
|
|
raise Exception('Could not find OpenSSL lib/headers, please set BORG_OPENSSL_PREFIX')
|