setup.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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. def generate_level(self, prefix, parser, Archiver):
  313. is_subcommand = False
  314. choices = {}
  315. for action in parser._actions:
  316. if action.choices is not None and 'SubParsersAction' in str(action.__class__):
  317. is_subcommand = True
  318. for cmd, parser in action.choices.items():
  319. choices[prefix + cmd] = parser
  320. if prefix and not choices:
  321. return
  322. for command, parser in sorted(choices.items()):
  323. if command.startswith('debug') or command == 'help':
  324. continue
  325. man_title = 'borg-' + command.replace(' ', '-')
  326. print('building man page', man_title + '(1)', file=sys.stderr)
  327. if self.generate_level(command + ' ', parser, Archiver):
  328. continue
  329. doc, write = self.new_doc()
  330. self.write_man_header(write, man_title, parser.description)
  331. self.write_heading(write, 'SYNOPSIS')
  332. write('borg', command, end='')
  333. self.write_usage(write, parser)
  334. write('\n')
  335. self.write_heading(write, 'DESCRIPTION')
  336. description, _, notes = parser.epilog.partition('\n.. man NOTES')
  337. write(description)
  338. self.write_heading(write, 'OPTIONS')
  339. write('See `borg-common(1)` for common options of Borg commands.')
  340. write()
  341. self.write_options(write, parser)
  342. self.write_examples(write, command)
  343. if notes:
  344. self.write_heading(write, 'NOTES')
  345. write(notes)
  346. self.write_see_also(write, man_title)
  347. self.gen_man_page(man_title, doc.getvalue())
  348. # Generate the borg-common(1) man page with the common options.
  349. if 'create' in choices:
  350. doc, write = self.new_doc()
  351. man_title = 'borg-common'
  352. self.write_man_header(write, man_title, 'Common options of Borg commands')
  353. common_options = [group for group in choices['create']._action_groups if group.title == 'Common options'][0]
  354. self.write_heading(write, 'SYNOPSIS')
  355. self.write_options_group(write, common_options)
  356. self.write_see_also(write, man_title)
  357. self.gen_man_page(man_title, doc.getvalue())
  358. return is_subcommand
  359. def build_topic_pages(self, Archiver):
  360. for topic, text in Archiver.helptext.items():
  361. doc, write = self.new_doc()
  362. man_title = 'borg-' + topic
  363. print('building man page', man_title + '(1)', file=sys.stderr)
  364. self.write_man_header(write, man_title, 'Details regarding ' + topic)
  365. self.write_heading(write, 'DESCRIPTION')
  366. write(text)
  367. self.gen_man_page(man_title, doc.getvalue())
  368. def new_doc(self):
  369. doc = io.StringIO(self.rst_prelude)
  370. doc.read()
  371. write = self.printer(doc)
  372. return doc, write
  373. def printer(self, fd):
  374. def write(*args, **kwargs):
  375. print(*args, file=fd, **kwargs)
  376. return write
  377. def write_heading(self, write, header, char='-', double_sided=False):
  378. write()
  379. if double_sided:
  380. write(char * len(header))
  381. write(header)
  382. write(char * len(header))
  383. write()
  384. def write_man_header(self, write, title, description):
  385. self.write_heading(write, title, '=', double_sided=True)
  386. self.write_heading(write, description, double_sided=True)
  387. # man page metadata
  388. write(':Author: The Borg Collective')
  389. write(':Date:', datetime.utcnow().date().isoformat())
  390. write(':Manual section: 1')
  391. write(':Manual group: borg backup tool')
  392. write()
  393. def write_examples(self, write, command):
  394. with open('docs/usage.rst') as fd:
  395. usage = fd.read()
  396. usage_include = '.. include:: usage/%s.rst.inc' % command
  397. begin = usage.find(usage_include)
  398. end = usage.find('.. include', begin + 1)
  399. examples = usage[begin:end]
  400. examples = examples.replace(usage_include, '')
  401. examples = examples.replace('Examples\n~~~~~~~~', '')
  402. examples = examples.replace('Miscellaneous Help\n------------------', '')
  403. examples = re.sub('^(~+)$', lambda matches: '+' * len(matches.group(0)), examples, flags=re.MULTILINE)
  404. examples = examples.strip()
  405. if examples:
  406. self.write_heading(write, 'EXAMPLES', '-')
  407. write(examples)
  408. def write_see_also(self, write, man_title):
  409. see_also = self.see_also.get(man_title.replace('borg-', ''), ())
  410. see_also = ['`borg-%s(1)`' % s for s in see_also]
  411. see_also.insert(0, '`borg-common(1)`')
  412. self.write_heading(write, 'SEE ALSO')
  413. write(', '.join(see_also))
  414. def gen_man_page(self, name, rst):
  415. from docutils.writers import manpage
  416. from docutils.core import publish_string
  417. man_page = publish_string(source=rst, writer=manpage.Writer())
  418. with open('docs/man/%s.1' % name, 'wb') as fd:
  419. fd.write(man_page)
  420. def write_usage(self, write, parser):
  421. if any(len(o.option_strings) for o in parser._actions):
  422. write(' <options> ', end='')
  423. for option in parser._actions:
  424. if option.option_strings:
  425. continue
  426. write(option.metavar, end=' ')
  427. def write_options(self, write, parser):
  428. for group in parser._action_groups:
  429. if group.title == 'Common options' or not group._group_actions:
  430. continue
  431. title = 'arguments' if group.title == 'positional arguments' else group.title
  432. self.write_heading(write, title, '+')
  433. self.write_options_group(write, group)
  434. def write_options_group(self, write, group):
  435. def is_positional_group(group):
  436. return any(not o.option_strings for o in group._group_actions)
  437. if is_positional_group(group):
  438. for option in group._group_actions:
  439. write(option.metavar)
  440. write(textwrap.indent(option.help or '', ' ' * 4))
  441. return
  442. opts = OrderedDict()
  443. for option in group._group_actions:
  444. if option.metavar:
  445. option_fmt = '%s ' + option.metavar
  446. else:
  447. option_fmt = '%s'
  448. option_str = ', '.join(option_fmt % s for s in option.option_strings)
  449. option_desc = textwrap.dedent((option.help or '') % option.__dict__)
  450. opts[option_str] = textwrap.indent(option_desc, ' ' * 4)
  451. padding = len(max(opts)) + 1
  452. for option, desc in opts.items():
  453. write(option.ljust(padding), desc)
  454. class build_api(Command):
  455. description = "generate a basic api.rst file based on the modules available"
  456. user_options = [
  457. ('output=', 'O', 'output directory'),
  458. ]
  459. def initialize_options(self):
  460. pass
  461. def finalize_options(self):
  462. pass
  463. def run(self):
  464. print("auto-generating API documentation")
  465. with open("docs/api.rst", "w") as doc:
  466. doc.write("""
  467. API Documentation
  468. =================
  469. """)
  470. for mod in glob('src/borg/*.py') + glob('src/borg/*.pyx'):
  471. print("examining module %s" % mod)
  472. mod = mod.replace('.pyx', '').replace('.py', '').replace('/', '.')
  473. if "._" not in mod:
  474. doc.write("""
  475. .. automodule:: %s
  476. :members:
  477. :undoc-members:
  478. """ % mod)
  479. cmdclass = {
  480. 'build_ext': build_ext,
  481. 'build_api': build_api,
  482. 'build_usage': build_usage,
  483. 'build_man': build_man,
  484. 'sdist': Sdist
  485. }
  486. ext_modules = []
  487. if not on_rtd:
  488. ext_modules += [
  489. Extension('borg.compress', [compress_source], libraries=['lz4'], include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
  490. Extension('borg.crypto', [crypto_source], libraries=crypto_libraries, include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros),
  491. Extension('borg.chunker', [chunker_source]),
  492. Extension('borg.hashindex', [hashindex_source]),
  493. Extension('borg.item', [item_source]),
  494. Extension('borg.crc32', [crc32_source]),
  495. ]
  496. if not sys.platform.startswith(('win32', )):
  497. ext_modules.append(Extension('borg.platform.posix', [platform_posix_source]))
  498. if sys.platform == 'linux':
  499. ext_modules.append(Extension('borg.platform.linux', [platform_linux_source], libraries=['acl']))
  500. elif sys.platform.startswith('freebsd'):
  501. ext_modules.append(Extension('borg.platform.freebsd', [platform_freebsd_source]))
  502. elif sys.platform == 'darwin':
  503. ext_modules.append(Extension('borg.platform.darwin', [platform_darwin_source]))
  504. setup(
  505. name='borgbackup',
  506. use_scm_version={
  507. 'write_to': 'src/borg/_version.py',
  508. },
  509. author='The Borg Collective (see AUTHORS file)',
  510. author_email='borgbackup@python.org',
  511. url='https://borgbackup.readthedocs.io/',
  512. description='Deduplicated, encrypted, authenticated and compressed backups',
  513. long_description=long_description,
  514. license='BSD',
  515. platforms=['Linux', 'MacOS X', 'FreeBSD', 'OpenBSD', 'NetBSD', ],
  516. classifiers=[
  517. 'Development Status :: 4 - Beta',
  518. 'Environment :: Console',
  519. 'Intended Audience :: System Administrators',
  520. 'License :: OSI Approved :: BSD License',
  521. 'Operating System :: POSIX :: BSD :: FreeBSD',
  522. 'Operating System :: POSIX :: BSD :: OpenBSD',
  523. 'Operating System :: POSIX :: BSD :: NetBSD',
  524. 'Operating System :: MacOS :: MacOS X',
  525. 'Operating System :: POSIX :: Linux',
  526. 'Programming Language :: Python',
  527. 'Programming Language :: Python :: 3',
  528. 'Programming Language :: Python :: 3.4',
  529. 'Programming Language :: Python :: 3.5',
  530. 'Programming Language :: Python :: 3.6',
  531. 'Topic :: Security :: Cryptography',
  532. 'Topic :: System :: Archiving :: Backup',
  533. ],
  534. packages=find_packages('src'),
  535. package_dir={'': 'src'},
  536. include_package_data=True,
  537. zip_safe=False,
  538. entry_points={
  539. 'console_scripts': [
  540. 'borg = borg.archiver:main',
  541. 'borgfs = borg.archiver:main',
  542. ]
  543. },
  544. cmdclass=cmdclass,
  545. ext_modules=ext_modules,
  546. setup_requires=['setuptools_scm>=1.7'],
  547. install_requires=install_requires,
  548. extras_require=extras_require,
  549. )