Browse Source

package/python-construct: new package

construct is a Python library for declarative serialization/
deserialization of structured binary data.

Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Martin Povišer 3 years ago
parent
commit
c05caa7557

+ 5 - 0
DEVELOPERS

@@ -1925,6 +1925,11 @@ F:	package/tslib/
 F:	package/x11r7/xdriver_xf86-input-tslib/
 F:	package/x11vnc/
 
+N:	Martin Povišer <povik+lin@cutebit.org>
+F:	package/python-construct/
+F:	support/testing/tests/package/sample_python_construct.py
+F:	support/testing/tests/package/test_python_construct.py
+
 N:	Masahiro Yamada <yamada.masahiro@socionext.com>
 F:	board/arm/foundation-v8/
 F:	configs/arm_foundationv8_defconfig

+ 1 - 0
package/Config.in

@@ -991,6 +991,7 @@ menu "External python modules"
 	source "package/python-colorzero/Config.in"
 	source "package/python-configshell-fb/Config.in"
 	source "package/python-constantly/Config.in"
+	source "package/python-construct/Config.in"
 	source "package/python-couchdb/Config.in"
 	source "package/python-crayons/Config.in"
 	source "package/python-crc16/Config.in"

+ 7 - 0
package/python-construct/Config.in

@@ -0,0 +1,7 @@
+config BR2_PACKAGE_PYTHON_CONSTRUCT
+	bool "python-construct"
+	help
+	  A powerful declarative symmetric parser/builder for binary
+	  data.
+
+	  https://construct.readthedocs.io/

+ 5 - 0
package/python-construct/python-construct.hash

@@ -0,0 +1,5 @@
+# md5, sha256 from https://pypi.org/project/construct
+md5  e426d3dd1566066e4ef1a03fe474dec0  construct-2.10.68.tar.gz
+sha256  7b2a3fd8e5f597a5aa1d614c3bd516fa065db01704c72a1efaaeec6ef23d8b45  construct-2.10.68.tar.gz
+# Locally computed sha256 checksums
+sha256  1552d70acfd0d3fe464ce13d30113ddc6fe4bac21e52212acc98509e3cc1a8f4  LICENSE

+ 14 - 0
package/python-construct/python-construct.mk

@@ -0,0 +1,14 @@
+################################################################################
+#
+# python-construct
+#
+################################################################################
+
+PYTHON_CONSTRUCT_VERSION = 2.10.68
+PYTHON_CONSTRUCT_SOURCE = construct-$(PYTHON_CONSTRUCT_VERSION).tar.gz
+PYTHON_CONSTRUCT_SITE = https://files.pythonhosted.org/packages/e0/b7/a4a032e94bcfdff481f2e6fecd472794d9da09f474a2185ed33b2c7cad64
+PYTHON_CONSTRUCT_SETUP_TYPE = setuptools
+PYTHON_CONSTRUCT_LICENSE = MIT
+PYTHON_CONSTRUCT_LICENSE_FILES = LICENSE
+
+$(eval $(python-package))

+ 16 - 0
support/testing/tests/package/sample_python_construct.py

@@ -0,0 +1,16 @@
+# Inspired from https://construct.readthedocs.io/en/latest/intro.html#example
+import construct
+
+format = construct.Struct(
+    "signature" / construct.Const(b"BMP"),
+    "width" / construct.Int8ub,
+    "height" / construct.Int8ub,
+    "pixels" / construct.Array(construct.this.width * construct.this.height, construct.Byte),
+)
+a = format.build(dict(width=3,height=2,pixels=[7,8,9,11,12,13]))
+assert(a == b'BMP\x03\x02\x07\x08\t\x0b\x0c\r')
+b = format.parse(b'BMP\x03\x02\x07\x08\t\x0b\x0c\r')
+assert(b.signature == b'BMP')
+assert(b.width == 3)
+assert(b.height == 2)
+assert(b.pixels == [7, 8, 9, 11, 12, 13])

+ 12 - 0
support/testing/tests/package/test_python_construct.py

@@ -0,0 +1,12 @@
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3Construct(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_PACKAGE_PYTHON_CONSTRUCT=y
+        """
+    sample_scripts = ["tests/package/sample_python_construct.py"]
+    timeout = 10