Skip to content

Commit

Permalink
libyang3-py3: libyang3 uses a python cffi bindings
Browse files Browse the repository at this point in the history
libyang 1.0.73 provided python bindings via swig.  Those have
been removed and libyang3 now requires the use of the cffi bindings
which are in a separate repo.

The binding names themselves are actually different ('yang' vs 'libyang')
so both should be installable simultaneously.

This is built as a debian package rather than a wheel since it contains
binary elements.
  • Loading branch information
bradh352 committed Feb 16, 2025
1 parent 9b6cf0c commit e9a8f03
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
/src/sonic-yang-mgmt/ @sonic-net/sonic-management
/src/libyang/ @sonic-net/sonic-management
/src/libyang3/ @sonic-net/sonic-management
/src/libyang3-py3/ @sonic-net/sonic-management

# bgpcfgd
/src/sonic-bgpcfgd/ @StormLiangMS
Expand Down
6 changes: 5 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@
url = https://github.com/Marvell-switching/sonic-platform-marvell.git
[submodule "platform/vpp"]
path = platform/vpp
url = https://github.com/sonic-net/sonic-platform-vpp.git
url = https://github.com/sonic-net/sonic-platform-vpp.git
[submodule "src/libyang3-py3"]
path = src/libyang3-py3
url = https://github.com/CESNET/libyang-python.git
tag = v3.0.3
2 changes: 1 addition & 1 deletion rules/libyang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ LIBYANG_PY3 = python3-yang_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb
$(LIBYANG_PY3)_DEPENDS += $(LIBYANG) $(LIBYANG_CPP)
$(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_PY3)))

$(eval $(call add_conflict_package,$(LIBYANG),$(LIBYANG3)))
#$(eval $(call add_conflict_package,$(LIBYANG),$(LIBYANG3)))
$(eval $(call add_conflict_package,$(LIBYANG_DEV),$(LIBYANG3_DEV)))

export LIBYANG LIBYANG_DBGSYM LIBYANG_DEV LIBYANG_CPP LIBYANG_PY3
12 changes: 12 additions & 0 deletions rules/libyang3-py3.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

SPATH := $($(LIBYANG3_PY3)_SRC_PATH)
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/libyang3-py3.mk rules/libyang3-py3.dep
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && find . -type f -exec sh -c 'git ls-files --error-unmatch "$0" >/dev/null 2>&1' {} \; -printf '%P\n'))
SMDEP_FILES += $(addprefix $(SPATH).patch/,$(shell cd $(SPATH).patch && find . -type f -exec sh -c 'git ls-files --error-unmatch "$0" >/dev/null 2>&1' {} \; -printf '%P\n'))

