diff mbox series

[v1,1/2] package/python-libyang: new package

Message ID 20260107175446.2470125-2-vjardin@free.fr
State Changes Requested
Headers show
Series Add python-libyang and python-sysrepo packages | expand

Commit Message

Vincent Jardin Jan. 7, 2026, 5:54 p.m. UTC
Python CFFI bindings for the libyang YANG library. This package
provides the 'libyang' Python module used by higher-level tooling
such as python-sysrepo.

Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 DEVELOPERS                                 |  2 ++
 package/Config.in                          |  2 ++
 package/python-libyang/Config.in           | 23 ++++++++++++++++++++++
 package/python-libyang/python-libyang.hash |  5 +++++
 package/python-libyang/python-libyang.mk   | 21 ++++++++++++++++++++
 5 files changed, 53 insertions(+)
 create mode 100644 package/python-libyang/Config.in
 create mode 100644 package/python-libyang/python-libyang.hash
 create mode 100644 package/python-libyang/python-libyang.mk

Comments

Thomas Petazzoni Jan. 7, 2026, 10:40 p.m. UTC | #1
Hello Vincent,

On Wed,  7 Jan 2026 18:54:45 +0100
Vincent Jardin via buildroot <buildroot@buildroot.org> wrote:

> diff --git a/DEVELOPERS b/DEVELOPERS
> index f982e3123a..5585e8b353 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -3359,6 +3359,8 @@ F:	package/bfscripts/
>  F:	package/dpdk/
>  F:	package/libecoli/
>  F:	package/libyang-cpp/
> +F:	package/python-libyang/
> +F:	package/python-sysrepo/

There's a problem in the patch splitting here. This patch should only
add the entry for python-libyang.

>  F:	package/sysrepo-cpp/
>  
>  N:	Vincent Prince <vincent.prince.fr@gmail.com>
> diff --git a/package/Config.in b/package/Config.in
> index def3db0e50..19d32c16ea 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -1205,6 +1205,7 @@ menu "External python modules"
>  	source "package/python-libconfig/Config.in"
>  	source "package/python-libevdev/Config.in"
>  	source "package/python-libusb1/Config.in"
> +	source "package/python-libyang/Config.in"
>  	source "package/python-lmdb/Config.in"
>  	source "package/python-lockfile/Config.in"
>  	source "package/python-log-rate-limit/Config.in"
> @@ -1434,6 +1435,7 @@ menu "External python modules"
>  	source "package/python-stack-data/Config.in"
>  	source "package/python-starlette/Config.in"
>  	source "package/python-sympy/Config.in"
> +	source "package/python-sysrepo/Config.in"
>  	source "package/python-systemd/Config.in"
>  	source "package/python-tabledata/Config.in"
>  	source "package/python-tcolorpy/Config.in"

Same comment here.

> diff --git a/package/python-libyang/Config.in b/package/python-libyang/Config.in
> new file mode 100644
> index 0000000000..793bf7e3c5
> --- /dev/null
> +++ b/package/python-libyang/Config.in
> @@ -0,0 +1,23 @@
> +config BR2_PACKAGE_PYTHON_LIBYANG
> +	bool "python-libyang"
> +	depends on BR2_PACKAGE_PYTHON3

Not needed, since all python-*/Config.in are already included inside a
if BR2_PACKAGE_PYTHON3... endif condition.

> +	depends on BR2_PACKAGE_LIBYANG

This should be a "select", and then you replicate the "depends on" from
BR2_PACKAGE_LIBYANG:

        depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libyang
        depends on BR2_TOOLCHAIN_HAS_THREADS # libyang
        depends on !BR2_STATIC_LIBS # libyang

> +	# Python3 doesn't work with uClibc and kernel headers < 5.1
> +	depends on !BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_1

This is no longer the case, this issue has been fixed in Buildroot, so
this dependency can be dropped.

> +	select BR2_PACKAGE_PYTHON_CFFI

	select BR2_PACKAGE_PYTHON_CFFI # runtime

> +	help
> +	  Python CFFI bindings for the libyang YANG library.
> +
> +	  This package provides the 'libyang' Python module, used by
> +	  higher-level tooling such as python-sysrepo.
> +
> +	  https://github.com/CESNET/libyang-python
> +
> +comment "python-libyang needs python3, uClibc needs kernel headers >= 5.1"
> +	depends on !BR2_PACKAGE_PYTHON3 || \
> +		(BR2_TOOLCHAIN_USES_UCLIBC && !BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_1)
> +
> +comment "python-libyang needs libyang"
> +	depends on BR2_PACKAGE_PYTHON3
> +	depends on !BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_1
> +	depends on !BR2_PACKAGE_LIBYANG

