2019-03-13 23:28:59 +00:00
|
|
|
# borgbackup - main setup code (see also other setup_*.py files)
|
|
|
|
|
2011-08-20 16:11:23 +00:00
|
|
|
import os
|
2010-10-30 11:24:23 +00:00
|
|
|
import sys
|
2019-03-13 02:01:00 +00:00
|
|
|
from collections import defaultdict
|
2011-08-20 16:11:23 +00:00
|
|
|
from glob import glob
|
2011-11-06 20:40:29 +00:00
|
|
|
|
2018-04-28 16:06:10 +00:00
|
|
|
try:
|
|
|
|
import multiprocessing
|
|
|
|
except ImportError:
|
|
|
|
multiprocessing = None
|
|
|
|
|
|
|
|
from setuptools.command.build_ext import build_ext
|
|
|
|
from setuptools import setup, find_packages, Extension
|
|
|
|
from setuptools.command.sdist import sdist
|
2020-10-04 19:24:32 +00:00
|
|
|
from distutils.command.clean import clean
|
2018-04-28 16:06:10 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
from Cython.Build import cythonize
|
|
|
|
except ImportError:
|
|
|
|
cythonize = None
|
2015-10-07 23:55:56 +00:00
|
|
|
|
2019-06-03 21:37:46 +00:00
|
|
|
import setup_checksums
|
2019-03-13 23:15:17 +00:00
|
|
|
import setup_compress
|
2019-03-12 02:15:59 +00:00
|
|
|
import setup_crypto
|
2018-06-12 19:06:01 +00:00
|
|
|
import setup_docs
|
2017-12-05 03:16:25 +00:00
|
|
|
|
2019-08-08 22:01:38 +00:00
|
|
|
is_win32 = sys.platform.startswith('win32')
|
|
|
|
|
2019-03-15 20:23:46 +00:00
|
|
|
# How the build process finds the system libs / uses the bundled code:
|
|
|
|
#
|
|
|
|
# 1. it will try to use (system) libs (see 1.1. and 1.2.),
|
|
|
|
# except if you use these env vars to force using the bundled code:
|
|
|
|
# BORG_USE_BUNDLED_XXX undefined --> try using system lib
|
|
|
|
# BORG_USE_BUNDLED_XXX=YES --> use the bundled code
|
|
|
|
# Note: do not use =NO, that is not supported!
|
|
|
|
# 1.1. if BORG_LIBXXX_PREFIX is set, it will use headers and libs from there.
|
|
|
|
# 1.2. if not and pkg-config can locate the lib, the lib located by
|
|
|
|
# pkg-config will be used. We use the pkg-config tool via the pkgconfig
|
|
|
|
# python package, which must be installed before invoking setup.py.
|
|
|
|
# if pkgconfig is not installed, this step is skipped.
|
|
|
|
# 2. if no system lib could be located via 1.1. or 1.2., it will fall back
|
|
|
|
# to using the bundled code.
|
|
|
|
|
|
|
|
# OpenSSL is required as a (system) lib in any case as we do not bundle it.
|
|
|
|
# Thus, only step 1.1. and 1.2. apply to openssl (but not 1. and 2.).
|
|
|
|
# needed: openssl >=1.0.2 or >=1.1.0 (or compatible)
|
|
|
|
system_prefix_openssl = os.environ.get('BORG_OPENSSL_PREFIX')
|
|
|
|
|
|
|
|
# needed: blake2 (>= 0.98.1)
|
|
|
|
prefer_system_libb2 = not bool(os.environ.get('BORG_USE_BUNDLED_B2'))
|
|
|
|
system_prefix_libb2 = os.environ.get('BORG_LIBB2_PREFIX')
|
2017-12-15 05:35:20 +00:00
|
|
|
|
2019-03-15 18:54:33 +00:00
|
|
|
# needed: lz4 (>= 1.7.0 / r129)
|
|
|
|
prefer_system_liblz4 = not bool(os.environ.get('BORG_USE_BUNDLED_LZ4'))
|
2019-03-15 20:23:46 +00:00
|
|
|
system_prefix_liblz4 = os.environ.get('BORG_LIBLZ4_PREFIX')
|
2019-03-15 18:54:33 +00:00
|
|
|
|
|
|
|
# needed: zstd (>= 1.3.0)
|
|
|
|
prefer_system_libzstd = not bool(os.environ.get('BORG_USE_BUNDLED_ZSTD'))
|
2019-03-15 20:23:46 +00:00
|
|
|
system_prefix_libzstd = os.environ.get('BORG_LIBZSTD_PREFIX')
|
2017-12-17 02:06:12 +00:00
|
|
|
|
2019-06-03 21:37:46 +00:00
|
|
|
prefer_system_libxxhash = not bool(os.environ.get('BORG_USE_BUNDLED_XXHASH'))
|
|
|
|
system_prefix_libxxhash = os.environ.get('BORG_LIBXXHASH_PREFIX')
|
|
|
|
|
2019-08-08 22:01:38 +00:00
|
|
|
# Number of threads to use for cythonize, not used on windows
|
2018-04-28 16:06:10 +00:00
|
|
|
cpu_threads = multiprocessing.cpu_count() if multiprocessing else 1
|
|
|
|
|
2015-10-07 23:16:49 +00:00
|
|
|
# Are we building on ReadTheDocs?
|
2015-10-08 12:23:37 +00:00
|
|
|
on_rtd = os.environ.get('READTHEDOCS')
|
2015-10-07 23:16:49 +00:00
|
|
|
|
2017-07-29 09:55:26 +00:00
|
|
|
install_requires = [
|
2018-04-12 21:35:38 +00:00
|
|
|
# we are rather picky about msgpack versions, because a good working msgpack is
|
2019-02-05 01:37:22 +00:00
|
|
|
# very important for borg, see: https://github.com/borgbackup/borg/issues/3753
|
2020-04-04 16:43:36 +00:00
|
|
|
'msgpack >=0.5.6, <=1.0.0',
|
2019-02-02 22:52:16 +00:00
|
|
|
# Please note:
|
|
|
|
# using any other version is not supported by borg development and
|
|
|
|
# any feedback related to issues caused by this will be ignored.
|
2017-07-29 09:55:26 +00:00
|
|
|
]
|
2015-09-12 20:44:23 +00:00
|
|
|
|
2016-10-18 22:56:22 +00:00
|
|
|
# note for package maintainers: if you package borgbackup for distribution,
|
2020-10-10 21:12:47 +00:00
|
|
|
# please (if available) add pyfuse3 (preferably) or llfuse (not maintained any more)
|
|
|
|
# as a *requirement*. "borg mount" needs one of them to work.
|
|
|
|
# if neither is available, do not require it, most of borgbackup will work.
|
2016-02-07 18:03:32 +00:00
|
|
|
extras_require = {
|
2020-10-10 21:12:47 +00:00
|
|
|
'llfuse': [
|
|
|
|
'llfuse >= 1.3.8',
|
2018-06-12 02:29:16 +00:00
|
|
|
],
|
2020-10-10 21:12:47 +00:00
|
|
|
'pyfuse3': [
|
|
|
|
'pyfuse3 >= 3.1.1',
|
|
|
|
],
|
|
|
|
'nofuse': [],
|
2016-02-07 18:03:32 +00:00
|
|
|
}
|
2015-07-12 13:07:24 +00:00
|
|
|
|
2016-05-05 18:59:53 +00:00
|
|
|
compress_source = 'src/borg/compress.pyx'
|
2017-05-02 17:05:27 +00:00
|
|
|
crypto_ll_source = 'src/borg/crypto/low_level.pyx'
|
2016-07-14 20:35:50 +00:00
|
|
|
crypto_helpers = 'src/borg/crypto/_crypto_helpers.c'
|
2017-05-02 16:52:36 +00:00
|
|
|
chunker_source = 'src/borg/chunker.pyx'
|
2016-05-05 18:59:53 +00:00
|
|
|
hashindex_source = 'src/borg/hashindex.pyx'
|
2016-11-30 11:43:28 +00:00
|
|
|
item_source = 'src/borg/item.pyx'
|
2017-05-31 21:17:27 +00:00
|
|
|
checksums_source = 'src/borg/algorithms/checksums.pyx'
|
2016-05-31 00:35:54 +00:00
|
|
|
platform_posix_source = 'src/borg/platform/posix.pyx'
|
|
|
|
platform_linux_source = 'src/borg/platform/linux.pyx'
|
2020-01-02 17:54:00 +00:00
|
|
|
platform_syncfilerange_source = 'src/borg/platform/syncfilerange.pyx'
|
2016-05-31 00:35:54 +00:00
|
|
|
platform_darwin_source = 'src/borg/platform/darwin.pyx'
|
|
|
|
platform_freebsd_source = 'src/borg/platform/freebsd.pyx'
|
2019-08-08 22:01:38 +00:00
|
|
|
platform_windows_source = 'src/borg/platform/windows.pyx'
|
2016-05-31 00:35:54 +00:00
|
|
|
|
|
|
|
cython_sources = [
|
|
|
|
compress_source,
|
2017-05-02 17:05:27 +00:00
|
|
|
crypto_ll_source,
|
2016-05-31 00:35:54 +00:00
|
|
|
chunker_source,
|
|
|
|
hashindex_source,
|
2016-11-30 11:43:28 +00:00
|
|
|
item_source,
|
2017-05-31 21:17:27 +00:00
|
|
|
checksums_source,
|
2016-05-31 00:35:54 +00:00
|
|
|
|
|
|
|
platform_posix_source,
|
|
|
|
platform_linux_source,
|
2020-01-02 17:54:00 +00:00
|
|
|
platform_syncfilerange_source,
|
2016-05-31 00:35:54 +00:00
|
|
|
platform_freebsd_source,
|
|
|
|
platform_darwin_source,
|
2019-08-08 22:01:38 +00:00
|
|
|
platform_windows_source,
|
2016-05-31 00:35:54 +00:00
|
|
|
]
|
2013-06-18 19:34:22 +00:00
|
|
|
|
2018-04-28 16:06:10 +00:00
|
|
|
if cythonize:
|
|
|
|
Sdist = sdist
|
|
|
|
else:
|
2015-08-22 12:58:06 +00:00
|
|
|
class Sdist(sdist):
|
2013-06-24 11:53:02 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
raise Exception('Cython is required to run sdist')
|
|
|
|
|
2019-06-04 15:50:00 +00:00
|
|
|
cython_c_files = [fn.replace('.pyx', '.c') for fn in cython_sources]
|
|
|
|
if not on_rtd and not all(os.path.exists(path) for path in cython_c_files):
|
2015-09-19 19:44:40 +00:00
|
|
|
raise ImportError('The GIT version of Borg needs Cython. Install Cython or use a released version.')
|
2014-03-10 21:50:38 +00:00
|
|
|
|
|
|
|
|
2017-05-31 21:17:27 +00:00
|
|
|
def rm(file):
|
|
|
|
try:
|
|
|
|
os.unlink(file)
|
|
|
|
print('rm', file)
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2017-05-25 15:55:42 +00:00
|
|
|
class Clean(clean):
|
|
|
|
def run(self):
|
|
|
|
super().run()
|
|
|
|
for source in cython_sources:
|
|
|
|
genc = source.replace('.pyx', '.c')
|
2017-05-31 21:17:27 +00:00
|
|
|
rm(genc)
|
2017-05-25 15:55:42 +00:00
|
|
|
compiled_glob = source.replace('.pyx', '.cpython*')
|
2017-05-31 21:17:27 +00:00
|
|
|
for compiled in sorted(glob(compiled_glob)):
|
|
|
|
rm(compiled)
|
2017-05-25 15:55:42 +00:00
|
|
|
|
2018-06-12 19:06:01 +00:00
|
|
|
|
2015-10-07 23:55:56 +00:00
|
|
|
cmdclass = {
|
|
|
|
'build_ext': build_ext,
|
2018-06-12 19:06:01 +00:00
|
|
|
'build_usage': setup_docs.build_usage,
|
|
|
|
'build_man': setup_docs.build_man,
|
2017-05-25 15:55:42 +00:00
|
|
|
'sdist': Sdist,
|
|
|
|
'clean': Clean,
|
2015-10-07 23:55:56 +00:00
|
|
|
}
|
2013-08-05 20:45:24 +00:00
|
|
|
|
2015-10-07 23:16:49 +00:00
|
|
|
ext_modules = []
|
|
|
|
if not on_rtd:
|
2019-03-13 02:01:00 +00:00
|
|
|
|
|
|
|
def members_appended(*ds):
|
|
|
|
result = defaultdict(list)
|
|
|
|
for d in ds:
|
|
|
|
for k, v in d.items():
|
|
|
|
assert isinstance(v, list)
|
|
|
|
result[k].extend(v)
|
|
|
|
return result
|
|
|
|
|
2019-03-13 22:59:04 +00:00
|
|
|
try:
|
|
|
|
import pkgconfig as pc
|
|
|
|
except ImportError:
|
|
|
|
print('Warning: can not import pkgconfig python package.')
|
|
|
|
pc = None
|
|
|
|
|
2019-03-13 02:01:00 +00:00
|
|
|
crypto_ext_kwargs = members_appended(
|
|
|
|
dict(sources=[crypto_ll_source, crypto_helpers]),
|
2019-03-15 20:23:46 +00:00
|
|
|
setup_crypto.crypto_ext_kwargs(pc, system_prefix_openssl),
|
|
|
|
setup_crypto.b2_ext_kwargs(pc, prefer_system_libb2, system_prefix_libb2),
|
2019-03-13 02:01:00 +00:00
|
|
|
)
|
|
|
|
|
2019-03-13 13:53:18 +00:00
|
|
|
compress_ext_kwargs = members_appended(
|
|
|
|
dict(sources=[compress_source]),
|
2019-03-15 20:23:46 +00:00
|
|
|
setup_compress.lz4_ext_kwargs(pc, prefer_system_liblz4, system_prefix_liblz4),
|
|
|
|
setup_compress.zstd_ext_kwargs(pc, prefer_system_libzstd, system_prefix_libzstd,
|
|
|
|
multithreaded=False, legacy=False),
|
2019-03-13 13:53:18 +00:00
|
|
|
)
|
|
|
|
|
2019-06-03 21:37:46 +00:00
|
|
|
checksums_ext_kwargs = members_appended(
|
|
|
|
dict(sources=[checksums_source]),
|
|
|
|
setup_checksums.xxhash_ext_kwargs(pc, prefer_system_libxxhash, system_prefix_libxxhash),
|
|
|
|
)
|
|
|
|
|
2015-10-07 23:16:49 +00:00
|
|
|
ext_modules += [
|
2017-12-17 02:06:12 +00:00
|
|
|
Extension('borg.crypto.low_level', **crypto_ext_kwargs),
|
2019-03-13 13:53:18 +00:00
|
|
|
Extension('borg.compress', **compress_ext_kwargs),
|
2017-12-05 03:16:25 +00:00
|
|
|
Extension('borg.hashindex', [hashindex_source]),
|
|
|
|
Extension('borg.item', [item_source]),
|
|
|
|
Extension('borg.chunker', [chunker_source]),
|
2019-06-03 21:37:46 +00:00
|
|
|
Extension('borg.algorithms.checksums', **checksums_ext_kwargs),
|
2017-12-05 03:16:25 +00:00
|
|
|
]
|
2018-04-28 16:06:10 +00:00
|
|
|
|
|
|
|
posix_ext = Extension('borg.platform.posix', [platform_posix_source])
|
|
|
|
linux_ext = Extension('borg.platform.linux', [platform_linux_source], libraries=['acl'])
|
2020-01-02 17:54:00 +00:00
|
|
|
syncfilerange_ext = Extension('borg.platform.syncfilerange', [platform_syncfilerange_source])
|
2018-04-28 16:06:10 +00:00
|
|
|
freebsd_ext = Extension('borg.platform.freebsd', [platform_freebsd_source])
|
|
|
|
darwin_ext = Extension('borg.platform.darwin', [platform_darwin_source])
|
2019-08-08 22:01:38 +00:00
|
|
|
windows_ext = Extension('borg.platform.windows', [platform_windows_source])
|
2018-04-28 16:06:10 +00:00
|
|
|
|
2019-08-08 22:01:38 +00:00
|
|
|
if not is_win32:
|
2018-04-28 16:06:10 +00:00
|
|
|
ext_modules.append(posix_ext)
|
2019-08-08 22:01:38 +00:00
|
|
|
else:
|
|
|
|
ext_modules.append(windows_ext)
|
2015-12-15 00:08:35 +00:00
|
|
|
if sys.platform == 'linux':
|
2018-04-28 16:06:10 +00:00
|
|
|
ext_modules.append(linux_ext)
|
2020-01-02 17:54:00 +00:00
|
|
|
ext_modules.append(syncfilerange_ext)
|
2015-10-07 23:16:49 +00:00
|
|
|
elif sys.platform.startswith('freebsd'):
|
2018-04-28 16:06:10 +00:00
|
|
|
ext_modules.append(freebsd_ext)
|
2015-10-07 23:16:49 +00:00
|
|
|
elif sys.platform == 'darwin':
|
2018-04-28 16:06:10 +00:00
|
|
|
ext_modules.append(darwin_ext)
|
|
|
|
|
|
|
|
# sometimes there's no need to cythonize
|
|
|
|
# this breaks chained commands like 'clean sdist'
|
|
|
|
cythonizing = len(sys.argv) > 1 and sys.argv[1] not in ('clean', 'egg_info', '--help-commands', '--version') \
|
|
|
|
and '--help' not in sys.argv[1:]
|
|
|
|
|
|
|
|
if cythonize and cythonizing:
|
2018-12-15 17:12:10 +00:00
|
|
|
cython_opts = dict(
|
|
|
|
# default language_level will be '3str' starting from Cython 3.0.0,
|
|
|
|
# but old cython versions (< 0.29) do not know that, thus we use 3 for now.
|
|
|
|
compiler_directives={'language_level': 3},
|
|
|
|
)
|
2019-08-08 22:01:38 +00:00
|
|
|
if not is_win32:
|
|
|
|
# compile .pyx extensions to .c in parallel, does not work on windows
|
|
|
|
cython_opts['nthreads'] = cpu_threads + 1
|
|
|
|
|
2020-03-08 22:20:11 +00:00
|
|
|
# generate C code from Cython for ALL supported platforms, so we have them in the sdist.
|
|
|
|
# the sdist does not require Cython at install time, so we need all as C.
|
|
|
|
cythonize([posix_ext, linux_ext, syncfilerange_ext, freebsd_ext, darwin_ext, windows_ext], **cython_opts)
|
|
|
|
# generate C code from Cython for THIS platform (and for all platform-independent Cython parts).
|
2018-12-15 17:12:10 +00:00
|
|
|
ext_modules = cythonize(ext_modules, **cython_opts)
|
2014-04-13 18:26:46 +00:00
|
|
|
|
2019-03-13 23:40:30 +00:00
|
|
|
|
2013-06-24 11:53:02 +00:00
|
|
|
setup(
|
2015-05-09 16:40:55 +00:00
|
|
|
name='borgbackup',
|
2015-08-22 13:54:40 +00:00
|
|
|
use_scm_version={
|
2016-05-05 18:59:53 +00:00
|
|
|
'write_to': 'src/borg/_version.py',
|
2015-08-22 13:54:40 +00:00
|
|
|
},
|
2015-05-09 16:40:55 +00:00
|
|
|
author='The Borg Collective (see AUTHORS file)',
|
2015-12-08 09:12:15 +00:00
|
|
|
author_email='borgbackup@python.org',
|
2016-04-29 01:19:27 +00:00
|
|
|
url='https://borgbackup.readthedocs.io/',
|
2015-05-09 16:40:55 +00:00
|
|
|
description='Deduplicated, encrypted, authenticated and compressed backups',
|
2019-03-13 23:40:30 +00:00
|
|
|
long_description=setup_docs.long_desc_from_readme(),
|
2013-06-24 11:53:02 +00:00
|
|
|
license='BSD',
|
2015-09-16 09:44:53 +00:00
|
|
|
platforms=['Linux', 'MacOS X', 'FreeBSD', 'OpenBSD', 'NetBSD', ],
|
2013-06-24 11:53:02 +00:00
|
|
|
classifiers=[
|
2019-02-26 21:39:27 +00:00
|
|
|
'Development Status :: 3 - Alpha',
|
2013-06-24 11:53:02 +00:00
|
|
|
'Environment :: Console',
|
|
|
|
'Intended Audience :: System Administrators',
|
|
|
|
'License :: OSI Approved :: BSD License',
|
2013-07-28 12:55:48 +00:00
|
|
|
'Operating System :: POSIX :: BSD :: FreeBSD',
|
2015-09-16 09:44:53 +00:00
|
|
|
'Operating System :: POSIX :: BSD :: OpenBSD',
|
|
|
|
'Operating System :: POSIX :: BSD :: NetBSD',
|
2013-06-27 20:10:15 +00:00
|
|
|
'Operating System :: MacOS :: MacOS X',
|
|
|
|
'Operating System :: POSIX :: Linux',
|
2013-06-24 11:53:02 +00:00
|
|
|
'Programming Language :: Python',
|
2015-05-14 10:04:38 +00:00
|
|
|
'Programming Language :: Python :: 3',
|
2017-01-04 00:02:25 +00:00
|
|
|
'Programming Language :: Python :: 3.6',
|
2018-08-06 15:48:27 +00:00
|
|
|
'Programming Language :: Python :: 3.7',
|
2020-04-21 21:14:20 +00:00
|
|
|
'Programming Language :: Python :: 3.8',
|
2020-10-04 13:38:05 +00:00
|
|
|
'Programming Language :: Python :: 3.9',
|
2013-06-24 11:53:02 +00:00
|
|
|
'Topic :: Security :: Cryptography',
|
|
|
|
'Topic :: System :: Archiving :: Backup',
|
|
|
|
],
|
2016-05-05 18:59:53 +00:00
|
|
|
packages=find_packages('src'),
|
|
|
|
package_dir={'': 'src'},
|
|
|
|
zip_safe=False,
|
2015-07-12 13:00:47 +00:00
|
|
|
entry_points={
|
|
|
|
'console_scripts': [
|
|
|
|
'borg = borg.archiver:main',
|
2016-03-17 00:40:17 +00:00
|
|
|
'borgfs = borg.archiver:main',
|
2015-07-12 13:00:47 +00:00
|
|
|
]
|
|
|
|
},
|
2017-11-24 04:00:23 +00:00
|
|
|
# See also the MANIFEST.in file.
|
|
|
|
# We want to install all the files in the package directories...
|
2017-06-26 20:23:02 +00:00
|
|
|
include_package_data=True,
|
2017-11-24 04:00:23 +00:00
|
|
|
# ...except the source files which have been compiled (C extensions):
|
|
|
|
exclude_package_data={
|
|
|
|
'': ['*.c', '*.h', '*.pyx', ],
|
2017-02-07 23:22:37 +00:00
|
|
|
},
|
2013-08-05 20:45:24 +00:00
|
|
|
cmdclass=cmdclass,
|
2014-04-13 18:26:46 +00:00
|
|
|
ext_modules=ext_modules,
|
2015-08-22 12:58:06 +00:00
|
|
|
setup_requires=['setuptools_scm>=1.7'],
|
2015-09-12 20:44:23 +00:00
|
|
|
install_requires=install_requires,
|
2016-02-07 18:03:32 +00:00
|
|
|
extras_require=extras_require,
|
2020-09-25 00:13:43 +00:00
|
|
|
python_requires='>=3.6',
|
2013-06-24 11:53:02 +00:00
|
|
|
)
|