From f9eb5a7327a748db15f8db3750b0b46baed0ef28 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Wed, 16 Nov 2022 02:23:47 -0300 Subject: [PATCH] bindings: improve search of linked libraries and include directories --- bindings/python/ns__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bindings/python/ns__init__.py b/bindings/python/ns__init__.py index 473f05803..e7ffccf4b 100644 --- a/bindings/python/ns__init__.py +++ b/bindings/python/ns__init__.py @@ -74,6 +74,10 @@ def _search_libraries() -> dict: library_search_paths += [os.path.dirname(library_search_paths[-1])] library_search_paths += [os.path.dirname(library_search_paths[-1])] + # Filter unique search paths and those that are not part of system directories + library_search_paths = list(filter(lambda x: x not in SYSTEM_LIBRARY_DIRECTORIES, + set(library_search_paths))) + # Search for the core library in the search paths libraries = [] for search_path in library_search_paths: @@ -82,6 +86,7 @@ def _search_libraries() -> dict: # Search system library directories (too slow for recursive search) for search_path in SYSTEM_LIBRARY_DIRECTORIES: libraries += glob.glob("%s/**/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) + libraries += glob.glob("%s/*.%s*" % (search_path, LIBRARY_EXTENSION), recursive=False) del search_path, library_search_paths @@ -343,7 +348,8 @@ def load_modules(): for linked_lib_include_dir in extract_library_include_dirs(library, prefix): if linked_lib_include_dir not in known_include_dirs: known_include_dirs.add(linked_lib_include_dir) - cppyy.add_include_path(linked_lib_include_dir) + if os.path.isdir(linked_lib_include_dir): + cppyy.add_include_path(linked_lib_include_dir) for module in modules: cppyy.include("ns3/%s-module.h" % module)