Made it possible to use installed umsgpack

This commit is contained in:
Dmitri Bogomolov 2017-06-12 13:54:44 +03:00
parent 06fed6f9c2
commit 76fed78211
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
3 changed files with 42 additions and 19 deletions

View File

@ -52,7 +52,22 @@ packageName = {
"openSUSE": "python-msgpack-python", "openSUSE": "python-msgpack-python",
"Fedora": "python2-msgpack", "Fedora": "python2-msgpack",
"Guix": "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": { "pyopencl": {
"FreeBSD": "py27-pyopencl", "FreeBSD": "py27-pyopencl",
@ -202,9 +217,25 @@ if __name__ == "__main__":
) )
installRequires = [] 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(): if "msgpack" in detectPrereqs():
installRequires.append("msgpack-python") installRequires.append("msgpack-python")
elif "umsgpack" in detectPrereqs():
installRequires.append("umsgpack")
else:
packages += ['pybitmessage.fallback', 'pybitmessage.fallback.umsgpack']
try: try:
dist = setup( dist = setup(
@ -234,19 +265,7 @@ if __name__ == "__main__":
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
], ],
package_dir={'pybitmessage': 'src'}, package_dir={'pybitmessage': 'src'},
packages=[ packages=packages,
'pybitmessage',
'pybitmessage.bitmessageqt',
'pybitmessage.bitmessagecurses',
'pybitmessage.messagetypes',
'pybitmessage.network',
'pybitmessage.pyelliptic',
'pybitmessage.socks',
'pybitmessage.storage',
'pybitmessage.fallback',
'pybitmessage.fallback.umsgpack',
'pybitmessage.plugins'
],
package_data={'': [ package_data={'': [
'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem', 'bitmessageqt/*.ui', 'bitmsghash/*.cl', 'sslkeys/*.pem',
'translations/*.ts', 'translations/*.qm', 'translations/*.ts', 'translations/*.qm',

View File

@ -204,7 +204,9 @@ def check_msgpack():
try: try:
import msgpack import msgpack
except ImportError: 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'): if sys.platform.startswith('openbsd'):
logger.error('On OpenBSD, try running "pkg_add py-msgpack" as root.') logger.error('On OpenBSD, try running "pkg_add py-msgpack" as root.')
elif sys.platform.startswith('freebsd'): elif sys.platform.startswith('freebsd'):
@ -224,7 +226,6 @@ def check_msgpack():
else: else:
logger.error('If your package manager does not have this package, try running "pip install msgpack-python".') logger.error('If your package manager does not have this package, try running "pip install msgpack-python".')
return False
return True return True
def check_dependencies(verbose = False, optional = False): def check_dependencies(verbose = False, optional = False):

View File

@ -3,12 +3,14 @@
try: try:
import msgpack import msgpack
except ImportError: except ImportError:
try:
import umsgpack as msgpack
except ImportError:
import fallback.umsgpack.umsgpack as msgpack import fallback.umsgpack.umsgpack as msgpack
import string import string
import zlib import zlib
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
import shared
from debug import logger from debug import logger
import messagetypes import messagetypes
from tr import _translate from tr import _translate
@ -18,6 +20,7 @@ BITMESSAGE_ENCODING_TRIVIAL = 1
BITMESSAGE_ENCODING_SIMPLE = 2 BITMESSAGE_ENCODING_SIMPLE = 2
BITMESSAGE_ENCODING_EXTENDED = 3 BITMESSAGE_ENCODING_EXTENDED = 3
class DecompressionSizeException(Exception): class DecompressionSizeException(Exception):
def __init__(self, size): def __init__(self, size):
self.size = size self.size = size