Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013-2016 vsergeev / Ivan (Vanya) A. Sergeev
Copyright (c) 2013-2023 vsergeev / Ivan (Vanya) A. Sergeev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 5 additions & 4 deletions PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
Metadata-Version: 1.1
Metadata-Version: 2.1
Name: u-msgpack-python
Version: 2.3.0
Version: 2.8.0
Summary: A portable, lightweight MessagePack serializer and deserializer written in pure Python.
Home-page: https://github.com/vsergeev/u-msgpack-python
Author: vsergeev
Author-email: [email protected]
License: MIT
Description: u-msgpack-python is a lightweight `MessagePack <http://msgpack.org/>`_ serializer and deserializer module written in pure Python, compatible with both Python 2 and Python 3, as well as CPython and PyPy implementations of Python. u-msgpack-python is fully compliant with the latest `MessagePack specification <https://github.com/msgpack/msgpack/blob/master/spec.md>`_. In particular, it supports the new binary, UTF-8 string, and application-defined ext types. See https://github.com/vsergeev/u-msgpack-python for more information.
Keywords: msgpack serialization deserialization
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Expand All @@ -17,3 +15,6 @@ Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
License-File: LICENSE

u-msgpack-python is a lightweight `MessagePack <http://msgpack.org/>`_ serializer and deserializer module written in pure Python, compatible with both Python 2 and Python 3, as well as CPython and PyPy implementations of Python. u-msgpack-python is fully compliant with the latest `MessagePack specification <https://github.com/msgpack/msgpack/blob/master/spec.md>`_. In particular, it supports the new binary, UTF-8 string, and application-defined ext types. See https://github.com/vsergeev/u-msgpack-python for more information.
168 changes: 168 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# u-msgpack-python [![Tests Status](https://github.com/vsergeev/u-msgpack-python/actions/workflows/tests.yml/badge.svg)](https://github.com/vsergeev/u-msgpack-python/actions/workflows/tests.yml) [![Docs Status](https://readthedocs.org/projects/u-msgpack-python/badge/)](https://u-msgpack-python.readthedocs.io/en/latest/) [![GitHub release](https://img.shields.io/github/release/vsergeev/u-msgpack-python.svg?maxAge=7200)](https://github.com/vsergeev/u-msgpack-python) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/vsergeev/u-msgpack-python/blob/master/LICENSE)

