We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can't mount on ubuntu. Missing dependencies ?
Trying to mount a backup archive on ubuntu 16.04 fails with:
`# borg mount ~/.backup/ /tmp/pqp/`
`Loading fuse support failed [ImportError: No module named 'llfuse']`

I have installed borgbackup from ubuntu repositories. Is there any missing dependencies on ubuntu packages ?

> `# dpkg -l | grep -i fuse`
> ii  exfat-fuse                                  1.2.3-1                                    amd64        read and write exFAT driver for FUSE
> ii  fuse                                        2.9.4-1ubuntu3.1                           amd64        Filesystem in Userspace
> ii  gvfs-fuse                                   1.28.2-1ubuntu1~16.04.1                    amd64        userspace virtual filesystem - fuse server
> ii  ifuse                                       1.1.2-0.1build3                            amd64        FUSE module for iPhone and iPod Touch devices
> ii  libfuse2:amd64                              2.9.4-1ubuntu3.1                           amd64        Filesystem in Userspace (library)
> ii  ntfs-3g                                     1:2015.3.14AR.1-1build1                    amd64        read/write NTFS driver for FUSE


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 # -*- encoding: utf-8 *-*
2 import os
3 import re
4 import sys
5 from glob import glob
6 
7 from distutils.command.build import build
8 from distutils.core import Command
9 
10 min_python = (3, 4)
11 my_python = sys.version_info
12 
13 if my_python < min_python:
14     print("Borg requires Python %d.%d or later" % min_python)
15     sys.exit(1)
16 
17 # Are we building on ReadTheDocs?
18 on_rtd = os.environ.get('READTHEDOCS')
19 
20 # msgpack pure python data corruption was fixed in 0.4.6.
21 # Also, we might use some rather recent API features.
22 install_requires = ['msgpack-python>=0.4.6', ]
23 
24 extras_require = {
25     # llfuse 0.40 (tested, proven, ok), needs FUSE version >= 2.8.0
26     # llfuse 0.41 (tested shortly, looks ok), needs FUSE version >= 2.8.0
27     # llfuse 0.41.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0
28     # llfuse 0.42 (tested shortly, looks ok), needs FUSE version >= 2.8.0
29     # llfuse 1.0 (tested shortly, looks ok), needs FUSE version >= 2.8.0
30     # llfuse 2.0 will break API
31     'fuse': ['llfuse<2.0', ],
32 }
33 
34 if sys.platform.startswith('freebsd'):
35     # llfuse was frequently broken / did not build on freebsd
36     # llfuse 0.41.1, 1.1 are ok
37     extras_require['fuse'] = ['llfuse <2.0, !=0.42.*, !=0.43, !=1.0', ]
38 
39 from setuptools import setup, Extension
40 from setuptools.command.sdist import sdist
41 
42 
43 compress_source = 'borg/compress.pyx'
44 crypto_source = 'borg/crypto.pyx'
45 chunker_source = 'borg/chunker.pyx'
46 hashindex_source = 'borg/hashindex.pyx'
47 platform_linux_source = 'borg/platform_linux.pyx'
48 platform_darwin_source = 'borg/platform_darwin.pyx'
49 platform_freebsd_source = 'borg/platform_freebsd.pyx'
50 
51 try:
52     from Cython.Distutils import build_ext
53     import Cython.Compiler.Main as cython_compiler
54 
55     class Sdist(sdist):
56         def __init__(self, *args, **kwargs):
57             for src in glob('borg/*.pyx'):
58                 cython_compiler.compile(src, cython_compiler.default_options)
59             super().__init__(*args, **kwargs)
60 
61         def make_distribution(self):
62             self.filelist.extend([
63                 'borg/compress.c',
64                 'borg/crypto.c',
65                 'borg/chunker.c', 'borg/_chunker.c',
66                 'borg/hashindex.c', 'borg/_hashindex.c',
67                 'borg/platform_linux.c',
68                 'borg/platform_freebsd.c',
69                 'borg/platform_darwin.c',
70             ])
71             super().make_distribution()
72 
73 except ImportError:
74     class Sdist(sdist):
75         def __init__(self, *args, **kwargs):
76             raise Exception('Cython is required to run sdist')
77 
78     compress_source = compress_source.replace('.pyx', '.c')
79     crypto_source = crypto_source.replace('.pyx', '.c')
80     chunker_source = chunker_source.replace('.pyx', '.c')
81     hashindex_source = hashindex_source.replace('.pyx', '.c')
82     platform_linux_source = platform_linux_source.replace('.pyx', '.c')
83     platform_freebsd_source = platform_freebsd_source.replace('.pyx', '.c')
84     platform_darwin_source = platform_darwin_source.replace('.pyx', '.c')
85     from distutils.command.build_ext import build_ext
86     if not on_rtd and not all(os.path.exists(path) for path in [
87         compress_source, crypto_source, chunker_source, hashindex_source,
88         platform_linux_source, platform_freebsd_source, platform_darwin_source]):
89         raise ImportError('The GIT version of Borg needs Cython. Install Cython or use a released version.')
90 
91 
92 def detect_openssl(prefixes):
93     for prefix in prefixes:
94         filename = os.path.join(prefix, 'include', 'openssl', 'evp.h')
95         if os.path.exists(filename):
96             with open(filename, 'r') as fd:
97                 if 'PKCS5_PBKDF2_HMAC(' in fd.read():
98                     return prefix
99 
100 
101 def detect_lz4(prefixes):
102     for prefix in prefixes:
103         filename = os.path.join(prefix, 'include', 'lz4.h')
104         if os.path.exists(filename):
105             with open(filename, 'r') as fd:
106                 if 'LZ4_decompress_safe' in fd.read():
107                     return prefix
108 
109 
110 include_dirs = []
111 library_dirs = []
112 
113 possible_openssl_prefixes = ['/usr', '/usr/local', '/usr/local/opt/openssl', '/usr/local/ssl', '/usr/local/openssl', '/usr/local/borg', '/opt/local']
114 if os.environ.get('BORG_OPENSSL_PREFIX'):
115     possible_openssl_prefixes.insert(0, os.environ.get('BORG_OPENSSL_PREFIX'))
116 ssl_prefix = detect_openssl(possible_openssl_prefixes)
117 if not ssl_prefix:
118     raise Exception('Unable to find OpenSSL >= 1.0 headers. (Looked here: {})'.format(', '.join(possible_openssl_prefixes)))
119 include_dirs.append(os.path.join(ssl_prefix, 'include'))
120 library_dirs.append(os.path.join(ssl_prefix, 'lib'))
121 
122 
123 possible_lz4_prefixes = ['/usr', '/usr/local', '/usr/local/opt/lz4', '/usr/local/lz4', '/usr/local/borg', '/opt/local']
124 if os.environ.get('BORG_LZ4_PREFIX'):
125     possible_lz4_prefixes.insert(0, os.environ.get('BORG_LZ4_PREFIX'))
126 lz4_prefix = detect_lz4(possible_lz4_prefixes)
127 if lz4_prefix:
128     include_dirs.append(os.path.join(lz4_prefix, 'include'))
129     library_dirs.append(os.path.join(lz4_prefix, 'lib'))
130 elif not on_rtd:
131     raise Exception('Unable to find LZ4 headers. (Looked here: {})'.format(', '.join(possible_lz4_prefixes)))
132 
133 
134 with open('README.rst', 'r') as fd:
135     long_description = fd.read()
136 
137 
138 class build_usage(Command):
139     description = "generate usage for each command"
140 
141     user_options = [
142         ('output=', 'O', 'output directory'),
143     ]
144 
145     def initialize_options(self):
146         pass
147 
148     def finalize_options(self):
149         pass
150 
151     def run(self):
152         print('generating usage docs')
153         if not os.path.exists('docs/usage'):
154             os.mkdir('docs/usage')
155         # allows us to build docs without the C modules fully loaded during help generation
156         from borg.archiver import Archiver
157         parser = Archiver().build_parser(prog='borg')
158 
159         self.generate_level("", parser, Archiver)
160 
161     def generate_level(self, prefix, parser, Archiver):
162         is_subcommand = False
163         choices = {}
164         for action in parser._actions:
165             if action.choices is not None and 'SubParsersAction' in str(action.__class__):
166                 is_subcommand = True
167                 for cmd, parser in action.choices.items():
168                     choices[prefix + cmd] = parser
169         if prefix and not choices:
170             return
171         print('found commands: %s' % list(choices.keys()))
172 
173         for command, parser in choices.items():
174             print('generating help for %s' % command)
175 
176             if self.generate_level(command + " ", parser, Archiver):
177                 break
178 
179             with open('docs/usage/%s.rst.inc' % command.replace(" ", "_"), 'w') as doc:
180                 doc.write(".. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!\n\n")
181                 if command == 'help':
182                     for topic in Archiver.helptext:
183                         params = {"topic": topic,
184                                   "underline": '~' * len('borg help ' + topic)}
185                         doc.write(".. _borg_{topic}:\n\n".format(**params))
186                         doc.write("borg help {topic}\n{underline}\n\n".format(**params))
187                         doc.write(Archiver.helptext[topic])
188                 else:
189                     params = {"command": command,
190                               "command_": command.replace(' ', '_'),
191                               "underline": '-' * len('borg ' + command)}
192                     doc.write(".. _borg_{command_}:\n\n".format(**params))
193                     doc.write("borg {command}\n{underline}\n::\n\n".format(**params))
194                     epilog = parser.epilog
195                     parser.epilog = None
196                     doc.write(re.sub("^", "    ", parser.format_help(), flags=re.M))
197                     doc.write("\nDescription\n~~~~~~~~~~~\n")
198                     doc.write(epilog)
199         return is_subcommand
200 
201 
202 class build_api(Command):
203     description = "generate a basic api.rst file based on the modules available"
204 
205     user_options = [
206         ('output=', 'O', 'output directory'),
207     ]
208 
209     def initialize_options(self):
210         pass
211 
212     def finalize_options(self):
213         pass
214 
215     def run(self):
216         print("auto-generating API documentation")
217         with open("docs/api.rst", "w") as doc:
218             doc.write("""
219 API Documentation
220 =================
221 """)
222             for mod in glob('borg/*.py') + glob('borg/*.pyx'):
223                 print("examining module %s" % mod)
224                 mod = mod.replace('.pyx', '').replace('.py', '').replace('/', '.')
225                 if "._" not in mod:
226                     doc.write("""
227 .. automodule:: %s
228     :members:
229     :undoc-members:
230 """ % mod)
231 
232 
233 cmdclass = {
234     'build_ext': build_ext,
235     'build_api': build_api,
236     'build_usage': build_usage,
237     'sdist': Sdist
238 }
239 
240 ext_modules = []
241 if not on_rtd:
242     ext_modules += [
243     Extension('borg.compress', [compress_source], libraries=['lz4'], include_dirs=include_dirs, library_dirs=library_dirs),
244     Extension('borg.crypto', [crypto_source], libraries=['crypto'], include_dirs=include_dirs, library_dirs=library_dirs),
245     Extension('borg.chunker', [chunker_source]),
246     Extension('borg.hashindex', [hashindex_source])
247 ]
248     if sys.platform == 'linux':
249         ext_modules.append(Extension('borg.platform_linux', [platform_linux_source], libraries=['acl']))
250     elif sys.platform.startswith('freebsd'):
251         ext_modules.append(Extension('borg.platform_freebsd', [platform_freebsd_source]))
252     elif sys.platform == 'darwin':
253         ext_modules.append(Extension('borg.platform_darwin', [platform_darwin_source]))
254 
255 setup(
256     name='borgbackup',
257     use_scm_version={
258         'write_to': 'borg/_version.py',
259     },
260     author='The Borg Collective (see AUTHORS file)',
261     author_email='borgbackup@python.org',
262     url='https://borgbackup.readthedocs.io/',
263     description='Deduplicated, encrypted, authenticated and compressed backups',
264     long_description=long_description,
265     license='BSD',
266     platforms=['Linux', 'MacOS X', 'FreeBSD', 'OpenBSD', 'NetBSD', ],
267     classifiers=[
268         'Development Status :: 4 - Beta',
269         'Environment :: Console',
270         'Intended Audience :: System Administrators',
271         'License :: OSI Approved :: BSD License',
272         'Operating System :: POSIX :: BSD :: FreeBSD',
273         'Operating System :: POSIX :: BSD :: OpenBSD',
274         'Operating System :: POSIX :: BSD :: NetBSD',
275         'Operating System :: MacOS :: MacOS X',
276         'Operating System :: POSIX :: Linux',
277         'Programming Language :: Python',
278         'Programming Language :: Python :: 3',
279         'Programming Language :: Python :: 3.4',
280         'Programming Language :: Python :: 3.5',
281         'Topic :: Security :: Cryptography',
282         'Topic :: System :: Archiving :: Backup',
283     ],
284     packages=['borg', 'borg.testsuite', ],
285     entry_points={
286         'console_scripts': [
287             'borg = borg.archiver:main',
288         ]
289     },
290     cmdclass=cmdclass,
291     ext_modules=ext_modules,
292     setup_requires=['setuptools_scm>=1.7'],
293     install_requires=install_requires,
294     extras_require=extras_require,
295 )
296
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -21,12 +21,17 @@
 # Also, we might use some rather recent API features.
 install_requires = ['msgpack-python>=0.4.6', ]
 