This needs to be updated to cover those dependencies:

        depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libyang
        depends on BR2_TOOLCHAIN_HAS_THREADS # libyang
        depends on !BR2_STATIC_LIBS # libyang

No need to mention the python3 dependency.

Rest looks good to me.

Thanks!

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index f982e3123a..5585e8b353 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -3359,6 +3359,8 @@  F:	package/bfscripts/
 F:	package/dpdk/
 F:	package/libecoli/
 F:	package/libyang-cpp/
+F:	package/python-libyang/
+F:	package/python-sysrepo/
 F:	package/sysrepo-cpp/
 
 N:	Vincent Prince <vincent.prince.fr@gmail.com>
diff --git a/package/Config.in b/package/Config.in
index def3db0e50..19d32c16ea 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1205,6 +1205,7 @@  menu "External python modules"
 	source "package/python-libconfig/Config.in"
 	source "package/python-libevdev/Config.in"
 	source "package/python-libusb1/Config.in"
+	source "package/python-libyang/Config.in"
 	source "package/python-lmdb/Config.in"
 	source "package/python-lockfile/Config.in"
 	source "package/python-log-rate-limit/Config.in"
@@ -1434,6 +1435,7 @@  menu "External python modules"
 	source "package/python-stack-data/Config.in"
 	source "package/python-starlette/Config.in"
 	source "package/python-sympy/Config.in"
+	source "package/python-sysrepo/Config.in"
 	source "package/python-systemd/Config.in"
 	source "package/python-tabledata/Config.in"
 	source "package/python-tcolorpy/Config.in"
diff --git a/package/python-libyang/Config.in b/package/python-libyang/Config.in
new file mode 100644
index 0000000000..793bf7e3c5
--- /dev/null
+++ b/package/python-libyang/Config.in
@@ -0,0 +1,23 @@ 
+config BR2_PACKAGE_PYTHON_LIBYANG
+	bool "python-libyang"
+	depends on BR2_PACKAGE_PYTHON3
+	depends on BR2_PACKAGE_LIBYANG
+	# Python3 doesn't work with uClibc and kernel headers < 5.1
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_1
+	select BR2_PACKAGE_PYTHON_CFFI
+	help
+	  Python CFFI bindings for the libyang YANG library.
+
+	  This package provides the 'libyang' Python module, used by
+	  higher-level tooling such as python-sysrepo.
+
+	  https://github.com/CESNET/libyang-python
+
+comment "python-libyang needs python3, uClibc needs kernel headers >= 5.1"
+	depends on !BR2_PACKAGE_PYTHON3 || \
+		(BR2_TOOLCHAIN_USES_UCLIBC && !BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_1)
+
+comment "python-libyang needs libyang"
+	depends on BR2_PACKAGE_PYTHON3
+	depends on !BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_HEADERS_AT_LEAST_5_1
+	depends on !BR2_PACKAGE_LIBYANG
diff --git a/package/python-libyang/python-libyang.hash b/package/python-libyang/python-libyang.hash
new file mode 100644
index 0000000000..077d97cdd8
--- /dev/null
+++ b/package/python-libyang/python-libyang.hash
@@ -0,0 +1,5 @@ 
+# From https://pypi.org/pypi/libyang/3.3.0/json
+sha256  97da2c908a8a3607ac834f2acec224ea53a4b9e9770c13e5598513641decf637  libyang-3.3.0.tar.gz
+
+# Locally computed
+sha256  c8d554f918d32b1467f35829e1cfb753764dd683c6edcecc877a4d7e9f05b2a7  LICENSE
diff --git a/package/python-libyang/python-libyang.mk b/package/python-libyang/python-libyang.mk
new file mode 100644
index 0000000000..2e4d1f3b90
--- /dev/null
+++ b/package/python-libyang/python-libyang.mk
@@ -0,0 +1,21 @@ 
+################################################################################
+#
+# python-libyang
+#
+################################################################################
+
+PYTHON_LIBYANG_VERSION = 3.3.0
+PYTHON_LIBYANG_SOURCE = libyang-$(PYTHON_LIBYANG_VERSION).tar.gz
+PYTHON_LIBYANG_SITE = https://files.pythonhosted.org/packages/source/l/libyang
+
+PYTHON_LIBYANG_LICENSE = MIT
+PYTHON_LIBYANG_LICENSE_FILES = LICENSE
+
+# pyproject.toml (PEP517)
+PYTHON_LIBYANG_SETUP_TYPE = pep517
+
+PYTHON_LIBYANG_DEPENDENCIES = \
+	libyang \
+	host-python-cffi
+
+$(eval $(python-package))