u-msgpack-python is a lightweight [MessagePack](http://msgpack.org/) serializer and deserializer module written in pure Python, compatible with Python 2 and 3, as well CPython and PyPy implementations of Python. u-msgpack-python is fully compliant with the latest [MessagePack specification](https://github.com/msgpack/msgpack/blob/master/spec.md). In particular, it supports the new binary, UTF-8 string, application-defined ext, and timestamp types.

u-msgpack-python is currently distributed as a package on [PyPI](https://pypi.python.org/pypi/u-msgpack-python) and as a single file module.

## Installation

With pip:
``` text
$ pip install u-msgpack-python
```

With easy_install:
``` text
$ easy_install u-msgpack-python
```

or simply drop `umsgpack.py` into your project!
``` text
$ wget https://raw.github.com/vsergeev/u-msgpack-python/master/umsgpack/__init__.py -O umsgpack.py
```

## Examples

Basic Example:
``` python
>>> import umsgpack
>>> umsgpack.packb({u"compact": True, u"schema": 0})
b'\x82\xa7compact\xc3\xa6schema\x00'
>>> umsgpack.unpackb(_)
{u'compact': True, u'schema': 0}
>>>
```

A more complicated example:
``` python
>>> umsgpack.packb([1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02", \
... u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345])
b'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01\
\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb\
@\x00\xfc\xd3Z\x85\x87\x94'
>>> umsgpack.unpackb(_)
[1, True, False, 4294967295, {u'foo': b'\x80\x01\x02', \
u'bar': [1, 2, 3, {u'a': [1, 2, 3, {}]}]}, -1, 2.12345]
>>>
```

Streaming serialization with file-like objects:
``` python
>>> f = open('test.bin', 'wb')
>>> umsgpack.pack({u"compact": True, u"schema": 0}, f)
>>> umsgpack.pack([1,2,3], f)
>>> f.close()
>>>
>>> f = open('test.bin', 'rb')
>>> umsgpack.unpack(f)
{u'compact': True, u'schema': 0}
>>> umsgpack.unpack(f)
[1, 2, 3]
>>> f.close()
>>>
```

Serializing and deserializing a raw Ext type:
``` python
>>> # Create an Ext object with type 5 and data b"\x01\x02\x03"
... foo = umsgpack.Ext(5, b"\x01\x02\x03")
>>> umsgpack.packb({u"stuff": foo, u"awesome": True})
b'\x82\xa5stuff\xc7\x03\x05\x01\x02\x03\xa7awesome\xc3'
>>>
>>> bar = umsgpack.unpackb(_)
>>> print(bar['stuff'])
Ext Object (Type: 5, Data: 0x01 0x02 0x03)
>>> bar['stuff'].type
5
>>> bar['stuff'].data
b'\x01\x02\x03'
>>>
```

Serializing and deserializing application-defined types with `ext_serializable()`:
``` python
>>> @umsgpack.ext_serializable(0x50)
... class Point(collections.namedtuple('Point', ['x', 'y'])):
... def packb(self):
... return struct.pack(">ii", self.x, self.y)
... @staticmethod
... def unpackb(data):
... return Point(*struct.unpack(">ii", data))
...
>>> umsgpack.packb(Point(1, 2))
b'\xd7P\x00\x00\x00\x01\x00\x00\x00\x02'
>>> umsgpack.unpackb(_)
Point(x=1, y=2)
>>>
```

Serializing and deserializing application-defined types with Ext handlers:
``` python
>>> umsgpack.packb([complex(1,2), decimal.Decimal("0.31")],
... ext_handlers = {
... complex: lambda obj: umsgpack.Ext(0x30, struct.pack("ff", obj.real, obj.imag)),
... decimal.Decimal: lambda obj: umsgpack.Ext(0x40, str(obj).encode()),
... })
b'\x92\xd70\x00\x00\x80?\x00\x00\x00@\[email protected]'
>>> umsgpack.unpackb(_,
... ext_handlers = {
... 0x30: lambda ext: complex(*struct.unpack("ff", ext.data)),
... 0x40: lambda ext: decimal.Decimal(ext.data.decode()),
... })
[(1+2j), Decimal('0.31')]
>>>
```

Python standard library style names `dump`, `dumps`, `load`, `loads` are also available:
``` python
>>> umsgpack.dumps({u"compact": True, u"schema": 0})
b'\x82\xa7compact\xc3\xa6schema\x00'
>>> umsgpack.loads(_)
{u'compact': True, u'schema': 0}
>>>
>>> f = open('test.bin', 'wb')
>>> umsgpack.dump({u"compact": True, u"schema": 0}, f)
>>> f.close()
>>>
>>> f = open('test.bin', 'rb')
>>> umsgpack.load(f)
{u'compact': True, u'schema': 0}
>>>
```

## Documentation

Documentation is hosted at [https://u-msgpack-python.readthedocs.io](https://u-msgpack-python.readthedocs.io).

To build documentation locally with Sphinx, run:

```
cd docs
make html
```

Sphinx will produce the HTML documentation in `docs/_build/html/`.

Run `make help` to see other output targets (LaTeX, man, text, etc.).

## Testing

The included unit tests may be run with `test_umsgpack.py`, under your favorite interpreter.

``` text
$ python2 test_umsgpack.py
$ python3 test_umsgpack.py
$ pypy test_umsgpack.py
$ pypy3 test_umsgpack.py
```

Alternatively, you can use `tox` or `detox` to test multiple Python versions at once.

``` text
$ pip install tox
$ tox
```

## License

u-msgpack-python is MIT licensed. See the included `LICENSE` file for more details.
34 changes: 34 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
u-msgpack-python (2.8.0-2) unstable; urgency=medium

* Team upload.
* Add dependency on python3-setuptools (Closes: #1080823)

-- Alexandre Detiste <[email protected]> Sun, 20 Oct 2024 23:48:26 +0200

u-msgpack-python (2.8.0-1) unstable; urgency=medium

* Team Upload
* New upstream version 2.8.0
* Use new dh-sequence-python3
* Set Rules-Requires-Root: no

-- Alexandre Detiste <[email protected]> Tue, 20 Aug 2024 13:14:34 +0200

u-msgpack-python (2.3.0-3) unstable; urgency=medium

[ Debian Janitor ]
* Bump debhelper from deprecated 9 to 12.
* Set upstream metadata fields: Bug-Database, Bug-Submit, Repository,
Repository-Browse.

[ Ondřej Nový ]
* d/control: Update Maintainer field with new Debian Python Team
contact address.
* d/control: Update Vcs-* fields with new Debian Python Team Salsa
layout.

[ Debian Janitor ]
* Bump debhelper from old 12 to 13.

-- Sandro Tosi <[email protected]> Sat, 04 Jun 2022 21:52:58 -0400

u-msgpack-python (2.3.0-2) unstable; urgency=medium

[ Ondřej Nový ]
Expand Down
14 changes: 7 additions & 7 deletions debian/control
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
Source: u-msgpack-python
Section: python
Priority: optional
Maintainer: Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>
Maintainer: Debian Python Team <team+python@tracker.debian.org>
Uploaders:
Orestis Ioannou <[email protected]>,
Build-Depends:
debhelper-compat (= 9),
dh-python,
debhelper-compat (= 13),
dh-sequence-python3,
python3-all,
python3-setuptools,
Rules-Requires-Root: no
Standards-Version: 3.9.8
Homepage: https://github.com/vsergeev/u-msgpack-python
Vcs-Git: https://salsa.debian.org/python-team/modules/u-msgpack-python.git
Vcs-Browser: https://salsa.debian.org/python-team/modules/u-msgpack-python
Vcs-Git: https://salsa.debian.org/python-team/packages/u-msgpack-python.git
Vcs-Browser: https://salsa.debian.org/python-team/packages/u-msgpack-python

Package: python3-u-msgpack
Architecture: all
Expand All @@ -24,5 +26,3 @@ Description: Python3 MessagePack serializer and deserializer
PyPy implementations of Python. u-msgpack-python is fully compliant with the
latest MessagePack specification. In particular, it supports the new binary,
UTF-8 string, and application-defined ext types.
.
This is the Python 3 package.
4 changes: 2 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/make -f
export PYBUILD_NAME=u-msgpack
export PYBUILD_NAME=umsgpack

%:
dh $@ --with python3 --buildsystem=pybuild
dh $@ --buildsystem=pybuild
4 changes: 4 additions & 0 deletions debian/upstream/metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Bug-Database: https://github.com/vsergeev/u-msgpack-python/issues
Bug-Submit: https://github.com/vsergeev/u-msgpack-python/issues/new
Repository: https://github.com/vsergeev/u-msgpack-python.git
Repository-Browse: https://github.com/vsergeev/u-msgpack-python
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[metadata]
description-file = README.md
description_file = README.md

[bdist_wheel]
universal = True

[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0

5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

setup(
name='u-msgpack-python',
version='2.3.0',
version='2.8.0',
description='A portable, lightweight MessagePack serializer and deserializer written in pure Python.',
author='vsergeev',
author_email='[email protected]',
url='https://github.com/vsergeev/u-msgpack-python',
py_modules=['umsgpack'],
packages=['umsgpack'],
package_data={'umsgpack': ['*.pyi', 'py.typed']},
long_description="""u-msgpack-python is a lightweight `MessagePack <http://msgpack.org/>`_ serializer and deserializer module written in pure Python, compatible with both Python 2 and Python 3, as well as CPython and PyPy implementations of Python. u-msgpack-python is fully compliant with the latest `MessagePack specification <https://github.com/msgpack/msgpack/blob/master/spec.md>`_. In particular, it supports the new binary, UTF-8 string, and application-defined ext types. See https://github.com/vsergeev/u-msgpack-python for more information.""",
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
Loading
Loading