setup.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. # -*- encoding: utf-8 *-*
  2. import os
  3. import io
  4. import re
  5. import sys
  6. from collections import OrderedDict
  7. from datetime import datetime
  8. from glob import glob
  9. from distutils.command.build import build
  10. from distutils.core import Command
  11. import textwrap
  12. min_python = (3, 4)
  13. my_python = sys.version_info
  14. if my_python < min_python:
  15. print("Borg requires Python %d.%d or later" % min_python)
  16. sys.exit(1)
  17. # Are we building on ReadTheDocs?
  18. on_rtd = os.environ.get('READTHEDOCS')
  19. # msgpack pure python data corruption was fixed in 0.4.6.
  20. # Also, we might use some rather recent API features.
  21. install_requires = ['msgpack-python>=0.4.6', ]
  22. # note for package maintainers: if you package borgbackup for distribution,
  23. # please add llfuse as a *requirement* on all platforms that have a working
  24. # llfuse package. "borg mount" needs llfuse to work.
  25. # if you do not have llfuse, do not require it, most of borgbackup will work.
  26. extras_require = {
  27. # llfuse 0.40 (tested, proven, ok), needs FUSE version >= 2.8.0
  28. # llfuse 0.41 (tested shortly, looks ok), needs FUSE version >= 2.8.0
  29. # llfuse 0.41.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0
  30. # llfuse 0.42 (tested shortly, looks ok), needs FUSE version >= 2.8.0
  31. # llfuse 1.0 (tested shortly, looks ok), needs FUSE version >= 2.8.0
  32. # llfuse 1.1.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0
  33. # llfuse 2.0 will break API
  34. 'fuse': ['llfuse<2.0', ],
  35. }
  36. if sys.platform.startswith('freebsd'):
  37. # llfuse was frequently broken / did not build on freebsd
  38. # llfuse 0.41.1, 1.1 are ok
  39. extras_require['fuse'] = ['llfuse <2.0, !=0.42.*, !=0.43, !=1.0', ]
  40. from setuptools import setup, find_packages, Extension
  41. from setuptools.command.sdist import sdist
  42. compress_source = 'src/borg/compress.pyx'
  43. crypto_ll_source = 'src/borg/crypto/low_level.pyx'
  44. chunker_source = 'src/borg/algorithms/chunker.pyx'
  45. hashindex_source = 'src/borg/hashindex.pyx'
  46. item_source = 'src/borg/item.pyx'
  47. crc32_source = 'src/borg/algorithms/crc32.pyx'
  48. platform_posix_source = 'src/borg/platform/posix.pyx'
  49. platform_linux_source = 'src/borg/platform/linux.pyx'
  50. platform_darwin_source = 'src/borg/platform/darwin.pyx'
  51. platform_freebsd_source = 'src/borg/platform/freebsd.pyx'
  52. cython_sources = [
  53. compress_source,
  54. crypto_ll_source,
  55. chunker_source,
  56. hashindex_source,
  57. item_source,
  58. crc32_source,
  59. platform_posix_source,
  60. platform_linux_source,
  61. platform_freebsd_source,
  62. platform_darwin_source,
  63. ]
  64. try:
  65. from Cython.Distutils import build_ext
  66. import Cython.Compiler.Main as cython_compiler
  67. class Sdist(sdist):
  68. def __init__(self, *args, **kwargs):
  69. for src in cython_sources:
  70. cython_compiler.compile(src, cython_compiler.default_options)
  71. super().__init__(*args, **kwargs)
  72. def make_distribution(self):
  73. self.filelist.extend([
  74. 'src/borg/compress.c',
  75. 'src/borg/crypto/low_level.c',
  76. 'src/borg/algorithms/chunker.c', 'src/borg/algorithms/buzhash.c',
  77. 'src/borg/hashindex.c', 'src/borg/_hashindex.c',
  78. 'src/borg/item.c',
  79. 'src/borg/algorithms/crc32.c',
  80. 'src/borg/algorithms/crc32_dispatch.c', 'src/borg/algorithms/crc32_clmul.c', 'src/borg/algorithms/crc32_slice_by_8.c',
  81. 'src/borg/platform/posix.c',
  82. 'src/borg/platform/linux.c',
  83. 'src/borg/platform/freebsd.c',
  84. 'src/borg/platform/darwin.c',
  85. ])
  86. super().make_distribution()
  87. except ImportError:
  88. class Sdist(sdist):
  89. def __init__(self, *args, **kwargs):
  90. raise Exception('Cython is required to run sdist')
  91. compress_source = compress_source.replace('.pyx', '.c')
  92. crypto_ll_source = crypto_ll_source.replace('.pyx', '.c')
  93. chunker_source = chunker_source.replace('.pyx', '.c')
  94. hashindex_source = hashindex_source.replace('.pyx', '.c')
  95. item_source = item_source.replace('.pyx', '.c')
  96. crc32_source = crc32_source.replace('.pyx', '.c')
  97. platform_posix_source = platform_posix_source.replace('.pyx', '.c')
  98. platform_linux_source = platform_linux_source.replace('.pyx', '.c')
  99. platform_freebsd_source = platform_freebsd_source.replace('.pyx', '.c')
  100. platform_darwin_source = platform_darwin_source.replace('.pyx', '.c')
  101. from distutils.command.build_ext import build_ext
  102. if not on_rtd and not all(os.path.exists(path) for path in [
  103. compress_source, crypto_ll_source, chunker_source, hashindex_source, item_source, crc32_source,
  104. platform_posix_source, platform_linux_source, platform_freebsd_source, platform_darwin_source]):
  105. raise ImportError('The GIT version of Borg needs Cython. Install Cython or use a released version.')
  106. def detect_openssl(prefixes):
  107. for prefix in prefixes:
  108. filename = os.path.join(prefix, 'include', 'openssl', 'evp.h')
  109. if os.path.exists(filename):
  110. with open(filename, 'r') as fd:
  111. if 'PKCS5_PBKDF2_HMAC(' in fd.read():
  112. return prefix
  113. def detect_lz4(prefixes):
  114. for prefix in prefixes:
  115. filename = os.path.join(prefix, 'include', 'lz4.h')
  116. if os.path.exists(filename):
  117. with open(filename, 'r') as fd:
  118. if 'LZ4_decompress_safe' in fd.read():
  119. return prefix
  120. def detect_libb2(prefixes):
  121. for prefix in prefixes:
  122. filename = os.path.join(prefix, 'include', 'blake2.h')
  123. if os.path.exists(filename):
  124. with open(filename, 'r') as fd:
  125. if 'blake2b_init' in fd.read():
  126. return prefix
  127. include_dirs = []
  128. library_dirs = []
  129. define_macros = []
  130. crypto_libraries = ['crypto']
  131. possible_openssl_prefixes = ['/usr', '/usr/local', '/usr/local/opt/openssl', '/usr/local/ssl', '/usr/local/openssl',
  132. '/usr/local/borg', '/opt/local', '/opt/pkg', ]
  133. if os.environ.get('BORG_OPENSSL_PREFIX'):
  134. possible_openssl_prefixes.insert(0, os.environ.get('BORG_OPENSSL_PREFIX'))
  135. ssl_prefix = detect_openssl(possible_openssl_prefixes)
  136. if not ssl_prefix:
  137. raise Exception('Unable to find OpenSSL >= 1.0 headers. (Looked here: {})'.format(', '.join(possible_openssl_prefixes)))
  138. include_dirs.append(os.path.join(ssl_prefix, 'include'))
  139. library_dirs.append(os.path.join(ssl_prefix, 'lib'))
  140. possible_lz4_prefixes = ['/usr', '/usr/local', '/usr/local/opt/lz4', '/usr/local/lz4',
  141. '/usr/local/borg', '/opt/local', '/opt/pkg', ]
  142. if os.environ.get('BORG_LZ4_PREFIX'):
  143. possible_lz4_prefixes.insert(0, os.environ.get('BORG_LZ4_PREFIX'))
  144. lz4_prefix = detect_lz4(possible_lz4_prefixes)
  145. if lz4_prefix:
  146. include_dirs.append(os.path.join(lz4_prefix, 'include'))
  147. library_dirs.append(os.path.join(lz4_prefix, 'lib'))
  148. elif not on_rtd:
  149. raise Exception('Unable to find LZ4 headers. (Looked here: {})'.format(', '.join(possible_lz4_prefixes)))
  150. possible_libb2_prefixes = ['/usr', '/usr/local', '/usr/local/opt/libb2', '/usr/local/libb2',
  151. '/usr/local/borg', '/opt/local', '/opt/pkg', ]
  152. if os.environ.get('BORG_LIBB2_PREFIX'):
  153. possible_libb2_prefixes.insert(0, os.environ.get('BORG_LIBB2_PREFIX'))
  154. libb2_prefix = detect_libb2(possible_libb2_prefixes)
  155. if libb2_prefix:
  156. print('Detected and preferring libb2 over bundled BLAKE2')
  157. include_dirs.append(os.path.join(libb2_prefix, 'include'))
  158. library_dirs.append(os.path.join(libb2_prefix, 'lib'))
  159. crypto_libraries.append('b2')
  160. define_macros.append(('BORG_USE_LIBB2', 'YES'))
  161. with open('README.rst', 'r') as fd:
  162. long_description = fd.read()
  163. # remove badges
  164. long_description = re.compile(r'^\.\. start-badges.*^\.\. end-badges', re.M | re.S).sub('', long_description)
  165. # remove |substitutions|
  166. long_description = re.compile(r'\|screencast\|').sub('', long_description)
  167. # remove unknown directives
  168. long_description = re.compile(r'^\.\. highlight:: \w+$', re.M).sub('', long_description)
  169. class build_usage(Command):
  170. description = "generate usage for each command"
  171. user_options = [
  172. ('output=', 'O', 'output directory'),
  173. ]
  174. def initialize_options(self):
  175. pass
  176. def finalize_options(self):
  177. pass
  178. def run(self):
  179. print('generating usage docs')
  180. import borg
  181. borg.doc_mode = 'build_man'
  182. if not os.path.exists('docs/usage'):
  183. os.mkdir('docs/usage')
  184. # allows us to build docs without the C modules fully loaded during help generation
  185. from borg.archiver import Archiver
  186. parser = Archiver(prog='borg').build_parser()
  187. self.generate_level("", parser, Archiver)
  188. def generate_level(self, prefix, parser, Archiver):
  189. is_subcommand = False
  190. choices = {}
  191. for action in parser._actions:
  192. if action.choices is not None and 'SubParsersAction' in str(action.__class__):
  193. is_subcommand = True
  194. for cmd, parser in action.choices.items():
  195. choices[prefix + cmd] = parser
  196. if prefix and not choices:
  197. return
  198. print('found commands: %s' % list(choices.keys()))
  199. for command, parser in sorted(choices.items()):
  200. if command.startswith('debug'):
  201. print('skipping', command)
  202. continue
  203. print('generating help for %s' % command)
  204. if self.generate_level(command + " ", parser, Archiver):
  205. continue
  206. with open('docs/usage/%s.rst.inc' % command.replace(" ", "_"), 'w') as doc:
  207. doc.write(".. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!\n\n")
  208. if command == 'help':
  209. for topic in Archiver.helptext:
  210. params = {"topic": topic,
  211. "underline": '~' * len('borg help ' + topic)}
  212. doc.write(".. _borg_{topic}:\n\n".format(**params))
  213. doc.write("borg help {topic}\n{underline}\n\n".format(**params))
  214. doc.write(Archiver.helptext[topic])
  215. else:
  216. params = {"command": command,
  217. "command_": command.replace(' ', '_'),
  218. "underline": '-' * len('borg ' + command)}
  219. doc.write(".. borg:command:: borg {command}\n\n".format(**params))
  220. doc.write(".. _borg_{command_}:\n\n".format(**params))
  221. doc.write("borg {command}\n{underline}\n::\n\n borg [common options] {command}".format(**params))
  222. self.write_usage(parser, doc)
  223. epilog = parser.epilog
  224. parser.epilog = None
  225. self.write_options(parser, doc)
  226. doc.write("\n\nDescription\n~~~~~~~~~~~\n")
  227. doc.write(epilog)
  228. if 'create' in choices:
  229. common_options = [group for group in choices['create']._action_groups if group.title == 'Common options'][0]
  230. with open('docs/usage/common-options.rst.inc', 'w') as doc:
  231. self.write_options_group(common_options, doc, False)
  232. return is_subcommand
  233. def write_usage(self, parser, fp):
  234. if any(len(o.option_strings) for o in parser._actions):
  235. fp.write(' <options>')
  236. for option in parser._actions:
  237. if option.option_strings:
  238. continue
  239. fp.write(' ' + option.metavar)
  240. def write_options(self, parser, fp):
  241. for group in parser._action_groups:
  242. if group.title == 'Common options':
  243. fp.write('\n\n`Common options`_\n')
  244. fp.write(' |')
  245. else:
  246. self.write_options_group(group, fp)
  247. def write_options_group(self, group, fp, with_title=True):
  248. def is_positional_group(group):
  249. return any(not o.option_strings for o in group._group_actions)
  250. def get_help(option):
  251. text = textwrap.dedent((option.help or '') % option.__dict__)
  252. return '\n'.join('| ' + line for line in text.splitlines())
  253. def shipout(text):
  254. fp.write(textwrap.indent('\n'.join(text), ' ' * 4))
  255. if not group._group_actions:
  256. return
  257. if with_title:
  258. fp.write('\n\n')
  259. fp.write(group.title + '\n')
  260. text = []
  261. if is_positional_group(group):
  262. for option in group._group_actions:
  263. text.append(option.metavar)
  264. text.append(textwrap.indent(option.help or '', ' ' * 4))
  265. shipout(text)
  266. return
  267. options = []
  268. for option in group._group_actions:
  269. if option.metavar:
  270. option_fmt = '``%%s %s``' % option.metavar
  271. else:
  272. option_fmt = '``%s``'
  273. option_str = ', '.join(option_fmt % s for s in option.option_strings)
  274. options.append((option_str, option))
  275. for option_str, option in options:
  276. help = textwrap.indent(get_help(option), ' ' * 4)
  277. text.append(option_str)
  278. text.append(help)
  279. shipout(text)
  280. class build_man(Command):
  281. description = 'build man pages'
  282. user_options = []
  283. see_also = {
  284. 'create': ('delete', 'prune', 'check', 'patterns', 'placeholders', 'compression'),
  285. 'recreate': ('patterns', 'placeholders', 'compression'),
  286. 'list': ('info', 'diff', 'prune', 'patterns'),
  287. 'info': ('list', 'diff'),
  288. 'init': ('create', 'delete', 'check', 'list', 'key-import', 'key-export', 'key-change-passphrase'),
  289. 'key-import': ('key-export', ),
  290. 'key-export': ('key-import', ),
  291. 'mount': ('umount', 'extract'), # Would be cooler if these two were on the same page
  292. 'umount': ('mount', ),
  293. 'extract': ('mount', ),
  294. }
  295. rst_prelude = textwrap.dedent("""
  296. .. role:: ref(title)
  297. .. |project_name| replace:: Borg
  298. """)
  299. def initialize_options(self):
  300. pass
  301. def finalize_options(self):
  302. pass
  303. def run(self):
  304. print('building man pages (in docs/man)', file=sys.stderr)
  305. import borg
  306. borg.doc_mode = 'build_man'
  307. os.makedirs('docs/man', exist_ok=True)
  308. # allows us to build docs without the C modules fully loaded during help generation
  309. from borg.archiver import Archiver
  310. parser = Archiver(prog='borg').build_parser()
  311. self.generate_level('', parser, Archiver)
  312. self.build_topic_pages(Archiver)
  313. self.build_intro_page()
  314. def generate_level(self, prefix, parser, Archiver):
  315. is_subcommand = False
  316. choices = {}
  317. for action in parser._actions:
  318. if action.choices is not None and 'SubParsersAction' in str(action.__class__):
  319. is_subcommand = True
  320. for cmd, parser in action.choices.items():
  321. choices[prefix + cmd] = parser
  322. if prefix and not choices:
  323. return
  324. for command, parser in sorted(choices.items()):
  325. if command.startswith('debug') or command == 'help':
  326. continue
  327. man_title = 'borg-' + command.replace(' ', '-')
  328. print('building man page', man_title + '(1)', file=sys.stderr)
  329. is_intermediary = self.generate_level(command + ' ', parser, Archiver)
  330. doc, write = self.new_doc()
  331. self.write_man_header(write, man_title, parser.description)
  332. self.write_heading(write, 'SYNOPSIS')
  333. if is_intermediary:
  334. subparsers = [action for action in parser._actions if 'SubParsersAction' in str(action.__class__)][0]
  335. for subcommand in subparsers.choices:
  336. write('| borg', '[common options]', command, subcommand, '...')
  337. self.see_also.setdefault(command, []).append('%s-%s' % (command, subcommand))
  338. else:
  339. write('borg', '[common options]', command, end='')
  340. self.write_usage(write, parser)
  341. write('\n')
  342. description, _, notes = parser.epilog.partition('\n.. man NOTES')
  343. if description:
  344. self.write_heading(write, 'DESCRIPTION')
  345. write(description)
  346. if not is_intermediary:
  347. self.write_heading(write, 'OPTIONS')
  348. write('See `borg-common(1)` for common options of Borg commands.')
  349. write()
  350. self.write_options(write, parser)
  351. self.write_examples(write, command)
  352. if notes:
  353. self.write_heading(write, 'NOTES')
  354. write(notes)
  355. self.write_see_also(write, man_title)
  356. self.gen_man_page(man_title, doc.getvalue())
  357. # Generate the borg-common(1) man page with the common options.
  358. if 'create' in choices:
  359. doc, write = self.new_doc()
  360. man_title = 'borg-common'
  361. self.write_man_header(write, man_title, 'Common options of Borg commands')
  362. common_options = [group for group in choices['create']._action_groups if group.title == 'Common options'][0]
  363. self.write_heading(write, 'SYNOPSIS')
  364. self.write_options_group(write, common_options)
  365. self.write_see_also(write, man_title)
  366. self.gen_man_page(man_title, doc.getvalue())
  367. return is_subcommand
  368. def build_topic_pages(self, Archiver):
  369. for topic, text in Archiver.helptext.items():
  370. doc, write = self.new_doc()
  371. man_title = 'borg-' + topic
  372. print('building man page', man_title + '(1)', file=sys.stderr)
  373. self.write_man_header(write, man_title, 'Details regarding ' + topic)
  374. self.write_heading(write, 'DESCRIPTION')
  375. write(text)
  376. self.gen_man_page(man_title, doc.getvalue())
  377. def build_intro_page(self):
  378. print('building man page borg(1)', file=sys.stderr)
  379. with open('docs/man_intro.rst') as fd:
  380. man_intro = fd.read()
  381. self.gen_man_page('borg', self.rst_prelude + man_intro)
  382. def new_doc(self):
  383. doc = io.StringIO(self.rst_prelude)
  384. doc.read()
  385. write = self.printer(doc)
  386. return doc, write
  387. def printer(self, fd):
  388. def write(*args, **kwargs):
  389. print(*args, file=fd, **kwargs)
  390. return write
  391. def write_heading(self, write, header, char='-', double_sided=False):
  392. write()
  393. if double_sided:
  394. write(char * len(header))
  395. write(header)
  396. write(char * len(header))
  397. write()
  398. def write_man_header(self, write, title, description):
  399. self.write_heading(write, title, '=', double_sided=True)
  400. self.write_heading(write, description, double_sided=True)
  401. # man page metadata
  402. write(':Author: The Borg Collective')
  403. write(':Date:', datetime.utcnow().date().isoformat())
  404. write(':Manual section: 1')
  405. write(':Manual group: borg backup tool')
  406. write()
  407. def write_examples(self, write, command):
  408. with open('docs/usage.rst') as fd:
  409. usage = fd.read()
  410. usage_include = '.. include:: usage/%s.rst.inc' % command
  411. begin = usage.find(usage_include)
  412. end = usage.find('.. include', begin + 1)
  413. examples = usage[begin:end]
  414. examples = examples.replace(usage_include, '')
  415. examples = examples.replace('Examples\n~~~~~~~~', '')
  416. examples = examples.replace('Miscellaneous Help\n------------------', '')
  417. examples = re.sub('^(~+)$', lambda matches: '+' * len(matches.group(0)), examples, flags=re.MULTILINE)
  418. examples = examples.strip()
  419. if examples:
  420. self.write_heading(write, 'EXAMPLES', '-')
  421. write(examples)
  422. def write_see_also(self, write, man_title):
  423. see_also = self.see_also.get(man_title.replace('borg-', ''), ())
  424. see_also = ['`borg-%s(1)`' % s for s in see_also]
  425. see_also.insert(0, '`borg-common(1)`')
  426. self.write_heading(write, 'SEE ALSO')
  427. write(', '.join(see_also))
  428. def gen_man_page(self, name, rst):
  429. from docutils.writers import manpage
  430. from docutils.core import publish_string
  431. # We give the source_path so that docutils can find relative includes
  432. # as-if the document where located in the docs/ directory.
  433. man_page = publish_string(source=rst, source_path='docs/virtmanpage.rst', writer=manpage.Writer())
  434. with open('docs/man/%s.1' % name, 'wb') as fd:
  435. fd.write(man_page)
  436. def write_usage(self, write, parser):
  437. if any(len(o.option_strings) for o in parser._actions):
  438. write(' <options> ', end='')
  439. for option in parser._actions:
  440. if option.option_strings:
  441. continue
  442. write(option.metavar, end=' ')
  443. def write_options(self, write, parser):
  444. for group in parser._action_groups:
  445. if group.title == 'Common options' or not group._group_actions:
  446. continue
  447. title = 'arguments' if group.title == 'positional arguments' else group.title
  448. self.write_heading(write, title, '+')
  449. self.write_options_group(write, group)
  450. def write_options_group(self, write, group):
  451. def is_positional_group(group):
  452. return any(not o.option_strings for o in group._group_actions)
  453. if is_positional_group(group):
  454. for option in group._group_actions:
  455. write(option.metavar)
  456. write(textwrap.indent(option.help or '', ' ' * 4))
  457. return
  458. opts = OrderedDict()
  459. for option in group._group_actions:
  460. if option.metavar:
  461. option_fmt = '%s ' + option.metavar
  462. else:
  463. option_fmt = '%s'
  464. option_str = ', '.join(option_fmt % s for s in option.option_strings)
  465. option_desc = textwrap.dedent((option.help or '') % option.__dict__)
  466. opts[option_str] = textwrap.indent(option_desc, ' ' * 4)
  467. padding = len(max(opts)) + 1
  468. for option, desc in opts.items():
  469. write(option.ljust(padding), desc)
  470. cmdclass = {
  471. 'build_ext': build_ext,
  472. 'build_usage': build_usage,
  473. 'build_man': build_man,
  474. 'sdist': Sdist
  475. }
  476. ext_modules = []
  477. if not on_rtd:
  478. ext_modules += [
  479. Extension('borg.compress', [compress_source], libraries=['lz4'], include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
  480. Extension('borg.crypto.low_level', [crypto_ll_source], libraries=crypto_libraries, include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
  481. Extension('borg.hashindex', [hashindex_source]),
  482. Extension('borg.item', [item_source]),
  483. Extension('borg.algorithms.chunker', [chunker_source]),
  484. Extension('borg.algorithms.crc32', [crc32_source]),
  485. ]
  486. if not sys.platform.startswith(('win32', )):
  487. ext_modules.append(Extension('borg.platform.posix', [platform_posix_source]))
  488. if sys.platform == 'linux':
  489. ext_modules.append(Extension('borg.platform.linux', [platform_linux_source], libraries=['acl']))
  490. elif sys.platform.startswith('freebsd'):
  491. ext_modules.append(Extension('borg.platform.freebsd', [platform_freebsd_source]))
  492. elif sys.platform == 'darwin':
  493. ext_modules.append(Extension('borg.platform.darwin', [platform_darwin_source]))
  494. setup(
  495. name='borgbackup',
  496. use_scm_version={
  497. 'write_to': 'src/borg/_version.py',
  498. },
  499. author='The Borg Collective (see AUTHORS file)',
  500. author_email='borgbackup@python.org',
  501. url='https://borgbackup.readthedocs.io/',
  502. description='Deduplicated, encrypted, authenticated and compressed backups',
  503. long_description=long_description,
  504. license='BSD',
  505. platforms=['Linux', 'MacOS X', 'FreeBSD', 'OpenBSD', 'NetBSD', ],
  506. classifiers=[
  507. 'Development Status :: 4 - Beta',
  508. 'Environment :: Console',
  509. 'Intended Audience :: System Administrators',
  510. 'License :: OSI Approved :: BSD License',
  511. 'Operating System :: POSIX :: BSD :: FreeBSD',
  512. 'Operating System :: POSIX :: BSD :: OpenBSD',
  513. 'Operating System :: POSIX :: BSD :: NetBSD',
  514. 'Operating System :: MacOS :: MacOS X',
  515. 'Operating System :: POSIX :: Linux',
  516. 'Programming Language :: Python',
  517. 'Programming Language :: Python :: 3',
  518. 'Programming Language :: Python :: 3.4',
  519. 'Programming Language :: Python :: 3.5',
  520. 'Programming Language :: Python :: 3.6',
  521. 'Topic :: Security :: Cryptography',
  522. 'Topic :: System :: Archiving :: Backup',
  523. ],
  524. packages=find_packages('src'),
  525. package_dir={'': 'src'},
  526. include_package_data=True,
  527. zip_safe=False,
  528. entry_points={
  529. 'console_scripts': [
  530. 'borg = borg.archiver:main',
  531. 'borgfs = borg.archiver:main',
  532. ]
  533. },
  534. package_data={
  535. 'borg': ['paperkey.html']
  536. },
  537. cmdclass=cmdclass,
  538. ext_modules=ext_modules,
  539. setup_requires=['setuptools_scm>=1.7'],
  540. install_requires=install_requires,
  541. extras_require=extras_require,
  542. )