From 3db4b35c3e76af2088457f3ba995b0ca4732aec8 Mon Sep 17 00:00:00 2001 From: Felix Schwarz Date: May 10 2019 19:56:01 +0000 Subject: bundle msgpack --- diff --git a/0010-msgpack-use-relative-imports.patch b/0010-msgpack-use-relative-imports.patch new file mode 100644 index 0000000..27400b0 --- /dev/null +++ b/0010-msgpack-use-relative-imports.patch @@ -0,0 +1,109 @@ +commit 43c500bf080eb1d1df0df1d6b6ccd7e801c663dd +Author: Your Name +Date: Thu May 9 21:28:21 2019 +0200 + + use relative imports + + This makes it possible to vendorize msgpack (with a different module name) more easily. + +diff --git a/msgpack/__init__.py b/msgpack/__init__.py +index 3955a41..3a3cf3a 100644 +--- a/msgpack/__init__.py ++++ b/msgpack/__init__.py +@@ -1,6 +1,6 @@ + # coding: utf-8 +-from msgpack._version import version +-from msgpack.exceptions import * ++from ._version import version ++from .exceptions import * + + from collections import namedtuple + +@@ -19,13 +19,13 @@ class ExtType(namedtuple('ExtType', 'code data')): + + import os + if os.environ.get('MSGPACK_PUREPYTHON'): +- from msgpack.fallback import Packer, unpackb, Unpacker ++ from .fallback import Packer, unpackb, Unpacker + else: + try: +- from msgpack._packer import Packer +- from msgpack._unpacker import unpackb, Unpacker ++ from ._packer import Packer ++ from ._unpacker import unpackb, Unpacker + except ImportError: +- from msgpack.fallback import Packer, unpackb, Unpacker ++ from .fallback import Packer, unpackb, Unpacker + + + def pack(o, stream, **kwargs): +diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx +index 225f24a..c490a5b 100644 +--- a/msgpack/_packer.pyx ++++ b/msgpack/_packer.pyx +@@ -5,8 +5,8 @@ from cpython cimport * + from cpython.version cimport PY_MAJOR_VERSION + from cpython.exc cimport PyErr_WarnEx + +-from msgpack.exceptions import PackValueError, PackOverflowError +-from msgpack import ExtType ++from .exceptions import PackValueError, PackOverflowError ++from . import ExtType + + + cdef extern from "Python.h": +diff --git a/msgpack/_unpacker.pyx b/msgpack/_unpacker.pyx +index d7fa5bc..0abd9c1 100644 +--- a/msgpack/_unpacker.pyx ++++ b/msgpack/_unpacker.pyx +@@ -32,13 +32,13 @@ from libc.string cimport * + from libc.limits cimport * + ctypedef unsigned long long uint64_t + +-from msgpack.exceptions import ( ++from .exceptions import ( + BufferFull, + OutOfData, + UnpackValueError, + ExtraData, + ) +-from msgpack import ExtType ++from . import ExtType + + + cdef extern from "unpack.h": +diff --git a/msgpack/fallback.py b/msgpack/fallback.py +index c0e5fd6..fd01bf8 100644 +--- a/msgpack/fallback.py ++++ b/msgpack/fallback.py +@@ -49,7 +49,7 @@ else: + newlist_hint = lambda size: [] + + +-from msgpack.exceptions import ( ++from .exceptions import ( + BufferFull, + OutOfData, + UnpackValueError, +@@ -57,7 +57,7 @@ from msgpack.exceptions import ( + PackOverflowError, + ExtraData) + +-from msgpack import ExtType ++from . import ExtType + + + EX_SKIP = 0 +diff --git a/msgpack/unpack_define.h b/msgpack/unpack_define.h +index 0dd708d..d681277 100644 +--- a/msgpack/unpack_define.h ++++ b/msgpack/unpack_define.h +@@ -18,7 +18,7 @@ + #ifndef MSGPACK_UNPACK_DEFINE_H__ + #define MSGPACK_UNPACK_DEFINE_H__ + +-#include "msgpack/sysdep.h" ++#include "sysdep.h" + #include + #include + #include diff --git a/0011-also-build-msgpack.patch b/0011-also-build-msgpack.patch new file mode 100644 index 0000000..d5b6ff3 --- /dev/null +++ b/0011-also-build-msgpack.patch @@ -0,0 +1,87 @@ +commit 17cdeebe701c46acb3125a8f46c105ef917d6af7 +Author: Your Name +Date: Thu May 9 21:23:29 2019 +0200 + + use msgpack + +diff --git a/setup.py b/setup.py +index edbccae..93c0c2e 100644 +--- a/setup.py ++++ b/setup.py +@@ -39,7 +39,7 @@ install_requires = [ + # we are rather picky about msgpack versions, because a good working msgpack is + # very important for borg, see https://github.com/borgbackup/borg/issues/3753 + # best versions seem to be 0.4.6, 0.4.7, 0.4.8 and 0.5.6: +- 'msgpack-python >=0.4.6, <=0.5.6, !=0.5.0, !=0.5.1, !=0.5.2, !=0.5.3, !=0.5.4, !=0.5.5', ++ #'msgpack-python >=0.4.6, <=0.5.6, !=0.5.0, !=0.5.1, !=0.5.2, !=0.5.3, !=0.5.4, !=0.5.5', + # if you can't satisfy the above requirement, these are versions that might + # also work ok, IF you make sure to use the COMPILED version of msgpack-python, + # NOT the PURE PYTHON fallback implementation: ==0.5.1, ==0.5.4 +@@ -88,6 +88,8 @@ platform_posix_source = 'src/borg/platform/posix.pyx' + platform_linux_source = 'src/borg/platform/linux.pyx' + platform_darwin_source = 'src/borg/platform/darwin.pyx' + platform_freebsd_source = 'src/borg/platform/freebsd.pyx' ++msgpack_packer_source = 'src/borg/_msgpack/_packer.pyx' ++msgpack_unpacker_source = 'src/borg/_msgpack/_unpacker.pyx' + + cython_sources = [ + compress_source, +@@ -129,6 +131,8 @@ try: + 'src/borg/platform/linux.c', + 'src/borg/platform/freebsd.c', + 'src/borg/platform/darwin.c', ++ 'src/borg/_msgpack/_packer.cpp', ++ 'src/borg/_msgpack/_unpacker.cpp', + ]) + super().make_distribution() + +@@ -147,10 +151,15 @@ except ImportError: + platform_linux_source = platform_linux_source.replace('.pyx', '.c') + platform_freebsd_source = platform_freebsd_source.replace('.pyx', '.c') + platform_darwin_source = platform_darwin_source.replace('.pyx', '.c') ++ ++ msgpack_packer_source = msgpack_packer_source.replace('.pyx', '.cpp') ++ msgpack_unpacker_source = msgpack_unpacker_source.replace('.pyx', '.cpp') ++ + from distutils.command.build_ext import build_ext + if not on_rtd and not all(os.path.exists(path) for path in [ + compress_source, crypto_ll_source, chunker_source, hashindex_source, item_source, checksums_source, +- platform_posix_source, platform_linux_source, platform_freebsd_source, platform_darwin_source]): ++ platform_posix_source, platform_linux_source, platform_freebsd_source, platform_darwin_source, ++ msgpack_packer_source, msgpack_unpacker_source]): + raise ImportError('The GIT version of Borg needs Cython. Install Cython or use a released version.') + + +@@ -788,7 +797,32 @@ if not on_rtd: + crypto_ext_kwargs = setup_b2.b2_ext_kwargs(bundled_path='src/borg/algorithms/blake2', + system_prefix=libb2_prefix, system=libb2_system, + **crypto_ext_kwargs) ++ ++ def cythonize_cpp(src): ++ sys.stderr.write("cythonize: %r\n" % (src,)) ++ cython_compiler.compile([src], cplus=True) ++ return src.replace('.pyx', '.cpp') ++ ++ msgpack_packer_cpp_source = cythonize_cpp(msgpack_packer_source) ++ _msgpack_endian = '__BIG_ENDIAN__' if (sys.byteorder == 'big') else '__LITTLE_ENDIAN__' ++ _msgpack_macros = [(_msgpack_endian, '1')] ++ _msgpack_packer_ext_kwargs = dict( ++ sources=[msgpack_packer_cpp_source], ++ include_dirs=include_dirs, ++ library_dirs=library_dirs, ++ define_macros=_msgpack_macros, ++ ) ++ msgpack_unpacker_cpp_source = cythonize_cpp(msgpack_unpacker_source) ++ _msgpack_unpacker_ext_kwargs = dict( ++ sources=[msgpack_unpacker_cpp_source], ++ include_dirs=include_dirs, ++ library_dirs=library_dirs, ++ define_macros=_msgpack_macros, ++ ) ++ + ext_modules += [ ++ Extension('borg._msgpack._packer', **_msgpack_packer_ext_kwargs), ++ Extension('borg._msgpack._unpacker', **_msgpack_unpacker_ext_kwargs), + Extension('borg.compress', **compress_ext_kwargs), + Extension('borg.crypto.low_level', **crypto_ext_kwargs), + Extension('borg.hashindex', [hashindex_source]), diff --git a/0012-use-bundled-msgpack.patch b/0012-use-bundled-msgpack.patch new file mode 100644 index 0000000..8cb5055 --- /dev/null +++ b/0012-use-bundled-msgpack.patch @@ -0,0 +1,210 @@ +commit 4d7f1b33ac971bf5f798de69b60292b0125f3f68 +Author: Felix Schwarz +Date: Sat May 4 21:25:56 2019 +0200 + + use bundled msgpack + +diff --git a/src/borg/archive.py b/src/borg/archive.py +index 2ff77030..db0c142d 100644 +--- a/src/borg/archive.py ++++ b/src/borg/archive.py +@@ -13,7 +13,7 @@ + from itertools import groupby + from shutil import get_terminal_size + +-import msgpack ++import borg._msgpack as msgpack + + from .logger import create_logger + +diff --git a/src/borg/archiver.py b/src/borg/archiver.py +index 41e34a83..ce3ec10b 100644 +--- a/src/borg/archiver.py ++++ b/src/borg/archiver.py +@@ -29,7 +29,7 @@ + + logger = create_logger() + +-import msgpack ++import borg._msgpack as msgpack + + import borg + from . import __version__ +diff --git a/src/borg/cache.py b/src/borg/cache.py +index 1ae2c4f6..e5e2b3b7 100644 +--- a/src/borg/cache.py ++++ b/src/borg/cache.py +@@ -6,7 +6,7 @@ + from collections import namedtuple + from time import perf_counter + +-import msgpack ++import borg._msgpack as msgpack + + from .logger import create_logger + +diff --git a/src/borg/crypto/key.py b/src/borg/crypto/key.py +index e83a0a66..43e612a6 100644 +--- a/src/borg/crypto/key.py ++++ b/src/borg/crypto/key.py +@@ -9,7 +9,7 @@ + from hashlib import sha256, sha512, pbkdf2_hmac + from hmac import HMAC, compare_digest + +-import msgpack ++import borg._msgpack as msgpack + + from borg.logger import create_logger + +diff --git a/src/borg/fuse.py b/src/borg/fuse.py +index a6999514..4bc2740c 100644 +--- a/src/borg/fuse.py ++++ b/src/borg/fuse.py +@@ -11,7 +11,7 @@ + from distutils.version import LooseVersion + + import llfuse +-import msgpack ++import borg._msgpack as msgpack + + from .logger import create_logger + logger = create_logger() +diff --git a/src/borg/helpers.py b/src/borg/helpers.py +index ed6b3afe..ae60c577 100644 +--- a/src/borg/helpers.py ++++ b/src/borg/helpers.py +@@ -31,8 +31,8 @@ + from string import Formatter + from shutil import get_terminal_size + +-import msgpack +-import msgpack.fallback ++import borg._msgpack as msgpack ++from borg._msgpack import fallback as msgpack_fallback + + from .logger import create_logger + logger = create_logger() +@@ -1287,7 +1287,7 @@ def int_to_bigint(value): + + + def is_slow_msgpack(): +- return msgpack.Packer is msgpack.fallback.Packer ++ return msgpack.Packer is msgpack_fallback.Packer + + + def is_supported_msgpack(): +diff --git a/src/borg/remote.py b/src/borg/remote.py +index 4a3bba7a..e8250e6d 100644 +--- a/src/borg/remote.py ++++ b/src/borg/remote.py +@@ -16,7 +16,7 @@ + import traceback + from subprocess import Popen, PIPE + +-import msgpack ++import borg._msgpack as msgpack + + from . import __version__ + from .compress import LZ4 +diff --git a/src/borg/repository.py b/src/borg/repository.py +index afa6a3f9..4c8369ec 100644 +--- a/src/borg/repository.py ++++ b/src/borg/repository.py +@@ -10,7 +10,7 @@ + from functools import partial + from itertools import islice + +-import msgpack ++import borg._msgpack as msgpack + + from .constants import * # NOQA + from .hashindex import NSIndex +diff --git a/src/borg/testsuite/archive.py b/src/borg/testsuite/archive.py +index bc113352..00bb6b22 100644 +--- a/src/borg/testsuite/archive.py ++++ b/src/borg/testsuite/archive.py +@@ -3,7 +3,7 @@ + from io import StringIO + from unittest.mock import Mock + +-import msgpack ++import borg._msgpack as msgpack + import pytest + + from . import BaseTestCase +diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py +index 179b41f8..3a7da857 100644 +--- a/src/borg/testsuite/archiver.py ++++ b/src/borg/testsuite/archiver.py +@@ -22,7 +22,7 @@ + from io import BytesIO, StringIO + from unittest.mock import patch + +-import msgpack ++import borg._msgpack as msgpack + import pytest + + try: +diff --git a/src/borg/testsuite/cache.py b/src/borg/testsuite/cache.py +index 31ebf55a..87c1a696 100644 +--- a/src/borg/testsuite/cache.py ++++ b/src/borg/testsuite/cache.py +@@ -1,7 +1,7 @@ + import io + import os.path + +-from msgpack import packb ++from borg._msgpack import packb + + import pytest + +diff --git a/src/borg/testsuite/helpers.py b/src/borg/testsuite/helpers.py +index 61efb9c7..21b2d021 100644 +--- a/src/borg/testsuite/helpers.py ++++ b/src/borg/testsuite/helpers.py +@@ -9,8 +9,8 @@ + + import pytest + +-import msgpack +-import msgpack.fallback ++import borg._msgpack as msgpack ++import borg._msgpack.fallback as msgpack_fallback + + from .. import platform + from ..helpers import Location +@@ -576,7 +576,7 @@ def test_parse_file_size_invalid(string): + def test_is_slow_msgpack(): + saved_packer = msgpack.Packer + try: +- msgpack.Packer = msgpack.fallback.Packer ++ msgpack.Packer = msgpack_fallback.Packer + assert is_slow_msgpack() + finally: + msgpack.Packer = saved_packer +diff --git a/src/borg/testsuite/key.py b/src/borg/testsuite/key.py +index 5ba6fb52..3881bda3 100644 +--- a/src/borg/testsuite/key.py ++++ b/src/borg/testsuite/key.py +@@ -4,7 +4,7 @@ + import tempfile + from binascii import hexlify, unhexlify + +-import msgpack ++import borg._msgpack as msgpack + import pytest + + from ..crypto.key import Passphrase, PasswordRetriesExceeded, bin_to_hex +diff --git a/src/borg/testsuite/repository.py b/src/borg/testsuite/repository.py +index c6b53df6..ba438f8e 100644 +--- a/src/borg/testsuite/repository.py ++++ b/src/borg/testsuite/repository.py +@@ -6,7 +6,7 @@ + import tempfile + from unittest.mock import patch + +-import msgpack ++import borg._msgpack as msgpack + + import pytest + diff --git a/borgbackup.spec b/borgbackup.spec index 27badb4..325be92 100644 --- a/borgbackup.spec +++ b/borgbackup.spec @@ -2,23 +2,32 @@ Name: %{srcname} Version: 1.1.9 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A deduplicating backup program with compression and authenticated encryption -License: BSD +License: BSD and ASL 2.0 URL: https://borgbackup.readthedocs.org -Source0: https://files.pythonhosted.org/packages/source/b/%{srcname}/%{srcname}-%{version}.tar.gz +Source0: %pypi_source +Source1: https://files.pythonhosted.org/packages/source/m/msgpack/msgpack-0.5.6.tar.gz Patch1: 0002-disable-sphinx-man-page-build.patch Patch2: 0003-test-archiver-fix2.patch +Patch10: 0010-msgpack-use-relative-imports.patch +Patch11: 0011-also-build-msgpack.patch +Patch12: 0012-use-bundled-msgpack.patch + # build BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-setuptools_scm BuildRequires: python%{python3_pkgversion}-Cython BuildRequires: python%{python3_pkgversion}-llfuse -BuildRequires: python%{python3_pkgversion}-msgpack <= 0.5.6 +#BuildRequires: python{python3_pkgversion}-msgpack <= 0.5.6 +Provides: bundled(python%{python3_pkgversion}-msgpack) = 0.5.6 +# requirements for bundled msgpack +BuildRequires: gcc-c++ +BuildRequires: python%{python3_pkgversion}-funcsigs # test BuildRequires: python%{python3_pkgversion}-pytest @@ -34,7 +43,7 @@ BuildRequires: libacl-devel BuildRequires: lz4-devel >= 1.7.0 BuildRequires: libzstd-devel >= 1.3.0 -Requires: python%{python3_pkgversion}-msgpack <= 0.5.6 +#Requires: python{python3_pkgversion}-msgpack <= 0.5.6 Requires: python%{python3_pkgversion}-setuptools Requires: python%{python3_pkgversion}-llfuse Requires: fuse @@ -46,6 +55,8 @@ supports compression and authenticated encryption. %prep %setup -n %{srcname}-%{version} rm -rf %{srcname}.egg-info +%patch11 -p1 +%patch12 -p1 # we don't need the guzzley_sphinx theme for only man page generation %patch1 -p1 @@ -54,6 +65,14 @@ rm -rf %{srcname}.egg-info # https://bugzilla.redhat.com/show_bug.cgi?id=1630992 sed -i 's/msgpack-python/msgpack/' setup.py +cd .. +tar xzf %{SOURCE1} +cd msgpack-0.5.6/ +%patch10 -p1 +cp -a msgpack ../%{srcname}-%{version}/src/borg/_msgpack +cp -a COPYING ../%{srcname}-%{version}/COPYING.msgpack +cd ../%{srcname}-%{version} + %build %py3_build @@ -103,6 +122,7 @@ py.test-3 -x -vk "not test_non_ascii_acl and not test_fuse and not benchmark and %files %license LICENSE +%license COPYING.msgpack %doc README.rst PKG-INFO AUTHORS %doc docs/changes.rst %{_mandir}/man1/* @@ -116,6 +136,9 @@ py.test-3 -x -vk "not test_non_ascii_acl and not test_fuse and not benchmark and %changelog +* Thu May 09 2019 Felix Schwarz - 1.1.9-3 +- bundle msgpack 0.5.6 (rhbz 1669083) + * Sun Mar 10 2019 Benjamin Pereto - 1.1.9-2 - drop python2-sphinx dependency diff --git a/sources b/sources index 3816329..1e19666 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (borgbackup-1.1.9.tar.gz) = 466288258700fb0b3dae936c79fd423d26bea2d721dd70112b3cfd0f8e2bb335144a00de76743c31d336f6c19793775260d154326ec70d6d6d0a4e5ad6a59e59 +SHA512 (msgpack-0.5.6.tar.gz) = bdbd193bd3bd02e78d9c6e8d9d8fa687d13583dff2813bc77c5e6cbbe0d180765da3c9a80d176f9993589e35f548ad04973e3d523d0b6d41ef7916ecd86195aa