From 76fed7821179f8df279148ed35e49950c6442f3f Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Mon, 12 Jun 2017 13:54:44 +0300 Subject: [PATCH] Made it possible to use installed umsgpack --- setup.py | 49 ++++++++++++++++++++++++++++------------- src/depends.py | 5 +++-- src/helper_msgcoding.py | 7 ++++-- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index 5330ae68..0da5680a 100644 --- a/setup.py +++ b/setup.py @@ -52,7 +52,22 @@ packageName = { "openSUSE": "python-msgpack-python", "Fedora": "python2-msgpack", "Guix": "python2-msgpack", - "Gentoo": "dev-python/msgpack" + "Gentoo": "dev-python/msgpack", + "optional": True, + "description": "python-msgpack is recommended for messages coding" + }, + "umsgpack": { + "FreeBSD": "", + "OpenBSD": "", + "Fedora": "", + "openSUSE": "", + "Guix": "", + "Ubuntu 12": "", + "Debian": "python-u-msgpack", + "Ubuntu": "python-u-msgpack", + "Gentoo": "dev-python/u-msgpack", + "optional": True, + "description": "umsgpack can be used instead of msgpack" }, "pyopencl": { "FreeBSD": "py27-pyopencl", @@ -202,9 +217,25 @@ if __name__ == "__main__": ) installRequires = [] - # this will silently accept alternative providers of msgpack if they are already installed + packages = [ + 'pybitmessage', + 'pybitmessage.bitmessageqt', + 'pybitmessage.bitmessagecurses', + 'pybitmessage.messagetypes', + 'pybitmessage.network', + 'pybitmessage.pyelliptic', + 'pybitmessage.socks', + 'pybitmessage.storage', + 'pybitmessage.plugins' + ] + # this will silently accept alternative providers of msgpack + # if they are already installed if "msgpack" in detectPrereqs(): installRequires.append("msgpack-python") + elif "umsgpack" in detectPrereqs(): + installRequires.append("umsgpack") + else: + packages += ['pybitmessage.fallback', 'pybitmessage.fallback.umsgpack'] try: dist = setup( @@ -234,19 +265,7 @@ if __name__ == "__main__": "Topic :: Software Development :: Libraries :: Python Modules", ], package_dir={'pybitmessage': 'src'}, - packages=[ - 'pybitmessage', - 'pybitmessage.bitmessageqt', - 'pybitmessage.bitmessagecurses', - 'pybitmessage.messagetypes', - 'pybitmessage.network', - 'pybitmessage.pyelliptic', - 'pybitmessage.socks', - 'pybitmessage.storage', - 'pybitmessage.fallback', - 'pybitmessage.fallback.umsgpack', - 'pybitmessage.plugins' - ], + packages=packages, package_data={'': [ 'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem', 'translations/*.ts', 'translations/*.qm', diff --git a/src/depends.py b/src/depends.py index 49c5c7a8..d66663b1 100755 --- a/src/depends.py +++ b/src/depends.py @@ -204,7 +204,9 @@ def check_msgpack(): try: import msgpack except ImportError: - logger.error('The msgpack package is not available. PyBitmessage requires msgpack.') + logger.error( + 'The msgpack package is not available.' + 'It is highly recommended for messages coding.') if sys.platform.startswith('openbsd'): logger.error('On OpenBSD, try running "pkg_add py-msgpack" as root.') elif sys.platform.startswith('freebsd'): @@ -224,7 +226,6 @@ def check_msgpack(): else: logger.error('If your package manager does not have this package, try running "pip install msgpack-python".') - return False return True def check_dependencies(verbose = False, optional = False): diff --git a/src/helper_msgcoding.py b/src/helper_msgcoding.py index 3e156754..aae35d27 100644 --- a/src/helper_msgcoding.py +++ b/src/helper_msgcoding.py @@ -3,12 +3,14 @@ try: import msgpack except ImportError: - import fallback.umsgpack.umsgpack as msgpack + try: + import umsgpack as msgpack + except ImportError: + import fallback.umsgpack.umsgpack as msgpack import string import zlib from bmconfigparser import BMConfigParser -import shared from debug import logger import messagetypes from tr import _translate @@ -18,6 +20,7 @@ BITMESSAGE_ENCODING_TRIVIAL = 1 BITMESSAGE_ENCODING_SIMPLE = 2 BITMESSAGE_ENCODING_EXTENDED = 3 + class DecompressionSizeException(Exception): def __init__(self, size): self.size = size