From b3b5602ac23c1ef8383ce26284a4f86ff9e5aa64 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 4 Aug 2022 10:46:36 +0200 Subject: [PATCH 1/2] _chunker.c: fix warnings on macOS macOS does not have POSIX_FADV_DONTNEED, thus some variables are not needed. --- src/borg/_chunker.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/borg/_chunker.c b/src/borg/_chunker.c index 75599c5b1..dd141e87b 100644 --- a/src/borg/_chunker.c +++ b/src/borg/_chunker.c @@ -154,8 +154,6 @@ static int chunker_fill(Chunker *c) { ssize_t n; - off_t offset, length; - int overshoot; PyObject *data; PyThreadState *thread_state; @@ -169,7 +167,10 @@ chunker_fill(Chunker *c) if(c->fh >= 0) { thread_state = PyEval_SaveThread(); - offset = c->bytes_read; + #if ( ( _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L ) && defined(POSIX_FADV_DONTNEED) ) + off_t offset = c->bytes_read; + #endif + // if we have a os-level file descriptor, use os-level API n = read(c->fh, c->data + c->position + c->remaining, n); if(n > 0) { @@ -186,8 +187,8 @@ chunker_fill(Chunker *c) PyErr_SetFromErrno(PyExc_OSError); return 0; } - length = c->bytes_read - offset; #if ( ( _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L ) && defined(POSIX_FADV_DONTNEED) ) + off_t length = c->bytes_read - offset; // Only do it once per run. if (pagemask == 0) @@ -200,6 +201,7 @@ chunker_fill(Chunker *c) // for the OS or other processes. // We rollback the initial offset back to the start of the page, // to avoid it not being truncated as a partial page request. + int overshoot; if (length > 0) { // All Linux kernels (at least up to and including 4.6(.0)) have a bug where // they truncate last partial page of POSIX_FADV_DONTNEED request, so we need From 69f4898460668bdcc8e7ff46052717ae3416ee76 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 4 Aug 2022 15:50:05 +0200 Subject: [PATCH 2/2] make setuptools happy, fixes #6874 work around setuptools puking about: ############################ # Package would be ignored # ############################ Python recognizes 'borg.cache_sync' as an importable package, but it is not listed in the `packages` configuration of setuptools. 'borg.cache_sync' has been automatically added to the distribution only because it may contain data files, but this behavior is likely to change in future versions of setuptools (and therefore is considered deprecated). Please make sure that 'borg.cache_sync' is included as a package by using the `packages` configuration field or the proper discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" and "data files" on setuptools documentation page. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 95c31fe02..dd42245af 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ except ImportError: multiprocessing = None from setuptools.command.build_ext import build_ext -from setuptools import setup, find_packages, Extension, Command +from setuptools import setup, find_namespace_packages, Extension, Command from setuptools.command.sdist import sdist try: @@ -292,7 +292,7 @@ setup( 'Topic :: Security :: Cryptography', 'Topic :: System :: Archiving :: Backup', ], - packages=find_packages('src'), + packages=find_namespace_packages('src'), package_dir={'': 'src'}, zip_safe=False, entry_points={