1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-23 00:07:38 +00:00

cope with pkgconfig ImportError

This commit is contained in:
Thomas Waldmann 2019-03-13 23:59:04 +01:00
parent 2fd0cff4e3
commit 1579d58b3e
5 changed files with 22 additions and 24 deletions

View file

@ -152,16 +152,22 @@ def members_appended(*ds):
result[k].extend(v)
return result
try:
import pkgconfig as pc
except ImportError:
print('Warning: can not import pkgconfig python package.')
pc = None
crypto_ext_kwargs = members_appended(
dict(sources=[crypto_ll_source, crypto_helpers]),
setup_crypto.crypto_ext_kwargs(),
setup_b2.b2_ext_kwargs(prefer_system_libb2),
setup_crypto.crypto_ext_kwargs(pc),
setup_b2.b2_ext_kwargs(pc, prefer_system_libb2),
)
compress_ext_kwargs = members_appended(
dict(sources=[compress_source]),
setup_lz4.lz4_ext_kwargs(prefer_system_liblz4),
setup_zstd.zstd_ext_kwargs(prefer_system_libzstd, multithreaded=False, legacy=False),
setup_lz4.lz4_ext_kwargs(pc, prefer_system_liblz4),
setup_zstd.zstd_ext_kwargs(pc, prefer_system_libzstd, multithreaded=False, legacy=False),
)
ext_modules += [

View file

@ -21,7 +21,7 @@ def multi_join(paths, *path_segments):
return [os.path.join(*(path_segments + (path,))) for path in paths]
def b2_ext_kwargs(prefer_system):
def b2_ext_kwargs(pc, prefer_system):
if prefer_system:
system_prefix = os.environ.get('BORG_LIBB2_PREFIX')
if system_prefix:
@ -30,11 +30,9 @@ def b2_ext_kwargs(prefer_system):
library_dirs=[os.path.join(system_prefix, 'lib')],
libraries=['b2'])
import pkgconfig
if pkgconfig.installed('libb2', '>= 0.98.1'):
if pc and pc.installed('libb2', '>= 0.98.1'):
print('Detected and preferring libb2 [via pkg-config]')
return pkgconfig.parse('libb2')
return pc.parse('libb2')
print('Using bundled BLAKE2')
sources = multi_join(b2_sources, bundled_path)

View file

@ -3,7 +3,7 @@
import os
def crypto_ext_kwargs():
def crypto_ext_kwargs(pc):
system_prefix = os.environ.get('BORG_OPENSSL_PREFIX')
if system_prefix:
print('Detected OpenSSL [via BORG_OPENSSL_PREFIX]')
@ -11,10 +11,8 @@ def crypto_ext_kwargs():
library_dirs=[os.path.join(system_prefix, 'lib')],
libraries=['crypto'])
import pkgconfig
if pkgconfig.exists('libcrypto'):
if pc and pc.exists('libcrypto'):
print('Detected OpenSSL [via pkg-config]')
return pkgconfig.parse('libcrypto')
return pc.parse('libcrypto')
raise Exception('Could not find OpenSSL lib/headers, please set BORG_OPENSSL_PREFIX')

View file

@ -21,7 +21,7 @@ def multi_join(paths, *path_segments):
return [os.path.join(*(path_segments + (path,))) for path in paths]
def lz4_ext_kwargs(prefer_system):
def lz4_ext_kwargs(pc, prefer_system):
if prefer_system:
system_prefix = os.environ.get('BORG_LIBLZ4_PREFIX')
if system_prefix:
@ -30,11 +30,9 @@ def lz4_ext_kwargs(prefer_system):
library_dirs=[os.path.join(system_prefix, 'lib')],
libraries=['lz4'])
import pkgconfig
if pkgconfig.installed('liblz4', '>= 1.7.0'):
if pc and pc.installed('liblz4', '>= 1.7.0'):
print('Detected and preferring liblz4 [via pkg-config]')
return pkgconfig.parse('liblz4')
return pc.parse('liblz4')
print('Using bundled LZ4')
sources = multi_join(lz4_sources, bundled_path)

View file

@ -68,7 +68,7 @@ def multi_join(paths, *path_segments):
return [os.path.join(*(path_segments + (path,))) for path in paths]
def zstd_ext_kwargs(prefer_system, multithreaded=False, legacy=False):
def zstd_ext_kwargs(pc, prefer_system, multithreaded=False, legacy=False):
if prefer_system:
system_prefix = os.environ.get('BORG_LIBZSTD_PREFIX')
if system_prefix:
@ -77,11 +77,9 @@ def zstd_ext_kwargs(prefer_system, multithreaded=False, legacy=False):
library_dirs=[os.path.join(system_prefix, 'lib')],
libraries=['zstd'])
import pkgconfig
if pkgconfig.installed('libzstd', '>= 1.3.0'):
if pc and pc.installed('libzstd', '>= 1.3.0'):
print('Detected and preferring libzstd [via pkg-config]')
return pkgconfig.parse('libzstd')
return pc.parse('libzstd')
print('Using bundled ZSTD')
sources = multi_join(zstd_sources, bundled_path)