$(LIBYANG3_PY3)_CACHE_MODE := GIT_CONTENT_SHA
$(LIBYANG3_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
$(LIBYANG3_PY3)_DEP_FILES := $(DEP_FILES)
$(LIBYANG3_PY3)_SMDEP_FILES := $(SMDEP_FILES)
$(LIBYANG3_PY3)_SMDEP_PATHS := $(SPATH)
18 changes: 18 additions & 0 deletions rules/libyang3-py3.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# libyang3 python3 deb package

LIBYANG3_PY3_VERSION = 3.0.3
LIBYANG3_PY3_SUBVERSION = 1
LIBYANG3_PY3_FULLVERSION = $(LIBYANG3_PY3_VERSION)-$(LIBYANG3_PY3_SUBVERSION)

export LIBYANG3_PY3_VERSION
export LIBYANG3_PY3_SUBVERSION
export LIBYANG3_PY3_FULLVERSION

LIBYANG3_PY3 = python3-libyang_$(LIBYANG3_PY3_FULLVERSION)_$(CONFIGURED_ARCH).deb
$(LIBYANG3_PY3)_SRC_PATH = $(SRC_PATH)/libyang3-py3
$(LIBYANG3_PY3)_DEPENDS += $(LIBYANG3) $(LIBYANG3_DEV)
$(LIBYANG3_PY3)_RDEPENDS += $(LIBYANG3)
SONIC_DPKG_DEBS += $(LIBYANG3_PY3)

export LIBYANG3_PY3

2 changes: 1 addition & 1 deletion slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1730,4 +1730,4 @@ jessie : $$(addprefix $(TARGET_PATH)/,$$(JESSIE_DOCKER_IMAGES)) \

## To build some commonly used libs. Some submodules depend on these libs.
## It is used in component pipelines. For example: swss needs libnl, libyang
lib-packages: $(addprefix $(DEBS_PATH)/,$(LIBNL3) $(LIBYANG) $(PROTOBUF) $(LIB_SONIC_DASH_API))
lib-packages: $(addprefix $(DEBS_PATH)/,$(LIBNL3) $(LIBYANG) $(LIBYANG3) $(PROTOBUF) $(LIB_SONIC_DASH_API))
2 changes: 2 additions & 0 deletions sonic-slave-bookworm/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install
swig \
pkgconf \
tcl-expect \
# For libyang3-py3
python3-cffi \
# For build dtb
device-tree-compiler \
# For sonic-mgmt-framework
Expand Down
2 changes: 2 additions & 0 deletions sonic-slave-bullseye/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install
swig \
pkgconf \
tcl-expect \
# For libyang3-py3
python3-cffi \
# For build dtb
device-tree-compiler \
# For sonic-mgmt-framework
Expand Down
2 changes: 2 additions & 0 deletions sonic-slave-buster/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install
swig \
pkgconf \
tcl-expect \
# For libyang3-py3
python3-cffi \
# For build dtb
device-tree-compiler \
# For sonic-mgmt-framework
Expand Down
1 change: 1 addition & 0 deletions src/libyang3-py3
Submodule libyang3-py3 added at 1afc2a
60 changes: 60 additions & 0 deletions src/libyang3-py3.patch/0001-debian.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff -ruN libyang-python.orig/debian/changelog libyang-python.new/debian/changelog
--- libyang-python.orig/debian/changelog 1970-01-01 00:00:00.000000000 +0000
+++ libyang-python.new/debian/changelog 2025-02-09 12:45:51.113010546 +0000
@@ -0,0 +1,5 @@
+libyang-python (3.0.3-1) unstable; urgency=low
+
+ * source package automatically created by stdeb 0.10.0
+
+ -- None <None> Sat, 08 Feb 2025 20:55:02 +0000
diff -ruN libyang-python.orig/debian/compat libyang-python.new/debian/compat
--- libyang-python.orig/debian/compat 1970-01-01 00:00:00.000000000 +0000
+++ libyang-python.new/debian/compat 2025-02-09 12:45:51.113010546 +0000
@@ -0,0 +1 @@
+13
diff -ruN libyang-python.orig/debian/control libyang-python.new/debian/control
--- libyang-python.orig/debian/control 1970-01-01 00:00:00.000000000 +0000
+++ libyang-python.new/debian/control 2025-02-09 12:45:51.113010546 +0000
@@ -0,0 +1,15 @@
+Source: libyang-python
+Maintainer: None <None>
+Section: python
+Priority: optional
+Build-Depends: dh-python, python3-setuptools, python3-all-dev, python3-cffi, debhelper (>= 13), libyang-dev ( >= 3.0.3)
+Standards-Version: 3.9.6
+Homepage: https://github.com/CESNET/libyang-python
+
+Package: python3-libyang
+Architecture: any
+Depends: ${misc:Depends}, ${python3:Depends}, ${shlibs:Depends}
+Description: CFFI bindings to libyang
+ Python CFFI bindings to libyang
+ https://github.com/CESNET/libyang/
+
diff -ruN libyang-python.orig/debian/rules libyang-python.new/debian/rules
--- libyang-python.orig/debian/rules 1970-01-01 00:00:00.000000000 +0000
+++ libyang-python.new/debian/rules 2025-02-09 12:45:51.113010546 +0000
@@ -0,0 +1,9 @@
+#!/usr/bin/make -f
+
+# This file was automatically generated by stdeb 0.10.0 at
+# Sat, 08 Feb 2025 20:55:02 +0000
+export PYBUILD_NAME=libyang
+
+%:
+ dh $@ --with python3 --buildsystem=pybuild
+
diff -ruN libyang-python.orig/debian/source/format libyang-python.new/debian/source/format
--- libyang-python.orig/debian/source/format 1970-01-01 00:00:00.000000000 +0000
+++ libyang-python.new/debian/source/format 2025-02-09 12:45:51.113010546 +0000
@@ -0,0 +1 @@
+3.0 (quilt)
diff -ruN libyang-python.orig/debian/watch libyang-python.new/debian/watch
--- libyang-python.orig/debian/watch 1970-01-01 00:00:00.000000000 +0000
+++ libyang-python.new/debian/watch 2025-02-09 12:45:51.113010546 +0000
@@ -0,0 +1,4 @@
+# please also check http://pypi.debian.net/libyang/watch
+version=3
+opts=uversionmangle=s/(rc|a|b|c)/~$1/ \
+http://pypi.debian.net/libyang/libyang-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
\ No newline at end of file
1 change: 1 addition & 0 deletions src/libyang3-py3.patch/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0001-debian.patch

0 comments on commit e9a8f03

Please sign in to comment.