+# note for package maintainers: if you package borgbackup for distribution,
+# please add llfuse as a *requirement* on all platforms that have a working
+# llfuse package. "borg mount" needs llfuse to work.
+# if you do not have llfuse, do not require it, most of borgbackup will work.
 extras_require = {
     # llfuse 0.40 (tested, proven, ok), needs FUSE version >= 2.8.0
     # llfuse 0.41 (tested shortly, looks ok), needs FUSE version >= 2.8.0
     # llfuse 0.41.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0
     # llfuse 0.42 (tested shortly, looks ok), needs FUSE version >= 2.8.0
     # llfuse 1.0 (tested shortly, looks ok), needs FUSE version >= 2.8.0
+    # llfuse 1.1.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0
     # llfuse 2.0 will break API
     'fuse': ['llfuse<2.0', ],
 }

{"golden_diff": "diff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -21,12 +21,17 @@\n # Also, we might use some rather recent API features.\n install_requires = ['msgpack-python>=0.4.6', ]\n \n+# note for package maintainers: if you package borgbackup for distribution,\n+# please add llfuse as a *requirement* on all platforms that have a working\n+# llfuse package. \"borg mount\" needs llfuse to work.\n+# if you do not have llfuse, do not require it, most of borgbackup will work.\n extras_require = {\n     # llfuse 0.40 (tested, proven, ok), needs FUSE version >= 2.8.0\n     # llfuse 0.41 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n     # llfuse 0.41.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n     # llfuse 0.42 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n     # llfuse 1.0 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n+    # llfuse 1.1.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n     # llfuse 2.0 will break API\n     'fuse': ['llfuse<2.0', ],\n }\n", "issue": "Can't mount on ubuntu. Missing dependencies ?\nTrying to mount a backup archive on ubuntu 16.04 fails with:\n`# borg mount ~/.backup/ /tmp/pqp/`\n`Loading fuse support failed [ImportError: No module named 'llfuse']`\n\nI have installed borgbackup from ubuntu repositories. Is there any missing dependencies on ubuntu packages ?\n\n> `# dpkg -l | grep -i fuse`\n> ii  exfat-fuse                                  1.2.3-1                                    amd64        read and write exFAT driver for FUSE\n> ii  fuse                                        2.9.4-1ubuntu3.1                           amd64        Filesystem in Userspace\n> ii  gvfs-fuse                                   1.28.2-1ubuntu1~16.04.1                    amd64        userspace virtual filesystem - fuse server\n> ii  ifuse                                       1.1.2-0.1build3                            amd64        FUSE module for iPhone and iPod Touch devices\n> ii  libfuse2:amd64                              2.9.4-1ubuntu3.1                           amd64        Filesystem in Userspace (library)\n> ii  ntfs-3g                                     1:2015.3.14AR.1-1build1                    amd64        read/write NTFS driver for FUSE\n\n", "before_files": [{"content": "# -*- encoding: utf-8 *-*\nimport os\nimport re\nimport sys\nfrom glob import glob\n\nfrom distutils.command.build import build\nfrom distutils.core import Command\n\nmin_python = (3, 4)\nmy_python = sys.version_info\n\nif my_python < min_python:\n    print(\"Borg requires Python %d.%d or later\" % min_python)\n    sys.exit(1)\n\n# Are we building on ReadTheDocs?\non_rtd = os.environ.get('READTHEDOCS')\n\n# msgpack pure python data corruption was fixed in 0.4.6.\n# Also, we might use some rather recent API features.\ninstall_requires = ['msgpack-python>=0.4.6', ]\n\nextras_require = {\n    # llfuse 0.40 (tested, proven, ok), needs FUSE version >= 2.8.0\n    # llfuse 0.41 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 0.41.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 0.42 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 1.0 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 2.0 will break API\n    'fuse': ['llfuse<2.0', ],\n}\n\nif sys.platform.startswith('freebsd'):\n    # llfuse was frequently broken / did not build on freebsd\n    # llfuse 0.41.1, 1.1 are ok\n    extras_require['fuse'] = ['llfuse <2.0, !=0.42.*, !=0.43, !=1.0', ]\n\nfrom setuptools import setup, Extension\nfrom setuptools.command.sdist import sdist\n\n\ncompress_source = 'borg/compress.pyx'\ncrypto_source = 'borg/crypto.pyx'\nchunker_source = 'borg/chunker.pyx'\nhashindex_source = 'borg/hashindex.pyx'\nplatform_linux_source = 'borg/platform_linux.pyx'\nplatform_darwin_source = 'borg/platform_darwin.pyx'\nplatform_freebsd_source = 'borg/platform_freebsd.pyx'\n\ntry:\n    from Cython.Distutils import build_ext\n    import Cython.Compiler.Main as cython_compiler\n\n    class Sdist(sdist):\n        def __init__(self, *args, **kwargs):\n            for src in glob('borg/*.pyx'):\n                cython_compiler.compile(src, cython_compiler.default_options)\n            super().__init__(*args, **kwargs)\n\n        def make_distribution(self):\n            self.filelist.extend([\n                'borg/compress.c',\n                'borg/crypto.c',\n                'borg/chunker.c', 'borg/_chunker.c',\n                'borg/hashindex.c', 'borg/_hashindex.c',\n                'borg/platform_linux.c',\n                'borg/platform_freebsd.c',\n                'borg/platform_darwin.c',\n            ])\n            super().make_distribution()\n\nexcept ImportError:\n    class Sdist(sdist):\n        def __init__(self, *args, **kwargs):\n            raise Exception('Cython is required to run sdist')\n\n    compress_source = compress_source.replace('.pyx', '.c')\n    crypto_source = crypto_source.replace('.pyx', '.c')\n    chunker_source = chunker_source.replace('.pyx', '.c')\n    hashindex_source = hashindex_source.replace('.pyx', '.c')\n    platform_linux_source = platform_linux_source.replace('.pyx', '.c')\n    platform_freebsd_source = platform_freebsd_source.replace('.pyx', '.c')\n    platform_darwin_source = platform_darwin_source.replace('.pyx', '.c')\n    from distutils.command.build_ext import build_ext\n    if not on_rtd and not all(os.path.exists(path) for path in [\n        compress_source, crypto_source, chunker_source, hashindex_source,\n        platform_linux_source, platform_freebsd_source, platform_darwin_source]):\n        raise ImportError('The GIT version of Borg needs Cython. Install Cython or use a released version.')\n\n\ndef detect_openssl(prefixes):\n    for prefix in prefixes:\n        filename = os.path.join(prefix, 'include', 'openssl', 'evp.h')\n        if os.path.exists(filename):\n            with open(filename, 'r') as fd:\n                if 'PKCS5_PBKDF2_HMAC(' in fd.read():\n                    return prefix\n\n\ndef detect_lz4(prefixes):\n    for prefix in prefixes:\n        filename = os.path.join(prefix, 'include', 'lz4.h')\n        if os.path.exists(filename):\n            with open(filename, 'r') as fd:\n                if 'LZ4_decompress_safe' in fd.read():\n                    return prefix\n\n\ninclude_dirs = []\nlibrary_dirs = []\n\npossible_openssl_prefixes = ['/usr', '/usr/local', '/usr/local/opt/openssl', '/usr/local/ssl', '/usr/local/openssl', '/usr/local/borg', '/opt/local']\nif os.environ.get('BORG_OPENSSL_PREFIX'):\n    possible_openssl_prefixes.insert(0, os.environ.get('BORG_OPENSSL_PREFIX'))\nssl_prefix = detect_openssl(possible_openssl_prefixes)\nif not ssl_prefix:\n    raise Exception('Unable to find OpenSSL >= 1.0 headers. (Looked here: {})'.format(', '.join(possible_openssl_prefixes)))\ninclude_dirs.append(os.path.join(ssl_prefix, 'include'))\nlibrary_dirs.append(os.path.join(ssl_prefix, 'lib'))\n\n\npossible_lz4_prefixes = ['/usr', '/usr/local', '/usr/local/opt/lz4', '/usr/local/lz4', '/usr/local/borg', '/opt/local']\nif os.environ.get('BORG_LZ4_PREFIX'):\n    possible_lz4_prefixes.insert(0, os.environ.get('BORG_LZ4_PREFIX'))\nlz4_prefix = detect_lz4(possible_lz4_prefixes)\nif lz4_prefix:\n    include_dirs.append(os.path.join(lz4_prefix, 'include'))\n    library_dirs.append(os.path.join(lz4_prefix, 'lib'))\nelif not on_rtd:\n    raise Exception('Unable to find LZ4 headers. (Looked here: {})'.format(', '.join(possible_lz4_prefixes)))\n\n\nwith open('README.rst', 'r') as fd:\n    long_description = fd.read()\n\n\nclass build_usage(Command):\n    description = \"generate usage for each command\"\n\n    user_options = [\n        ('output=', 'O', 'output directory'),\n    ]\n\n    def initialize_options(self):\n        pass\n\n    def finalize_options(self):\n        pass\n\n    def run(self):\n        print('generating usage docs')\n        if not os.path.exists('docs/usage'):\n            os.mkdir('docs/usage')\n        # allows us to build docs without the C modules fully loaded during help generation\n        from borg.archiver import Archiver\n        parser = Archiver().build_parser(prog='borg')\n\n        self.generate_level(\"\", parser, Archiver)\n\n    def generate_level(self, prefix, parser, Archiver):\n        is_subcommand = False\n        choices = {}\n        for action in parser._actions:\n            if action.choices is not None and 'SubParsersAction' in str(action.__class__):\n                is_subcommand = True\n                for cmd, parser in action.choices.items():\n                    choices[prefix + cmd] = parser\n        if prefix and not choices:\n            return\n        print('found commands: %s' % list(choices.keys()))\n\n        for command, parser in choices.items():\n            print('generating help for %s' % command)\n\n            if self.generate_level(command + \" \", parser, Archiver):\n                break\n\n            with open('docs/usage/%s.rst.inc' % command.replace(\" \", \"_\"), 'w') as doc:\n                doc.write(\".. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!\\n\\n\")\n                if command == 'help':\n                    for topic in Archiver.helptext:\n                        params = {\"topic\": topic,\n                                  \"underline\": '~' * len('borg help ' + topic)}\n                        doc.write(\".. _borg_{topic}:\\n\\n\".format(**params))\n                        doc.write(\"borg help {topic}\\n{underline}\\n\\n\".format(**params))\n                        doc.write(Archiver.helptext[topic])\n                else:\n                    params = {\"command\": command,\n                              \"command_\": command.replace(' ', '_'),\n                              \"underline\": '-' * len('borg ' + command)}\n                    doc.write(\".. _borg_{command_}:\\n\\n\".format(**params))\n                    doc.write(\"borg {command}\\n{underline}\\n::\\n\\n\".format(**params))\n                    epilog = parser.epilog\n                    parser.epilog = None\n                    doc.write(re.sub(\"^\", \"    \", parser.format_help(), flags=re.M))\n                    doc.write(\"\\nDescription\\n~~~~~~~~~~~\\n\")\n                    doc.write(epilog)\n        return is_subcommand\n\n\nclass build_api(Command):\n    description = \"generate a basic api.rst file based on the modules available\"\n\n    user_options = [\n        ('output=', 'O', 'output directory'),\n    ]\n\n    def initialize_options(self):\n        pass\n\n    def finalize_options(self):\n        pass\n\n    def run(self):\n        print(\"auto-generating API documentation\")\n        with open(\"docs/api.rst\", \"w\") as doc:\n            doc.write(\"\"\"\nAPI Documentation\n=================\n\"\"\")\n            for mod in glob('borg/*.py') + glob('borg/*.pyx'):\n                print(\"examining module %s\" % mod)\n                mod = mod.replace('.pyx', '').replace('.py', '').replace('/', '.')\n                if \"._\" not in mod:\n                    doc.write(\"\"\"\n.. automodule:: %s\n    :members:\n    :undoc-members:\n\"\"\" % mod)\n\n\ncmdclass = {\n    'build_ext': build_ext,\n    'build_api': build_api,\n    'build_usage': build_usage,\n    'sdist': Sdist\n}\n\next_modules = []\nif not on_rtd:\n    ext_modules += [\n    Extension('borg.compress', [compress_source], libraries=['lz4'], include_dirs=include_dirs, library_dirs=library_dirs),\n    Extension('borg.crypto', [crypto_source], libraries=['crypto'], include_dirs=include_dirs, library_dirs=library_dirs),\n    Extension('borg.chunker', [chunker_source]),\n    Extension('borg.hashindex', [hashindex_source])\n]\n    if sys.platform == 'linux':\n        ext_modules.append(Extension('borg.platform_linux', [platform_linux_source], libraries=['acl']))\n    elif sys.platform.startswith('freebsd'):\n        ext_modules.append(Extension('borg.platform_freebsd', [platform_freebsd_source]))\n    elif sys.platform == 'darwin':\n        ext_modules.append(Extension('borg.platform_darwin', [platform_darwin_source]))\n\nsetup(\n    name='borgbackup',\n    use_scm_version={\n        'write_to': 'borg/_version.py',\n    },\n    author='The Borg Collective (see AUTHORS file)',\n    author_email='borgbackup@python.org',\n    url='https://borgbackup.readthedocs.io/',\n    description='Deduplicated, encrypted, authenticated and compressed backups',\n    long_description=long_description,\n    license='BSD',\n    platforms=['Linux', 'MacOS X', 'FreeBSD', 'OpenBSD', 'NetBSD', ],\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Environment :: Console',\n        'Intended Audience :: System Administrators',\n        'License :: OSI Approved :: BSD License',\n        'Operating System :: POSIX :: BSD :: FreeBSD',\n        'Operating System :: POSIX :: BSD :: OpenBSD',\n        'Operating System :: POSIX :: BSD :: NetBSD',\n        'Operating System :: MacOS :: MacOS X',\n        'Operating System :: POSIX :: Linux',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n        'Topic :: Security :: Cryptography',\n        'Topic :: System :: Archiving :: Backup',\n    ],\n    packages=['borg', 'borg.testsuite', ],\n    entry_points={\n        'console_scripts': [\n            'borg = borg.archiver:main',\n        ]\n    },\n    cmdclass=cmdclass,\n    ext_modules=ext_modules,\n    setup_requires=['setuptools_scm>=1.7'],\n    install_requires=install_requires,\n    extras_require=extras_require,\n)\n", "path": "setup.py"}], "after_files": [{"content": "# -*- encoding: utf-8 *-*\nimport os\nimport re\nimport sys\nfrom glob import glob\n\nfrom distutils.command.build import build\nfrom distutils.core import Command\n\nmin_python = (3, 4)\nmy_python = sys.version_info\n\nif my_python < min_python:\n    print(\"Borg requires Python %d.%d or later\" % min_python)\n    sys.exit(1)\n\n# Are we building on ReadTheDocs?\non_rtd = os.environ.get('READTHEDOCS')\n\n# msgpack pure python data corruption was fixed in 0.4.6.\n# Also, we might use some rather recent API features.\ninstall_requires = ['msgpack-python>=0.4.6', ]\n\n# note for package maintainers: if you package borgbackup for distribution,\n# please add llfuse as a *requirement* on all platforms that have a working\n# llfuse package. \"borg mount\" needs llfuse to work.\n# if you do not have llfuse, do not require it, most of borgbackup will work.\nextras_require = {\n    # llfuse 0.40 (tested, proven, ok), needs FUSE version >= 2.8.0\n    # llfuse 0.41 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 0.41.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 0.42 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 1.0 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 1.1.1 (tested shortly, looks ok), needs FUSE version >= 2.8.0\n    # llfuse 2.0 will break API\n    'fuse': ['llfuse<2.0', ],\n}\n\nif sys.platform.startswith('freebsd'):\n    # llfuse was frequently broken / did not build on freebsd\n    # llfuse 0.41.1, 1.1 are ok\n    extras_require['fuse'] = ['llfuse <2.0, !=0.42.*, !=0.43, !=1.0', ]\n\nfrom setuptools import setup, Extension\nfrom setuptools.command.sdist import sdist\n\n\ncompress_source = 'borg/compress.pyx'\ncrypto_source = 'borg/crypto.pyx'\nchunker_source = 'borg/chunker.pyx'\nhashindex_source = 'borg/hashindex.pyx'\nplatform_linux_source = 'borg/platform_linux.pyx'\nplatform_darwin_source = 'borg/platform_darwin.pyx'\nplatform_freebsd_source = 'borg/platform_freebsd.pyx'\n\ntry:\n    from Cython.Distutils import build_ext\n    import Cython.Compiler.Main as cython_compiler\n\n    class Sdist(sdist):\n        def __init__(self, *args, **kwargs):\n            for src in glob('borg/*.pyx'):\n                cython_compiler.compile(src, cython_compiler.default_options)\n            super().__init__(*args, **kwargs)\n\n        def make_distribution(self):\n            self.filelist.extend([\n                'borg/compress.c',\n                'borg/crypto.c',\n                'borg/chunker.c', 'borg/_chunker.c',\n                'borg/hashindex.c', 'borg/_hashindex.c',\n                'borg/platform_linux.c',\n                'borg/platform_freebsd.c',\n                'borg/platform_darwin.c',\n            ])\n            super().make_distribution()\n\nexcept ImportError:\n    class Sdist(sdist):\n        def __init__(self, *args, **kwargs):\n            raise Exception('Cython is required to run sdist')\n\n    compress_source = compress_source.replace('.pyx', '.c')\n    crypto_source = crypto_source.replace('.pyx', '.c')\n    chunker_source = chunker_source.replace('.pyx', '.c')\n    hashindex_source = hashindex_source.replace('.pyx', '.c')\n    platform_linux_source = platform_linux_source.replace('.pyx', '.c')\n    platform_freebsd_source = platform_freebsd_source.replace('.pyx', '.c')\n    platform_darwin_source = platform_darwin_source.replace('.pyx', '.c')\n    from distutils.command.build_ext import build_ext\n    if not on_rtd and not all(os.path.exists(path) for path in [\n        compress_source, crypto_source, chunker_source, hashindex_source,\n        platform_linux_source, platform_freebsd_source, platform_darwin_source]):\n        raise ImportError('The GIT version of Borg needs Cython. Install Cython or use a released version.')\n\n\ndef detect_openssl(prefixes):\n    for prefix in prefixes:\n        filename = os.path.join(prefix, 'include', 'openssl', 'evp.h')\n        if os.path.exists(filename):\n            with open(filename, 'r') as fd:\n                if 'PKCS5_PBKDF2_HMAC(' in fd.read():\n                    return prefix\n\n\ndef detect_lz4(prefixes):\n    for prefix in prefixes:\n        filename = os.path.join(prefix, 'include', 'lz4.h')\n        if os.path.exists(filename):\n            with open(filename, 'r') as fd:\n                if 'LZ4_decompress_safe' in fd.read():\n                    return prefix\n\n\ninclude_dirs = []\nlibrary_dirs = []\n\npossible_openssl_prefixes = ['/usr', '/usr/local', '/usr/local/opt/openssl', '/usr/local/ssl', '/usr/local/openssl', '/usr/local/borg', '/opt/local']\nif os.environ.get('BORG_OPENSSL_PREFIX'):\n    possible_openssl_prefixes.insert(0, os.environ.get('BORG_OPENSSL_PREFIX'))\nssl_prefix = detect_openssl(possible_openssl_prefixes)\nif not ssl_prefix:\n    raise Exception('Unable to find OpenSSL >= 1.0 headers. (Looked here: {})'.format(', '.join(possible_openssl_prefixes)))\ninclude_dirs.append(os.path.join(ssl_prefix, 'include'))\nlibrary_dirs.append(os.path.join(ssl_prefix, 'lib'))\n\n\npossible_lz4_prefixes = ['/usr', '/usr/local', '/usr/local/opt/lz4', '/usr/local/lz4', '/usr/local/borg', '/opt/local']\nif os.environ.get('BORG_LZ4_PREFIX'):\n    possible_lz4_prefixes.insert(0, os.environ.get('BORG_LZ4_PREFIX'))\nlz4_prefix = detect_lz4(possible_lz4_prefixes)\nif lz4_prefix:\n    include_dirs.append(os.path.join(lz4_prefix, 'include'))\n    library_dirs.append(os.path.join(lz4_prefix, 'lib'))\nelif not on_rtd:\n    raise Exception('Unable to find LZ4 headers. (Looked here: {})'.format(', '.join(possible_lz4_prefixes)))\n\n\nwith open('README.rst', 'r') as fd:\n    long_description = fd.read()\n\n\nclass build_usage(Command):\n    description = \"generate usage for each command\"\n\n    user_options = [\n        ('output=', 'O', 'output directory'),\n    ]\n\n    def initialize_options(self):\n        pass\n\n    def finalize_options(self):\n        pass\n\n    def run(self):\n        print('generating usage docs')\n        if not os.path.exists('docs/usage'):\n            os.mkdir('docs/usage')\n        # allows us to build docs without the C modules fully loaded during help generation\n        from borg.archiver import Archiver\n        parser = Archiver().build_parser(prog='borg')\n\n        self.generate_level(\"\", parser, Archiver)\n\n    def generate_level(self, prefix, parser, Archiver):\n        is_subcommand = False\n        choices = {}\n        for action in parser._actions:\n            if action.choices is not None and 'SubParsersAction' in str(action.__class__):\n                is_subcommand = True\n                for cmd, parser in action.choices.items():\n                    choices[prefix + cmd] = parser\n        if prefix and not choices:\n            return\n        print('found commands: %s' % list(choices.keys()))\n\n        for command, parser in choices.items():\n            print('generating help for %s' % command)\n\n            if self.generate_level(command + \" \", parser, Archiver):\n                break\n\n            with open('docs/usage/%s.rst.inc' % command.replace(\" \", \"_\"), 'w') as doc:\n                doc.write(\".. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!\\n\\n\")\n                if command == 'help':\n                    for topic in Archiver.helptext:\n                        params = {\"topic\": topic,\n                                  \"underline\": '~' * len('borg help ' + topic)}\n                        doc.write(\".. _borg_{topic}:\\n\\n\".format(**params))\n                        doc.write(\"borg help {topic}\\n{underline}\\n\\n\".format(**params))\n                        doc.write(Archiver.helptext[topic])\n                else:\n                    params = {\"command\": command,\n                              \"command_\": command.replace(' ', '_'),\n                              \"underline\": '-' * len('borg ' + command)}\n                    doc.write(\".. _borg_{command_}:\\n\\n\".format(**params))\n                    doc.write(\"borg {command}\\n{underline}\\n::\\n\\n\".format(**params))\n                    epilog = parser.epilog\n                    parser.epilog = None\n                    doc.write(re.sub(\"^\", \"    \", parser.format_help(), flags=re.M))\n                    doc.write(\"\\nDescription\\n~~~~~~~~~~~\\n\")\n                    doc.write(epilog)\n        return is_subcommand\n\n\nclass build_api(Command):\n    description = \"generate a basic api.rst file based on the modules available\"\n\n    user_options = [\n        ('output=', 'O', 'output directory'),\n    ]\n\n    def initialize_options(self):\n        pass\n\n    def finalize_options(self):\n        pass\n\n    def run(self):\n        print(\"auto-generating API documentation\")\n        with open(\"docs/api.rst\", \"w\") as doc:\n            doc.write(\"\"\"\nAPI Documentation\n=================\n\"\"\")\n            for mod in glob('borg/*.py') + glob('borg/*.pyx'):\n                print(\"examining module %s\" % mod)\n                mod = mod.replace('.pyx', '').replace('.py', '').replace('/', '.')\n                if \"._\" not in mod:\n                    doc.write(\"\"\"\n.. automodule:: %s\n    :members:\n    :undoc-members:\n\"\"\" % mod)\n\n\ncmdclass = {\n    'build_ext': build_ext,\n    'build_api': build_api,\n    'build_usage': build_usage,\n    'sdist': Sdist\n}\n\next_modules = []\nif not on_rtd:\n    ext_modules += [\n    Extension('borg.compress', [compress_source], libraries=['lz4'], include_dirs=include_dirs, library_dirs=library_dirs),\n    Extension('borg.crypto', [crypto_source], libraries=['crypto'], include_dirs=include_dirs, library_dirs=library_dirs),\n    Extension('borg.chunker', [chunker_source]),\n    Extension('borg.hashindex', [hashindex_source])\n]\n    if sys.platform == 'linux':\n        ext_modules.append(Extension('borg.platform_linux', [platform_linux_source], libraries=['acl']))\n    elif sys.platform.startswith('freebsd'):\n        ext_modules.append(Extension('borg.platform_freebsd', [platform_freebsd_source]))\n    elif sys.platform == 'darwin':\n        ext_modules.append(Extension('borg.platform_darwin', [platform_darwin_source]))\n\nsetup(\n    name='borgbackup',\n    use_scm_version={\n        'write_to': 'borg/_version.py',\n    },\n    author='The Borg Collective (see AUTHORS file)',\n    author_email='borgbackup@python.org',\n    url='https://borgbackup.readthedocs.io/',\n    description='Deduplicated, encrypted, authenticated and compressed backups',\n    long_description=long_description,\n    license='BSD',\n    platforms=['Linux', 'MacOS X', 'FreeBSD', 'OpenBSD', 'NetBSD', ],\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Environment :: Console',\n        'Intended Audience :: System Administrators',\n        'License :: OSI Approved :: BSD License',\n        'Operating System :: POSIX :: BSD :: FreeBSD',\n        'Operating System :: POSIX :: BSD :: OpenBSD',\n        'Operating System :: POSIX :: BSD :: NetBSD',\n        'Operating System :: MacOS :: MacOS X',\n        'Operating System :: POSIX :: Linux',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.4',\n        'Programming Language :: Python :: 3.5',\n        'Topic :: Security :: Cryptography',\n        'Topic :: System :: Archiving :: Backup',\n    ],\n    packages=['borg', 'borg.testsuite', ],\n    entry_points={\n        'console_scripts': [\n            'borg = borg.archiver:main',\n        ]\n    },\n    cmdclass=cmdclass,\n    ext_modules=ext_modules,\n    setup_requires=['setuptools_scm>=1.7'],\n    install_requires=install_requires,\n    extras_require=extras_require,\n)\n", "path": "setup.py"}]}