Skip to content

Commit 48d3b51

Browse files
committed
context: add the path to internal libyang modules
The ly_ctx_new requires the internal libyang modules to create a context. Add the ly_yang_module_dir function to the cffi. In context.py, pass the result of this function to the ly_ctx_new calls. Signed-off-by: Jeremie Leska <jeremie.leska@6wind.com>
1 parent 49a1e9a commit 48d3b51

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎cffi/cdefs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ typedef enum {
4040
LY_ERR ly_ctx_new(const char *, uint16_t, struct ly_ctx **);
4141
void ly_ctx_destroy(struct ly_ctx *);
4242
int ly_ctx_set_searchdir(struct ly_ctx *, const char *);
43+
const char *ly_yang_module_dir(void);
4344

4445
typedef enum
4546
{

‎libyang/context.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ def __init__(
251251
search_paths.extend(search_path.strip(": \t\r\n'\"").split(":"))
252252

253253
search_paths = [path for path in search_paths if os.path.isdir(path)]
254+
255+
module_dir = c2str(lib.ly_yang_module_dir())
256+
if module_dir:
257+
search_paths.insert(0, module_dir)
258+
254259
search_path = ":".join(search_paths) if search_paths else None
255260

256261
if yanglib_path is None:

0 commit comments

Comments
 (0)