diff mbox series

[3/4] package/python-ruamel-yaml-clib: new package

Message ID 20240207170959.2672846-3-buildroot@bubu1.eu
State Accepted
Headers show
Series [1/4] package/python-ruamel-yaml: fix comment in hash file | expand

Commit Message

Marcus Hoffmann Feb. 7, 2024, 5:09 p.m. UTC
Add optional c extension for python-ruamel-yaml which can speed up yaml
loading/parsing.

Extend the ruamel-yaml runtime test to check if the c extension works
correctly.

Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
---
 package/Config.in                                |  1 +
 package/python-ruamel-yaml-clib/Config.in        |  9 +++++++++
 .../python-ruamel-yaml-clib.hash                 |  5 +++++
 .../python-ruamel-yaml-clib.mk                   | 16 ++++++++++++++++
 .../tests/package/sample_python_ruamel_yaml.py   | 12 ++++++++++++
 .../tests/package/test_python_ruamel_yaml.py     |  1 +
 6 files changed, 44 insertions(+)
 create mode 100644 package/python-ruamel-yaml-clib/Config.in
 create mode 100644 package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.hash
 create mode 100644 package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.mk

Comments

Thomas Petazzoni July 12, 2024, 1:23 p.m. UTC | #1
Hello Marcus,

On Wed,  7 Feb 2024 18:09:55 +0100
Marcus Hoffmann via buildroot <buildroot@buildroot.org> wrote:

> diff --git a/package/python-ruamel-yaml-clib/Config.in b/package/python-ruamel-yaml-clib/Config.in
> new file mode 100644
> index 0000000000..a06080873f
> --- /dev/null
> +++ b/package/python-ruamel-yaml-clib/Config.in
> @@ -0,0 +1,9 @@
> +if BR2_PACKAGE_PYTHON_RUAMEL_YAML
> +config BR2_PACKAGE_PYTHON_RUAMEL_YAML_CLIB
> +	bool "python-ruamel-yaml-clib"

Changed the if BR2_PACKAGE_PYTHON_RUAMEL_YAML to a depends on
BR2_PACKAGE_PYTHON_RUAMEL_YAML, which is more common for this type of
situation IMO.

> diff --git a/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.mk b/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.mk
> new file mode 100644
> index 0000000000..3e5434fa9a
> --- /dev/null
> +++ b/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.mk
> @@ -0,0 +1,16 @@
> +################################################################################
> +#
> +# python-ruamel-yaml

Bad copy/paste, should have been python-ruamel-yaml-clib.

> +#
> +################################################################################
> +
> +PYTHON_RUAMEL_YAML_CLIB_VERSION = 0.2.8
> +PYTHON_RUAMEL_YAML_CLIB_SOURCE = ruamel.yaml.clib-$(PYTHON_RUAMEL_YAML_CLIB_VERSION).tar.gz
> +PYTHON_RUAMEL_YAML_CLIB_SITE = https://files.pythonhosted.org/packages/46/ab/bab9eb1566cd16f060b54055dd39cf6a34bfa0240c53a7218c43e974295b
> +PYTHON_RUAMEL_YAML_CLIB_SETUP_TYPE = setuptools
> +PYTHON_RUAMEL_YAML_CLIB_LICENSE = MIT
> +PYTHON_RUAMEL_YAML_CLIB_LICENSE_FILES = LICENSE
> +PYTHON_RUAMEL_YAML_CLIB_CPE_ID_VENDOR = ruamel.yaml_project
> +PYTHON_RUAMEL_YAML_CLIB_CPE_ID_PRODUCT = ruamel.yaml

I dropped those two lines. Indeed, the CPE vendor/product (at least
product) cannot be the same as for python-ruamel-yaml, as they have
different versioning.

Also, the entry in the DEVELOPERS file was missing, so I added it.

Applied with those fixes. Thanks!

Thomas
diff mbox series

Patch

diff --git a/package/Config.in b/package/Config.in
index bf8c325e99..e256202276 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1320,6 +1320,7 @@  menu "External python modules"
 	source "package/python-rtoml/Config.in"
 	source "package/python-rtslib-fb/Config.in"
 	source "package/python-ruamel-yaml/Config.in"
+	source "package/python-ruamel-yaml-clib/Config.in"
 	source "package/python-s3transfer/Config.in"
 	source "package/python-scandir/Config.in"
 	source "package/python-scapy/Config.in"
