Skip to content

Fix compatibility with the master branch of libyang - #173

Closed
jktjkt wants to merge 4 commits into
CESNET:masterfrom
jktjkt:fix/build-with-master
Closed

jktjkt wants to merge 4 commits into
CESNET:masterfrom
jktjkt:fix/build-with-master

Conversation

@jktjkt

@jktjkt jktjkt commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This is similar to #172, but it exposes users to the new behavior of the upstream library. The change upstream means that creating a Context without lookups of YANG schemas from disk is no longer possible. Rather than mask it, I wanted to make this obvious, so this PR adds support for enabling/disabling the file-based lookups after the context has been created.

@jktjkt
jktjkt force-pushed the fix/build-with-master branch 3 times, most recently from 76b9dfe to 97f9e1d Compare September 23, 2026 17:15
jktjkt and others added 4 commits September 23, 2026 20:00
Due to the way how the tests runners and linters are set up, when
`test_a.py` imported `test_b`, it would pass during regular test
execution and fail with pylint. That ain't good.

Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Upstream libyang now unconditionally needs certain core YANG modules,
and they are not available as builtins in the library. Load them via the
usual lookups from disk instead.

Since context creation without access to on-disk data is now broken, the
tests which excercie this path have to first change to loading "a
minimal context" with file lookup enabled, and then disable this
feature via a newly wrapped function.

Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
...to the latest that we're testing against.

Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
And I have to add this line here just to make the CI happy, even though
everything is in the first line. Oh well.

Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
@rbu9fe

rbu9fe commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@rjarry @jeremie6wind @samuel-gauthier Any progress here? We would like to have the changes of this and the following PRs.

jeremie6wind pushed a commit to jeremie6wind/libyang-python that referenced this pull request Nov 27, 2026
Since libyang commit be5a07fea89d ("context UPDATE remove binary
internal modules"), ly_ctx_new() reads its internal modules from the
search dirs. So creating a context fails when ly_yang_module_dir() is
not one of them:

  >>> libyang.Context()
  libyang.util.LibyangError: cannot create context

Always add this dir at the end of the search path. User dirs are still
searched first, and libyang ignores a dir that is given twice.

ly_yang_module_dir() was added by the same libyang commit, and the
first release with it is v5.8.6, with soversion 5.5.5. So require this
version.

Closes: CESNET#172
Closes: CESNET#173
Suggested-by: Pepa Hajek <hajekpepa@gmail.com>
Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com>
jeremie6wind pushed a commit to jeremie6wind/libyang-python that referenced this pull request Nov 27, 2026
The result of the load_module() call is not used, because the call is
expected to fail.

No functional change.

Closes: CESNET#173
Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants