diff --git a/rosidl_generator_py/package.xml b/rosidl_generator_py/package.xml index 62bdb6c7..59f9535b 100644 --- a/rosidl_generator_py/package.xml +++ b/rosidl_generator_py/package.xml @@ -26,6 +26,7 @@ rosidl_generator_c rosidl_parser rosidl_runtime_c + rpyutils ament_cmake_pytest ament_index_python diff --git a/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py b/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py index 86062700..c16b0fb2 100644 --- a/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py +++ b/rosidl_generator_py/rosidl_generator_py/import_type_support_impl.py @@ -14,6 +14,8 @@ import importlib +from rpyutils import add_dll_directories_from_env + class UnsupportedTypeSupport(Exception): """Raised when typesupport couldn't be imported.""" @@ -37,6 +39,10 @@ def import_type_support(pkg_name): """ module_name = '.{}_s__rosidl_typesupport_c'.format(pkg_name) try: - return importlib.import_module(module_name, package=pkg_name) + # Since Python 3.8, on Windows we should ensure DLL directories are explicitly added + # to the search path. + # See https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew + with add_dll_directories_from_env('PATH'): + return importlib.import_module(module_name, package=pkg_name) except ImportError: raise UnsupportedTypeSupport(pkg_name)