mirror of https://github.com/borgbackup/borg.git
completely remove have_cython() hack
this was making us require mock, which is really a test component and shouldn't be part of the runtime dependencies. furthermore, it was making the imports and the code more brittle: it may have been possible that, through an environment variable, backups could be corrupted because mock libraries would be configured instead of real once, which is a risk we shouldn't be taking. finally, this was used only to build docs, which we will build and commit to git by hand with a fully working borg when relevant. see #384.
This commit is contained in:
parent
f52fb410a5
commit
f13dd6e579
|
@ -18,16 +18,12 @@ import time
|
|||
from io import BytesIO
|
||||
from . import xattr
|
||||
from .helpers import parse_timestamp, Error, uid2user, user2uid, gid2group, group2gid, format_timedelta, \
|
||||
Manifest, Statistics, decode_dict, make_path_safe, StableDict, int_to_bigint, bigint_to_int, have_cython, \
|
||||
Manifest, Statistics, decode_dict, make_path_safe, StableDict, int_to_bigint, bigint_to_int, \
|
||||
st_atime_ns, st_ctime_ns, st_mtime_ns
|
||||
if have_cython():
|
||||
from .platform import acl_get, acl_set
|
||||
from .chunker import Chunker
|
||||
from .hashindex import ChunkIndex
|
||||
import msgpack
|
||||
else:
|
||||
import mock
|
||||
msgpack = mock.Mock()
|
||||
from .platform import acl_get, acl_set
|
||||
from .chunker import Chunker
|
||||
from .hashindex import ChunkIndex
|
||||
import msgpack
|
||||
|
||||
ITEMS_BUFFER = 1024 * 1024
|
||||
|
||||
|
|
|
@ -20,16 +20,15 @@ from .helpers import Error, location_validator, format_time, format_file_size, \
|
|||
format_file_mode, ExcludePattern, IncludePattern, exclude_path, adjust_patterns, to_localtime, timestamp, \
|
||||
get_cache_dir, get_keys_dir, prune_within, prune_split, unhexlify, \
|
||||
Manifest, remove_surrogates, update_excludes, format_archive, check_extension_modules, Statistics, \
|
||||
dir_is_tagged, bigint_to_int, ChunkerParams, CompressionSpec, have_cython, is_slow_msgpack, yes, \
|
||||
dir_is_tagged, bigint_to_int, ChunkerParams, CompressionSpec, is_slow_msgpack, yes, \
|
||||
EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
|
||||
from .logger import create_logger, setup_logging
|
||||
logger = create_logger()
|
||||
if have_cython():
|
||||
from .compress import Compressor, COMPR_BUFFER
|
||||
from .upgrader import AtticRepositoryUpgrader
|
||||
from .repository import Repository
|
||||
from .cache import Cache
|
||||
from .key import key_creator
|
||||
from .compress import Compressor, COMPR_BUFFER
|
||||
from .upgrader import AtticRepositoryUpgrader
|
||||
from .repository import Repository
|
||||
from .cache import Cache
|
||||
from .key import key_creator
|
||||
from .archive import Archive, ArchiveChecker, CHUNKER_PARAMS
|
||||
from .remote import RepositoryServer, RemoteRepository
|
||||
|
||||
|
|
|
@ -10,12 +10,11 @@ from .key import PlaintextKey
|
|||
from .logger import create_logger
|
||||
logger = create_logger()
|
||||
from .helpers import Error, get_cache_dir, decode_dict, st_mtime_ns, unhexlify, int_to_bigint, \
|
||||
bigint_to_int, format_file_size, have_cython, yes
|
||||
bigint_to_int, format_file_size, yes
|
||||
from .locking import UpgradableLock
|
||||
from .hashindex import ChunkIndex
|
||||
|
||||
if have_cython():
|
||||
import msgpack
|
||||
import msgpack
|
||||
|
||||
|
||||
class Cache:
|
||||
|
|
|
@ -7,11 +7,10 @@ import stat
|
|||
import tempfile
|
||||
import time
|
||||
from .archive import Archive
|
||||
from .helpers import daemonize, have_cython
|
||||
from .helpers import daemonize
|
||||
from .remote import cache_if_remote
|
||||
|
||||
if have_cython():
|
||||
import msgpack
|
||||
import msgpack
|
||||
|
||||
# Does this version of llfuse support ns precision?
|
||||
have_fuse_xtime_ns = hasattr(llfuse.EntryAttributes, 'st_mtime_ns')
|
||||
|
|
|
@ -22,27 +22,11 @@ from fnmatch import translate
|
|||
from operator import attrgetter
|
||||
|
||||
|
||||
def have_cython():
|
||||
"""allow for a way to disable Cython includes
|
||||
|
||||
this is used during usage docs build, in setup.py. It is to avoid
|
||||
loading the Cython libraries which are built, but sometimes not in
|
||||
the search path (namely, during Tox runs).
|
||||
|
||||
we simply check an environment variable (``BORG_CYTHON_DISABLE``)
|
||||
which, when set (to anything) will disable includes of Cython
|
||||
libraries in key places to enable usage docs to be built.
|
||||
|
||||
:returns: True if Cython is available, False otherwise.
|
||||
"""
|
||||
return not os.environ.get('BORG_CYTHON_DISABLE')
|
||||
|
||||
if have_cython():
|
||||
from . import hashindex
|
||||
from . import chunker
|
||||
from . import crypto
|
||||
import msgpack
|
||||
import msgpack.fallback
|
||||
from . import hashindex
|
||||
from . import chunker
|
||||
from . import crypto
|
||||
import msgpack
|
||||
import msgpack.fallback
|
||||
|
||||
|
||||
# return codes returned by borg command
|
||||
|
|
|
@ -7,14 +7,13 @@ import textwrap
|
|||
import hmac
|
||||
from hashlib import sha256
|
||||
|
||||
from .helpers import IntegrityError, get_keys_dir, Error, have_cython
|
||||
from .helpers import IntegrityError, get_keys_dir, Error
|
||||
from .logger import create_logger
|
||||
logger = create_logger()
|
||||
|
||||
if have_cython():
|
||||
from .crypto import pbkdf2_sha256, get_random_bytes, AES, bytes_to_long, long_to_bytes, bytes_to_int, num_aes_blocks
|
||||
from .compress import Compressor, COMPR_BUFFER
|
||||
import msgpack
|
||||
from .crypto import pbkdf2_sha256, get_random_bytes, AES, bytes_to_long, long_to_bytes, bytes_to_int, num_aes_blocks
|
||||
from .compress import Compressor, COMPR_BUFFER
|
||||
import msgpack
|
||||
|
||||
PREFIX = b'\0' * 8
|
||||
|
||||
|
|
|
@ -10,11 +10,10 @@ import traceback
|
|||
|
||||
from . import __version__
|
||||
|
||||
from .helpers import Error, IntegrityError, have_cython
|
||||
from .helpers import Error, IntegrityError
|
||||
from .repository import Repository
|
||||
|
||||
if have_cython():
|
||||
import msgpack
|
||||
import msgpack
|
||||
|
||||
BUFSIZE = 10 * 1024 * 1024
|
||||
|
||||
|
|
|
@ -10,9 +10,8 @@ import shutil
|
|||
import struct
|
||||
from zlib import crc32
|
||||
|
||||
from .helpers import Error, ErrorWithTraceback, IntegrityError, read_msgpack, write_msgpack, unhexlify, have_cython
|
||||
if have_cython():
|
||||
from .hashindex import NSIndex
|
||||
from .helpers import Error, ErrorWithTraceback, IntegrityError, read_msgpack, write_msgpack, unhexlify
|
||||
from .hashindex import NSIndex
|
||||
from .locking import UpgradableLock
|
||||
from .lrucache import LRUCache
|
||||
|
||||
|
|
|
@ -59,12 +59,6 @@ Some "yes" sayers (if set, they automatically confirm that you really want to do
|
|||
For "Warning: The repository at location ... was previously located at ..."
|
||||
BORG_CHECK_I_KNOW_WHAT_I_AM_DOING
|
||||
For "Warning: 'check --repair' is an experimental feature that might result in data loss."
|
||||
BORG_CYTHON_DISABLE
|
||||
Disables the loading of Cython modules. This is currently
|
||||
experimental and is used only to generate usage docs at build
|
||||
time. It is unlikely to produce good results on a regular
|
||||
run. The variable should be set to the name of the calling class, and
|
||||
should be unique across all of borg. It is currently only used by ``build_usage``.
|
||||
|
||||
Directories:
|
||||
BORG_KEYS_DIR
|
||||
|
|
5
setup.py
5
setup.py
|
@ -135,8 +135,6 @@ class build_usage(Command):
|
|||
def run(self):
|
||||
print('generating usage docs')
|
||||
# allows us to build docs without the C modules fully loaded during help generation
|
||||
if 'BORG_CYTHON_DISABLE' not in os.environ:
|
||||
os.environ['BORG_CYTHON_DISABLE'] = self.__class__.__name__
|
||||
from borg.archiver import Archiver
|
||||
parser = Archiver().build_parser(prog='borg')
|
||||
choices = {}
|
||||
|
@ -166,9 +164,6 @@ class build_usage(Command):
|
|||
doc.write(re.sub("^", " ", parser.format_help(), flags=re.M))
|
||||
doc.write("\nDescription\n~~~~~~~~~~~\n")
|
||||
doc.write(epilog)
|
||||
# return to regular Cython configuration, if we changed it
|
||||
if os.environ.get('BORG_CYTHON_DISABLE') == self.__class__.__name__:
|
||||
del os.environ['BORG_CYTHON_DISABLE']
|
||||
|
||||
|
||||
class build_api(Command):
|
||||
|
|
Loading…
Reference in New Issue