From f35af0a942e7f425287ba1744004e4e736c7c536 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Fri, 15 May 2020 18:19:50 -0700 Subject: [PATCH 1/2] Explicitly add DLL directories for Windows before importing Since Python 3.8, we should explicitly add DLL directories we recursively depend on. Use a helper context manager from rpyutils for adding directories from the PATH environment variable. Signed-off-by: Jacob Perron --- tf2_py/package.xml | 1 + tf2_py/tf2_py/__init__.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tf2_py/package.xml b/tf2_py/package.xml index 4e6e98ff0b..e864096299 100644 --- a/tf2_py/package.xml +++ b/tf2_py/package.xml @@ -21,6 +21,7 @@ builtin_interfaces geometry_msgs rclpy + rpyutils ament_lint_auto ament_cmake_pytest diff --git a/tf2_py/tf2_py/__init__.py b/tf2_py/tf2_py/__init__.py index b9b975159b..dea674a41f 100644 --- a/tf2_py/tf2_py/__init__.py +++ b/tf2_py/tf2_py/__init__.py @@ -33,4 +33,10 @@ # # Author: Eitan Marder-Eppstein # ********************************************************** -from tf2_py._tf2_py import * # noqa +from rpyutils import add_dll_directories_from_env + +# 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'): + from tf2_py._tf2_py import * # noqa From 6f7c56a0992b837902cad0a987011fa1251d2e39 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Mon, 18 May 2020 11:37:57 -0700 Subject: [PATCH 2/2] Apply similar change to test Signed-off-by: Jacob Perron --- tf2_py/test/test_buffer_core.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tf2_py/test/test_buffer_core.py b/tf2_py/test/test_buffer_core.py index 98d6ae06e7..45721dbb7c 100644 --- a/tf2_py/test/test_buffer_core.py +++ b/tf2_py/test/test_buffer_core.py @@ -32,9 +32,14 @@ from geometry_msgs.msg import TransformStamped import rclpy - -from test_tf2_py._tf2_py import BufferCore -from test_tf2_py._tf2_py import LookupException +from rpyutils import add_dll_directories_from_env + +# 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'): + from test_tf2_py._tf2_py import BufferCore + from test_tf2_py._tf2_py import LookupException def build_transform(target_frame, source_frame, stamp):