diff --git a/DEVELOPERS b/DEVELOPERS index e2d7fc3b04..a8b53f41da 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1925,6 +1925,11 @@ F: package/tslib/ F: package/x11r7/xdriver_xf86-input-tslib/ F: package/x11vnc/ +N: Martin PoviĊĦer +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 F: board/arm/foundation-v8/ F: configs/arm_foundationv8_defconfig diff --git a/package/Config.in b/package/Config.in index d593277e80..96c54ca672 100644 --- a/package/Config.in +++ b/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" diff --git a/package/python-construct/Config.in b/package/python-construct/Config.in new file mode 100644 index 0000000000..f70c8dc631 --- /dev/null +++ b/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/ diff --git a/package/python-construct/python-construct.hash b/package/python-construct/python-construct.hash new file mode 100644 index 0000000000..f406d6739b --- /dev/null +++ b/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 diff --git a/package/python-construct/python-construct.mk b/package/python-construct/python-construct.mk new file mode 100644 index 0000000000..3b0bb56106 --- /dev/null +++ b/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)) diff --git a/support/testing/tests/package/sample_python_construct.py b/support/testing/tests/package/sample_python_construct.py new file mode 100644 index 0000000000..551b559761 --- /dev/null +++ b/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]) diff --git a/support/testing/tests/package/test_python_construct.py b/support/testing/tests/package/test_python_construct.py new file mode 100644 index 0000000000..3c51dc31bb --- /dev/null +++ b/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