From 391252476d623dc64c020ef08bb6da1bb3717a47 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 14 Feb 2026 20:45:09 +0100 Subject: [PATCH] remove API_VERSION check we now have better build tools and these exceptions have not been seen since long. --- src/borg/archiver/__init__.py | 3 +-- src/borg/chunkers/__init__.py | 2 -- src/borg/chunkers/buzhash.pyi | 2 -- src/borg/chunkers/buzhash.pyx | 2 +- src/borg/chunkers/buzhash64.pyi | 2 -- src/borg/chunkers/buzhash64.pyx | 2 +- src/borg/chunkers/failing.py | 2 -- src/borg/chunkers/fixed.py | 1 - src/borg/chunkers/reader.pyi | 2 -- src/borg/chunkers/reader.pyx | 2 +- src/borg/compress.pyi | 2 -- src/borg/compress.pyx | 2 +- src/borg/crypto/low_level.pyi | 2 -- src/borg/crypto/low_level.pyx | 2 +- src/borg/hashindex.pyi | 2 -- src/borg/hashindex.pyx | 2 +- src/borg/helpers/__init__.py | 2 +- src/borg/helpers/checks.py | 19 ------------------- src/borg/item.pyi | 2 -- src/borg/item.pyx | 2 +- src/borg/platform/__init__.py | 8 +------- src/borg/platform/base.py | 1 - src/borg/platform/darwin.pyx | 2 +- src/borg/platform/freebsd.pyx | 2 +- src/borg/platform/linux.pyx | 2 +- src/borg/platform/netbsd.pyx | 2 +- 26 files changed, 14 insertions(+), 60 deletions(-) delete mode 100644 src/borg/helpers/checks.py diff --git a/src/borg/archiver/__init__.py b/src/borg/archiver/__init__.py index 7f7610fae..834bf7b5c 100644 --- a/src/borg/archiver/__init__.py +++ b/src/borg/archiver/__init__.py @@ -40,7 +40,7 @@ try: from ..helpers import format_file_size from ..helpers import remove_surrogates, text_to_json from ..helpers import DatetimeWrapper, replace_placeholders - from ..helpers import check_extension_modules + from ..helpers import is_slow_msgpack, is_supported_msgpack, sysinfo from ..helpers import signal_handler, raising_signal_handler, SigHup, SigTerm from ..helpers import ErrorIgnoringTextIOWrapper @@ -456,7 +456,6 @@ class Archiver( def prerun_checks(self, logger, is_serve): - check_extension_modules() selftest(logger) def _setup_implied_logging(self, args): diff --git a/src/borg/chunkers/__init__.py b/src/borg/chunkers/__init__.py index 5e3094d03..dd3376985 100644 --- a/src/borg/chunkers/__init__.py +++ b/src/borg/chunkers/__init__.py @@ -4,8 +4,6 @@ from .failing import ChunkerFailing from .fixed import ChunkerFixed from .reader import * # noqa -API_VERSION = "1.2_01" - def get_chunker(algo, *params, **kw): key = kw.get("key", None) diff --git a/src/borg/chunkers/buzhash.pyi b/src/borg/chunkers/buzhash.pyi index 16f9d46bb..72e1c7005 100644 --- a/src/borg/chunkers/buzhash.pyi +++ b/src/borg/chunkers/buzhash.pyi @@ -2,8 +2,6 @@ from typing import List, Iterator, BinaryIO from .reader import fmap_entry -API_VERSION: str - def buzhash(data: bytes, seed: int) -> int: ... def buzhash_update(sum: int, remove: int, add: int, len: int, seed: int) -> int: ... diff --git a/src/borg/chunkers/buzhash.pyx b/src/borg/chunkers/buzhash.pyx index 627d5ba62..d31ddf8b9 100644 --- a/src/borg/chunkers/buzhash.pyx +++ b/src/borg/chunkers/buzhash.pyx @@ -1,6 +1,6 @@ # cython: language_level=3 -API_VERSION = '1.2_01' + import cython import time diff --git a/src/borg/chunkers/buzhash64.pyi b/src/borg/chunkers/buzhash64.pyi index 7ff85b0f8..b5ee1879f 100644 --- a/src/borg/chunkers/buzhash64.pyi +++ b/src/borg/chunkers/buzhash64.pyi @@ -2,8 +2,6 @@ from typing import List, Iterator, BinaryIO from .reader import fmap_entry -API_VERSION: str - def buzhash64(data: bytes, key: bytes) -> int: ... def buzhash64_update(sum: int, remove: int, add: int, len: int, key: bytes) -> int: ... def buzhash64_get_table(key: bytes) -> List[int]: ... diff --git a/src/borg/chunkers/buzhash64.pyx b/src/borg/chunkers/buzhash64.pyx index c241e5845..a03a98829 100644 --- a/src/borg/chunkers/buzhash64.pyx +++ b/src/borg/chunkers/buzhash64.pyx @@ -1,6 +1,6 @@ # cython: language_level=3 -API_VERSION = '1.2_01' + import cython import time diff --git a/src/borg/chunkers/failing.py b/src/borg/chunkers/failing.py index 856ff6dee..771320851 100644 --- a/src/borg/chunkers/failing.py +++ b/src/borg/chunkers/failing.py @@ -1,5 +1,3 @@ -API_VERSION = "1.2_01" - import os import errno from typing import BinaryIO, Iterator diff --git a/src/borg/chunkers/fixed.py b/src/borg/chunkers/fixed.py index 3cdab7a9f..bedc4df4a 100644 --- a/src/borg/chunkers/fixed.py +++ b/src/borg/chunkers/fixed.py @@ -1,6 +1,5 @@ from typing import Iterator, BinaryIO -API_VERSION = "1.2_01" import time diff --git a/src/borg/chunkers/reader.pyi b/src/borg/chunkers/reader.pyi index 76a0f53ec..53e92188e 100644 --- a/src/borg/chunkers/reader.pyi +++ b/src/borg/chunkers/reader.pyi @@ -1,7 +1,5 @@ from typing import NamedTuple, Tuple, Dict, List, Any, Type, BinaryIO, Iterator -API_VERSION: str - has_seek_hole: bool class _Chunk(NamedTuple): diff --git a/src/borg/chunkers/reader.pyx b/src/borg/chunkers/reader.pyx index 26258914b..2a45e55ca 100644 --- a/src/borg/chunkers/reader.pyx +++ b/src/borg/chunkers/reader.pyx @@ -1,6 +1,6 @@ # cython: language_level=3 -API_VERSION = '1.2_01' + import os import errno diff --git a/src/borg/compress.pyi b/src/borg/compress.pyi index 64defa372..c8a271a1c 100644 --- a/src/borg/compress.pyi +++ b/src/borg/compress.pyi @@ -1,7 +1,5 @@ from typing import Any, Type, Dict, Tuple -API_VERSION: str - def get_compressor(name: str, **kwargs) -> Any: ... class CompressionSpec: diff --git a/src/borg/compress.pyx b/src/borg/compress.pyx index e78821ec9..3327f4ee1 100644 --- a/src/borg/compress.pyx +++ b/src/borg/compress.pyx @@ -29,7 +29,7 @@ except ImportError: from .constants import MAX_DATA_SIZE, ROBJ_FILE_STREAM from .helpers import Buffer, DecompressionError -API_VERSION = '1.2_02' + cdef extern from "lz4.h": int LZ4_compress_default(const char* source, char* dest, int inputSize, int maxOutputSize) nogil diff --git a/src/borg/crypto/low_level.pyi b/src/borg/crypto/low_level.pyi index 7d5b0f9a7..9f8d61950 100644 --- a/src/borg/crypto/low_level.pyi +++ b/src/borg/crypto/low_level.pyi @@ -3,8 +3,6 @@ from typing import Optional, Union -API_VERSION: str - # Module-level functions def num_cipher_blocks(length: int, blocksize: int = 16) -> int: """Return the number of cipher blocks required to encrypt/decrypt bytes of data.""" diff --git a/src/borg/crypto/low_level.pyx b/src/borg/crypto/low_level.pyx index f723cde52..074135c62 100644 --- a/src/borg/crypto/low_level.pyx +++ b/src/borg/crypto/low_level.pyx @@ -45,7 +45,7 @@ from libc.stdlib cimport malloc, free from libc.stdint cimport uint8_t, uint32_t, uint64_t from libc.string cimport memset, memcpy -API_VERSION = '1.3_01' + cdef extern from "openssl/crypto.h": int CRYPTO_memcmp(const void *a, const void *b, size_t len) diff --git a/src/borg/hashindex.pyi b/src/borg/hashindex.pyi index 626973319..60c4fa8da 100644 --- a/src/borg/hashindex.pyi +++ b/src/borg/hashindex.pyi @@ -1,7 +1,5 @@ from typing import NamedTuple, Tuple, Type, IO, Iterator, Any -API_VERSION: str - PATH_OR_FILE = str | IO class ChunkIndexEntry(NamedTuple): diff --git a/src/borg/hashindex.pyx b/src/borg/hashindex.pyx index b2c466e15..a62a0491a 100644 --- a/src/borg/hashindex.pyx +++ b/src/borg/hashindex.pyx @@ -5,7 +5,7 @@ import struct from borghash import HashTableNT -API_VERSION = '1.2_01' + cdef _NoDefault = object() diff --git a/src/borg/helpers/__init__.py b/src/borg/helpers/__init__.py index 74800d6a3..7902d5bb6 100644 --- a/src/borg/helpers/__init__.py +++ b/src/borg/helpers/__init__.py @@ -10,7 +10,7 @@ import logging from collections import namedtuple from ..constants import * # NOQA -from .checks import check_extension_modules + from .datastruct import StableDict, Buffer, EfficientCollectionQueue from .errors import Error, ErrorWithTraceback, IntegrityError, DecompressionError, CancelledByUser, CommandError from .errors import RTError, modern_ec diff --git a/src/borg/helpers/checks.py b/src/borg/helpers/checks.py deleted file mode 100644 index 8c935bee7..000000000 --- a/src/borg/helpers/checks.py +++ /dev/null @@ -1,19 +0,0 @@ -from .errors import RTError - - -def check_extension_modules(): - from .. import platform, compress, crypto, item, hashindex, chunkers - - msg = """The Borg binary extension modules do not seem to be properly installed.""" - if hashindex.API_VERSION != "1.2_01": - raise RTError(msg) - if chunkers.API_VERSION != "1.2_01": - raise RTError(msg) - if compress.API_VERSION != "1.2_02": - raise RTError(msg) - if crypto.low_level.API_VERSION != "1.3_01": - raise RTError(msg) - if item.API_VERSION != "1.2_01": - raise RTError(msg) - if platform.API_VERSION != platform.OS_API_VERSION or platform.API_VERSION != "1.2_05": - raise RTError(msg) diff --git a/src/borg/item.pyi b/src/borg/item.pyi index 53177394d..a5047da1b 100644 --- a/src/borg/item.pyi +++ b/src/borg/item.pyi @@ -2,8 +2,6 @@ from typing import Set, NamedTuple, Tuple, Mapping, Dict, List, Iterator, Callab from .helpers import StableDict -API_VERSION: str - def want_bytes(v: Any, *, errors: str = ...) -> bytes: ... def chunks_contents_equal(chunks1: Iterator, chunks2: Iterator) -> bool: ... diff --git a/src/borg/item.pyx b/src/borg/item.pyx index 7b1011659..8e39d346a 100644 --- a/src/borg/item.pyx +++ b/src/borg/item.pyx @@ -17,7 +17,7 @@ cdef extern from "_item.c": object _optr_to_object(object bytes) -API_VERSION = '1.2_01' + def fix_key(data, key, *, errors='strict'): diff --git a/src/borg/platform/__init__.py b/src/borg/platform/__init__.py index fed7e2fe9..ea0914fc5 100644 --- a/src/borg/platform/__init__.py +++ b/src/borg/platform/__init__.py @@ -8,7 +8,7 @@ from types import ModuleType from ..platformflags import is_win32, is_linux, is_freebsd, is_netbsd, is_darwin, is_cygwin, is_haiku -from .base import ENOATTR, API_VERSION +from .base import ENOATTR from .base import SaveFile, sync_dir, fdatasync, safe_fadvise from .base import get_process_id, fqdn, hostname, hostid, swidth @@ -18,7 +18,6 @@ from . import xattr # noqa: F401 platform_ug: ModuleType | None = None # make mypy happy if is_linux: # pragma: linux only - from .linux import API_VERSION as OS_API_VERSION from .linux import listxattr, getxattr, setxattr from .linux import acl_get, acl_set from .linux import set_flags, get_flags @@ -28,7 +27,6 @@ if is_linux: # pragma: linux only from .posix import getosusername from . import posix_ug as platform_ug elif is_freebsd: # pragma: freebsd only - from .freebsd import API_VERSION as OS_API_VERSION from .freebsd import listxattr, getxattr, setxattr from .freebsd import acl_get, acl_set from .freebsd import set_flags @@ -39,7 +37,6 @@ elif is_freebsd: # pragma: freebsd only from .posix import getosusername from . import posix_ug as platform_ug elif is_netbsd: # pragma: netbsd only - from .netbsd import API_VERSION as OS_API_VERSION from .netbsd import listxattr, getxattr, setxattr from .base import acl_get, acl_set from .base import set_flags, get_flags @@ -49,7 +46,6 @@ elif is_netbsd: # pragma: netbsd only from .posix import getosusername from . import posix_ug as platform_ug elif is_darwin: # pragma: darwin only - from .darwin import API_VERSION as OS_API_VERSION from .darwin import listxattr, getxattr, setxattr from .darwin import acl_get, acl_set from .darwin import is_darwin_feature_64_bit_inode, _get_birthtime_ns @@ -62,7 +58,6 @@ elif is_darwin: # pragma: darwin only from . import posix_ug as platform_ug elif not is_win32: # pragma: posix only # Generic code for all other POSIX OSes - OS_API_VERSION = API_VERSION from .base import listxattr, getxattr, setxattr from .base import acl_get, acl_set from .base import set_flags, get_flags @@ -73,7 +68,6 @@ elif not is_win32: # pragma: posix only from . import posix_ug as platform_ug else: # pragma: win32 only # Win32-specific stuff - OS_API_VERSION = API_VERSION from .base import listxattr, getxattr, setxattr from .base import acl_get, acl_set from .base import set_flags, get_flags diff --git a/src/borg/platform/base.py b/src/borg/platform/base.py index f4c39561b..53c1a3563 100644 --- a/src/borg/platform/base.py +++ b/src/borg/platform/base.py @@ -20,7 +20,6 @@ platform API; in this way, platform APIs provided by the platform-specific suppo are correctly composed into the base functionality. """ -API_VERSION = "1.2_05" fdatasync = getattr(os, "fdatasync", os.fsync) has_posix_fadvise = hasattr(os, "posix_fadvise") diff --git a/src/borg/platform/darwin.pyx b/src/borg/platform/darwin.pyx index 4f63607c3..4d73ff531 100644 --- a/src/borg/platform/darwin.pyx +++ b/src/borg/platform/darwin.pyx @@ -8,7 +8,7 @@ from . import posix_ug from ..helpers import safe_decode, safe_encode from .xattr import _listxattr_inner, _getxattr_inner, _setxattr_inner, split_string0 -API_VERSION = '1.2_05' + cdef extern from *: """ diff --git a/src/borg/platform/freebsd.pyx b/src/borg/platform/freebsd.pyx index d16e25482..83f2a4b28 100644 --- a/src/borg/platform/freebsd.pyx +++ b/src/borg/platform/freebsd.pyx @@ -7,7 +7,7 @@ from .posix import posix_acl_use_stored_uid_gid from ..helpers import safe_encode, safe_decode from .xattr import _listxattr_inner, _getxattr_inner, _setxattr_inner, split_lstring -API_VERSION = '1.2_05' + cdef extern from "sys/extattr.h": ssize_t c_extattr_list_file "extattr_list_file" (const char *path, int attrnamespace, void *data, size_t nbytes) diff --git a/src/borg/platform/linux.pyx b/src/borg/platform/linux.pyx index 138ee7a0f..df9dceff5 100644 --- a/src/borg/platform/linux.pyx +++ b/src/borg/platform/linux.pyx @@ -17,7 +17,7 @@ except ImportError: from libc cimport errno -API_VERSION = '1.2_05' + cdef extern from "sys/xattr.h": ssize_t c_listxattr "listxattr" (const char *path, char *list, size_t size) diff --git a/src/borg/platform/netbsd.pyx b/src/borg/platform/netbsd.pyx index b79c02abc..12c2c0904 100644 --- a/src/borg/platform/netbsd.pyx +++ b/src/borg/platform/netbsd.pyx @@ -1,6 +1,6 @@ from .xattr import _listxattr_inner, _getxattr_inner, _setxattr_inner, split_lstring -API_VERSION = '1.2_05' + cdef extern from "sys/extattr.h": ssize_t c_extattr_list_file "extattr_list_file" (const char *path, int attrnamespace, void *data, size_t nbytes)