diff --git a/package/python-ruamel-yaml-clib/Config.in b/package/python-ruamel-yaml-clib/Config.in
new file mode 100644
index 0000000000..a06080873f
--- /dev/null
+++ b/package/python-ruamel-yaml-clib/Config.in
@@ -0,0 +1,9 @@ 
+if BR2_PACKAGE_PYTHON_RUAMEL_YAML
+config BR2_PACKAGE_PYTHON_RUAMEL_YAML_CLIB
+	bool "python-ruamel-yaml-clib"
+	help
+	  C version of reader, parser and emitter for ruamel.yaml
+	  derived from libyaml
+
+	  https://sourceforge.net/projects/ruamel-yaml/
+endif
diff --git a/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.hash b/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.hash
new file mode 100644
index 0000000000..937afc3df1
--- /dev/null
+++ b/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.hash
@@ -0,0 +1,5 @@ 
+# md5, sha256 from https://pypi.org/pypi/ruamel.yaml.clib/json
+md5  b72e549363fa1b9c4f9123e98f2b46cc  ruamel.yaml.clib-0.2.8.tar.gz
+sha256  beb2e0404003de9a4cab9753a8805a8fe9320ee6673136ed7f04255fe60bb512  ruamel.yaml.clib-0.2.8.tar.gz
+# Locally computed sha256 checksums
+sha256  5458f90e82366f660f956b3c929ba5f7a0efdb99a99a847e2f51f2020ffbe887  LICENSE
diff --git a/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.mk b/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.mk
new file mode 100644
index 0000000000..3e5434fa9a
--- /dev/null
+++ b/package/python-ruamel-yaml-clib/python-ruamel-yaml-clib.mk
@@ -0,0 +1,16 @@ 
+################################################################################
+#
+# python-ruamel-yaml
+#
+################################################################################
+
+PYTHON_RUAMEL_YAML_CLIB_VERSION = 0.2.8
+PYTHON_RUAMEL_YAML_CLIB_SOURCE = ruamel.yaml.clib-$(PYTHON_RUAMEL_YAML_CLIB_VERSION).tar.gz
+PYTHON_RUAMEL_YAML_CLIB_SITE = https://files.pythonhosted.org/packages/46/ab/bab9eb1566cd16f060b54055dd39cf6a34bfa0240c53a7218c43e974295b
+PYTHON_RUAMEL_YAML_CLIB_SETUP_TYPE = setuptools
+PYTHON_RUAMEL_YAML_CLIB_LICENSE = MIT
+PYTHON_RUAMEL_YAML_CLIB_LICENSE_FILES = LICENSE
+PYTHON_RUAMEL_YAML_CLIB_CPE_ID_VENDOR = ruamel.yaml_project
+PYTHON_RUAMEL_YAML_CLIB_CPE_ID_PRODUCT = ruamel.yaml
+
+$(eval $(python-package))
diff --git a/support/testing/tests/package/sample_python_ruamel_yaml.py b/support/testing/tests/package/sample_python_ruamel_yaml.py
index 5b3a079471..55cd696278 100644
--- a/support/testing/tests/package/sample_python_ruamel_yaml.py
+++ b/support/testing/tests/package/sample_python_ruamel_yaml.py
@@ -25,3 +25,15 @@  parsed = yaml.load(yaml_text)
 
 assert parsed['OneMoreRootKey'] == 9.99
 assert parsed['ListRoot'][1]['another-int'] == 1111
+
+# Tests the C extension based loader
+# ruamel.yaml automatically falls back to the pure python version, so we need
+# to explicitly check if importing the CLoader works here.
+# Import this here, so it's clearer what part of the test is failing.
+from ruamel.yaml import CLoader  # noqa: E402
+assert CLoader is not None
+yaml = YAML(typ='safe')
+parsed_from_c = yaml.load(yaml_text)
+
+assert parsed_from_c['OneMoreRootKey'] == 9.99
+assert parsed_from_c['ListRoot'][1]['another-int'] == 1111
diff --git a/support/testing/tests/package/test_python_ruamel_yaml.py b/support/testing/tests/package/test_python_ruamel_yaml.py
index 15062b4455..b145da4b24 100644
--- a/support/testing/tests/package/test_python_ruamel_yaml.py
+++ b/support/testing/tests/package/test_python_ruamel_yaml.py
@@ -7,6 +7,7 @@  class TestPythonPy3RuamelYaml(TestPythonPackageBase):
         """
         BR2_PACKAGE_PYTHON3=y
         BR2_PACKAGE_PYTHON_RUAMEL_YAML=y
+        BR2_PACKAGE_PYTHON_RUAMEL_YAML_CLIB=y
         """
     sample_scripts = ["tests/package/sample_python_ruamel_yaml.py"]
     timeout = 40