setup.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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_source = 'src/borg/crypto.pyx'
  44. chunker_source = 'src/borg/chunker.pyx'
  45. hashindex_source = 'src/borg/hashindex.pyx'
  46. item_source = 'src/borg/item.pyx'
  47. crc32_source = 'src/borg/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_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.c',
  76. 'src/borg/chunker.c', 'src/borg/_chunker.c',
  77. 'src/borg/hashindex.c', 'src/borg/_hashindex.c',
  78. 'src/borg/item.c',
  79. 'src/borg/crc32.c',
  80. 'src/borg/_crc32/crc32.c', 'src/borg/_crc32/clmul.c', 'src/borg/_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_source = crypto_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_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').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_}:\n\n".format(**params))
  220. doc.write("borg {command}\n{underline}\n::\n\n borg {command}".format(**params))
  221. self.write_usage(parser, doc)
  222. epilog = parser.epilog
  223. parser.epilog = None
  224. self.write_options(parser, doc)
  225. doc.write("\n\nDescription\n~~~~~~~~~~~\n")
  226. doc.write(epilog)
  227. if 'create' in choices:
  228. common_options = [group for group in choices['create']._action_groups if group.title == 'Common options'][0]
  229. with open('docs/usage/common-options.rst.inc', 'w') as doc:
  230. self.write_options_group(common_options, doc, False)
  231. return is_subcommand
  232. def write_usage(self, parser, fp):
  233. if any(len(o.option_strings) for o in parser._actions):
  234. fp.write(' <options>')
  235. for option in parser._actions:
  236. if option.option_strings:
  237. continue
  238. fp.write(' ' + option.metavar)
  239. def write_options(self, parser, fp):
  240. for group in parser._action_groups:
  241. if group.title == 'Common options':
  242. fp.write('\n\n`Common options`_\n')
  243. fp.write(' |')
  244. else:
  245. self.write_options_group(group, fp)
  246. def write_options_group(self, group, fp, with_title=True):
  247. def is_positional_group(group):
  248. return any(not o.option_strings for o in group._group_actions)
  249. def get_help(option):
  250. text = textwrap.dedent((option.help or '') % option.__dict__)
  251. return '\n'.join('| ' + line for line in text.splitlines())
  252. def shipout(text):
  253. fp.write(textwrap.indent('\n'.join(text), ' ' * 4))
  254. if not group._group_actions:
  255. return
  256. if with_title:
  257. fp.write('\n\n')
  258. fp.write(group.title + '\n')
  259. text = []
  260. if is_positional_group(group):
  261. for option in group._group_actions:
  262. text.append(option.metavar)
  263. text.append(textwrap.indent(option.help or '', ' ' * 4))
  264. shipout(text)
  265. return
  266. options = []
  267. for option in group._group_actions:
  268. if option.metavar:
  269. option_fmt = '``%%s %s``' % option.metavar
  270. else:
  271. option_fmt = '``%s``'
  272. option_str = ', '.join(option_fmt % s for s in option.option_strings)
  273. options.append((option_str, option))
  274. for option_str, option in options:
  275. help = textwrap.indent(get_help(option), ' ' * 4)
  276. text.append(option_str)
  277. text.append(help)
  278. shipout(text)
  279. class build_man(Command):
  280. description = 'build man pages'
  281. user_options = []
  282. see_also = {
  283. 'create': ('delete', 'prune', 'check', 'patterns', 'placeholders', 'compression'),
  284. 'recreate': ('patterns', 'placeholders', 'compression'),
  285. 'list': ('info', 'diff', 'prune', 'patterns'),
  286. 'info': ('list', 'diff'),
  287. 'init': ('create', 'delete', 'check', 'list', 'key-import', 'key-export', 'key-change-passphrase'),
  288. 'key-import': ('key-export', ),
  289. 'key-export': ('key-import', ),
  290. 'mount': ('umount', 'extract'), # Would be cooler if these two were on the same page
  291. 'umount': ('mount', ),
  292. 'extract': ('mount', ),
  293. }
  294. rst_prelude = textwrap.dedent("""
  295. .. role:: ref(title)
  296. .. |project_name| replace:: Borg
  297. """)
  298. def initialize_options(self):
  299. pass
  300. def finalize_options(self):
  301. pass
  302. def run(self):
  303. print('building man pages (in docs/man)', file=sys.stderr)
  304. import borg
  305. borg.doc_mode = 'build_man'
  306. os.makedirs('docs/man', exist_ok=True)
  307. # allows us to build docs without the C modules fully loaded during help generation
  308. from borg.archiver import Archiver
  309. parser = Archiver(prog='borg').parser
  310. self.generate_level('', parser, Archiver)
  311. self.build_topic_pages(Archiver)
  312. self.build_intro_page()
  313. def generate_level(self, prefix, parser, Archiver):
  314. is_subcommand = False
  315. choices = {}
  316. for action in parser._actions:
  317. if action.choices is not None and 'SubParsersAction' in str(action.__class__):
  318. is_subcommand = True
  319. for cmd, parser in action.choices.items():
  320. choices[prefix + cmd] = parser
  321. if prefix and not choices:
  322. return
  323. for command, parser in sorted(choices.items()):
  324. if command.startswith('debug') or command == 'help':
  325. continue
  326. man_title = 'borg-' + command.replace(' ', '-')
  327. print('building man page', man_title + '(1)', file=sys.stderr)
  328. if self.generate_level(command + ' ', parser, Archiver):
  329. continue
  330. doc, write = self.new_doc()
  331. self.write_man_header(write, man_title, parser.description)
  332. self.write_heading(write, 'SYNOPSIS')
  333. write('borg', command, end='')
  334. self.write_usage(write, parser)
  335. write('\n')
  336. self.write_heading(write, 'DESCRIPTION')
  337. description, _, notes = parser.epilog.partition('\n.. man NOTES')
  338. write(description)
  339. self.write_heading(write, 'OPTIONS')
  340. write('See `borg-common(1)` for common options of Borg commands.')
  341. write()
  342. self.write_options(write, parser)
  343. self.write_examples(write, command)
  344. if notes:
  345. self.write_heading(write, 'NOTES')
  346. write(notes)
  347. self.write_see_also(write, man_title)
  348. self.gen_man_page(man_title, doc.getvalue())
  349. # Generate the borg-common(1) man page with the common options.
  350. if 'create' in choices:
  351. doc, write = self.new_doc()
  352. man_title = 'borg-common'
  353. self.write_man_header(write, man_title, 'Common options of Borg commands')
  354. common_options = [group for group in choices['create']._action_groups if group.title == 'Common options'][0]
  355. self.write_heading(write, 'SYNOPSIS')
  356. self.write_options_group(write, common_options)
  357. self.write_see_also(write, man_title)
  358. self.gen_man_page(man_title, doc.getvalue())
  359. return is_subcommand
  360. def build_topic_pages(self, Archiver):
  361. for topic, text in Archiver.helptext.items():
  362. doc, write = self.new_doc()
  363. man_title = 'borg-' + topic
  364. print('building man page', man_title + '(1)', file=sys.stderr)
  365. self.write_man_header(write, man_title, 'Details regarding ' + topic)
  366. self.write_heading(write, 'DESCRIPTION')
  367. write(text)
  368. self.gen_man_page(man_title, doc.getvalue())
  369. def build_intro_page(self):
  370. print('building man page borg(1)', file=sys.stderr)
  371. with open('docs/man_intro.rst') as fd:
  372. man_intro = fd.read()
  373. self.gen_man_page('borg', self.rst_prelude + man_intro)
  374. def new_doc(self):
  375. doc = io.StringIO(self.rst_prelude)
  376. doc.read()
  377. write = self.printer(doc)
  378. return doc, write
  379. def printer(self, fd):
  380. def write(*args, **kwargs):
  381. print(*args, file=fd, **kwargs)
  382. return write
  383. def write_heading(self, write, header, char='-', double_sided=False):
  384. write()
  385. if double_sided:
  386. write(char * len(header))
  387. write(header)
  388. write(char * len(header))
  389. write()
  390. def write_man_header(self, write, title, description):
  391. self.write_heading(write, title, '=', double_sided=True)
  392. self.write_heading(write, description, double_sided=True)
  393. # man page metadata
  394. write(':Author: The Borg Collective')
  395. write(':Date:', datetime.utcnow().date().isoformat())
  396. write(':Manual section: 1')
  397. write(':Manual group: borg backup tool')
  398. write()
  399. def write_examples(self, write, command):
  400. with open('docs/usage.rst') as fd:
  401. usage = fd.read()
  402. usage_include = '.. include:: usage/%s.rst.inc' % command
  403. begin = usage.find(usage_include)
  404. end = usage.find('.. include', begin + 1)
  405. examples = usage[begin:end]
  406. examples = examples.replace(usage_include, '')
  407. examples = examples.replace('Examples\n~~~~~~~~', '')
  408. examples = examples.replace('Miscellaneous Help\n------------------', '')
  409. examples = re.sub('^(~+)$', lambda matches: '+' * len(matches.group(0)), examples, flags=re.MULTILINE)
  410. examples = examples.strip()
  411. if examples:
  412. self.write_heading(write, 'EXAMPLES', '-')
  413. write(examples)
  414. def write_see_also(self, write, man_title):
  415. see_also = self.see_also.get(man_title.replace('borg-', ''), ())
  416. see_also = ['`borg-%s(1)`' % s for s in see_also]
  417. see_also.insert(0, '`borg-common(1)`')
  418. self.write_heading(write, 'SEE ALSO')
  419. write(', '.join(see_also))
  420. def gen_man_page(self, name, rst):
  421. from docutils.writers import manpage
  422. from docutils.core import publish_string
  423. # We give the source_path so that docutils can find relative includes
  424. # as-if the document where located in the docs/ directory.
  425. man_page = publish_string(source=rst, source_path='docs/virtmanpage.rst', writer=manpage.Writer())
  426. with open('docs/man/%s.1' % name, 'wb') as fd:
  427. fd.write(man_page)
  428. def write_usage(self, write, parser):
  429. if any(len(o.option_strings) for o in parser._actions):
  430. write(' <options> ', end='')
  431. for option in parser._actions:
  432. if option.option_strings:
  433. continue
  434. write(option.metavar, end=' ')
  435. def write_options(self, write, parser):
  436. for group in parser._action_groups:
  437. if group.title == 'Common options' or not group._group_actions:
  438. continue
  439. title = 'arguments' if group.title == 'positional arguments' else group.title
  440. self.write_heading(write, title, '+')
  441. self.write_options_group(write, group)
  442. def write_options_group(self, write, group):
  443. def is_positional_group(group):
  444. return any(not o.option_strings for o in group._group_actions)
  445. if is_positional_group(group):
  446. for option in group._group_actions:
  447. write(option.metavar)
  448. write(textwrap.indent(option.help or '', ' ' * 4))
  449. return
  450. opts = OrderedDict()
  451. for option in group._group_actions:
  452. if option.metavar:
  453. option_fmt = '%s ' + option.metavar
  454. else:
  455. option_fmt = '%s'
  456. option_str = ', '.join(option_fmt % s for s in option.option_strings)
  457. option_desc = textwrap.dedent((option.help or '') % option.__dict__)
  458. opts[option_str] = textwrap.indent(option_desc, ' ' * 4)
  459. padding = len(max(opts)) + 1
  460. for option, desc in opts.items():
  461. write(option.ljust(padding), desc)
  462. class build_api(Command):
  463. description = "generate a basic api.rst file based on the modules available"
  464. user_options = [
  465. ('output=', 'O', 'output directory'),
  466. ]
  467. def initialize_options(self):
  468. pass
  469. def finalize_options(self):
  470. pass
  471. def run(self):
  472. print("auto-generating API documentation")
  473. with open("docs/api.rst", "w") as doc:
  474. doc.write("""
  475. API Documentation
  476. =================
  477. """)
  478. for mod in glob('src/borg/*.py') + glob('src/borg/*.pyx'):
  479. print("examining module %s" % mod)
  480. mod = mod.replace('.pyx', '').replace('.py', '').replace('/', '.')
  481. if "._" not in mod:
  482. doc.write("""
  483. .. automodule:: %s
  484. :members:
  485. :undoc-members:
  486. """ % mod)
  487. cmdclass = {
  488. 'build_ext': build_ext,
  489. 'build_api': build_api,
  490. 'build_usage': build_usage,
  491. 'build_man': build_man,
  492. 'sdist': Sdist
  493. }
  494. ext_modules = []
  495. if not on_rtd:
  496. ext_modules += [
  497. Extension('borg.compress', [compress_source], libraries=['lz4'], include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
  498. Extension('borg.crypto', [crypto_source], libraries=crypto_libraries, include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
  499. Extension('borg.chunker', [chunker_source]),
  500. Extension('borg.hashindex', [hashindex_source]),
  501. Extension('borg.item', [item_source]),
  502. Extension('borg.crc32', [crc32_source]),
  503. ]
  504. if not sys.platform.startswith(('win32', )):
  505. ext_modules.append(Extension('borg.platform.posix', [platform_posix_source]))
  506. if sys.platform == 'linux':
  507. ext_modules.append(Extension('borg.platform.linux', [platform_linux_source], libraries=['acl']))
  508. elif sys.platform.startswith('freebsd'):
  509. ext_modules.append(Extension('borg.platform.freebsd', [platform_freebsd_source]))
  510. elif sys.platform == 'darwin':
  511. ext_modules.append(Extension('borg.platform.darwin', [platform_darwin_source]))
  512. setup(
  513. name='borgbackup',
  514. use_scm_version={
  515. 'write_to': 'src/borg/_version.py',
  516. },
  517. author='The Borg Collective (see AUTHORS file)',
  518. author_email='borgbackup@python.org',
  519. url='https://borgbackup.readthedocs.io/',
  520. description='Deduplicated, encrypted, authenticated and compressed backups',
  521. long_description=long_description,
  522. license='BSD',
  523. platforms=['Linux', 'MacOS X', 'FreeBSD', 'OpenBSD', 'NetBSD', ],
  524. classifiers=[
  525. 'Development Status :: 4 - Beta',
  526. 'Environment :: Console',
  527. 'Intended Audience :: System Administrators',
  528. 'License :: OSI Approved :: BSD License',
  529. 'Operating System :: POSIX :: BSD :: FreeBSD',
  530. 'Operating System :: POSIX :: BSD :: OpenBSD',
  531. 'Operating System :: POSIX :: BSD :: NetBSD',
  532. 'Operating System :: MacOS :: MacOS X',
  533. 'Operating System :: POSIX :: Linux',
  534. 'Programming Language :: Python',
  535. 'Programming Language :: Python :: 3',
  536. 'Programming Language :: Python :: 3.4',
  537. 'Programming Language :: Python :: 3.5',
  538. 'Programming Language :: Python :: 3.6',
  539. 'Topic :: Security :: Cryptography',
  540. 'Topic :: System :: Archiving :: Backup',
  541. ],
  542. packages=find_packages('src'),
  543. package_dir={'': 'src'},
  544. include_package_data=True,
  545. zip_safe=False,
  546. entry_points={
  547. 'console_scripts': [
  548. 'borg = borg.archiver:main',
  549. 'borgfs = borg.archiver:main',
  550. ]
  551. },
  552. cmdclass=cmdclass,
  553. ext_modules=ext_modules,
  554. setup_requires=['setuptools_scm>=1.7'],
  555. install_requires=install_requires,
  556. extras_require=extras_require,
  557. )