Skip to content

Commit 863930c

Browse files
committed
libyang3-py3: libyang3 uses a python cffi bindings
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.
1 parent 094aefc commit 863930c

File tree

12 files changed

+125
-2
lines changed

12 files changed

+125
-2
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
/src/sonic-yang-mgmt/ @sonic-net/sonic-management
6767
/src/libyang/ @sonic-net/sonic-management
6868
/src/libyang3/ @sonic-net/sonic-management
69+
/src/libyang3-py3/ @sonic-net/sonic-management
6970

7071
# bgpcfgd
7172
/src/sonic-bgpcfgd/ @StormLiangMS

rules/libyang.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ LIBYANG_PY3 = python3-yang_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb
2929
$(LIBYANG_PY3)_DEPENDS += $(LIBYANG) $(LIBYANG_CPP)
3030
$(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_PY3)))
3131

32-
$(eval $(call add_conflict_package,$(LIBYANG),$(LIBYANG3)))
32+
#$(eval $(call add_conflict_package,$(LIBYANG),$(LIBYANG3)))
3333
$(eval $(call add_conflict_package,$(LIBYANG_DEV),$(LIBYANG3_DEV)))
3434

3535
export LIBYANG LIBYANG_DBGSYM LIBYANG_DEV LIBYANG_CPP LIBYANG_PY3

rules/libyang3-py3.dep

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
SPATH := $($(LIBYANG3_PY3)_SRC_PATH)
3+
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/libyang3-py3.mk rules/libyang3-py3.dep
4+
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST)
5+
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'))
6+
7+
$(LIBYANG3_PY3)_CACHE_MODE := GIT_CONTENT_SHA
8+
$(LIBYANG3_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)
9+
$(LIBYANG3_PY3)_DEP_FILES := $(DEP_FILES)
10+
$(LIBYANG3_PY3)_SMDEP_FILES := $(SMDEP_FILES)
11+
$(LIBYANG3_PY3)_SMDEP_PATHS := $(SPATH)

rules/libyang3-py3.mk

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# libyang3 python3 deb package
2+
3+
LIBYANG3_PY3_VERSION = 3.1.0
4+
LIBYANG3_PY3_SUBVERSION = 1
5+
LIBYANG3_PY3_FULLVERSION = $(LIBYANG3_PY3_VERSION)-$(LIBYANG3_PY3_SUBVERSION)
6+
7+
export LIBYANG3_PY3_VERSION
8+
export LIBYANG3_PY3_SUBVERSION
9+
export LIBYANG3_PY3_FULLVERSION
10+
11+
LIBYANG3_PY3 = python3-libyang_$(LIBYANG3_PY3_FULLVERSION)_$(CONFIGURED_ARCH).deb
12+
$(LIBYANG3_PY3)_SRC_PATH = $(SRC_PATH)/libyang3-py3
13+
$(LIBYANG3_PY3)_DEPENDS += $(LIBYANG3) $(LIBYANG3_DEV)
14+
$(LIBYANG3_PY3)_RDEPENDS += $(LIBYANG3)
15+
SONIC_MAKE_DEBS += $(LIBYANG3_PY3)
16+
17+
export LIBYANG3_PY3
18+

slave.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,4 +1759,4 @@ jessie : $$(addprefix $(TARGET_PATH)/,$$(JESSIE_DOCKER_IMAGES)) \
17591759

17601760
## To build some commonly used libs. Some submodules depend on these libs.
17611761
## It is used in component pipelines. For example: swss needs libnl, libyang
1762-
lib-packages: $(addprefix $(DEBS_PATH)/,$(LIBNL3) $(LIBYANG) $(PROTOBUF) $(LIB_SONIC_DASH_API))
1762+
lib-packages: $(addprefix $(DEBS_PATH)/,$(LIBNL3) $(LIBYANG) $(LIBYANG3) $(PROTOBUF) $(LIB_SONIC_DASH_API))

sonic-slave-bookworm/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install
373373
pkgconf \
374374
tcl-expect \
375375
libxxhash-dev \
376+
# For libyang3-py3
377+
python3-cffi \
376378
# For build dtb
377379
device-tree-compiler \
378380
# For sonic-mgmt-framework

sonic-slave-bullseye/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install
366366
pkgconf \
367367
tcl-expect \
368368
libxxhash-dev \
369+
# For libyang3-py3
370+
python3-cffi \
369371
# For build dtb
370372
device-tree-compiler \
371373
# For sonic-mgmt-framework

sonic-slave-buster/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install
361361
pkgconf \
362362
tcl-expect \
363363
libxxhash-dev \
364+
# For libyang3-py3
365+
python3-cffi \
364366
# For build dtb
365367
device-tree-compiler \
366368
# For sonic-mgmt-framework

sonic-slave-trixie/Dockerfile.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install
366366
pkgconf \
367367
tcl-expect \
368368
libxxhash-dev \
369+
# For libyang3-py3
370+
python3-cffi \
369371
# For build dtb
370372
device-tree-compiler \
371373
# For sonic-mgmt-framework

src/libyang3-py3/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
SHELL = /bin/bash
2+
.ONESHELL:
3+
.SHELLFLAGS += -e
4+
5+
MAIN_TARGET = $(LIBYANG3_PY3)
6+
7+
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
8+
rm -rf ./libyang-python
9+
# Obtain libyang-python
10+
git clone --depth 1 -b v3.1.0 https://github.com/CESNET/libyang-python.git libyang-python
11+
pushd ./libyang-python
12+
13+
# Apply patch series
14+
QUILT_PATCHES=../patch quilt push -a
15+
16+
# Build package
17+
ifeq ($(CROSS_BUILD_ENVIRON), y)
18+
dpkg-buildpackage -rfakeroot -d -b -us -uc -a$(CONFIGURED_ARCH) -Pcross,nocheck -j$(SONIC_CONFIG_MAKE_JOBS)
19+
else
20+
dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR)
21+
endif
22+
popd
23+
24+
mv $* $(DEST)/

0 commit comments

Comments
 (0)