From 9661b3fa00d6d1e1551da9df537b58003f3595e9 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Tue, 12 Mar 2024 22:01:50 +0000 Subject: [PATCH] Fix pytest finding librecode DLL on Python >= 3.8 --- tests/Makefile.am | 6 +++--- tests/pytest | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 604f1df..3aac4a3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,9 +33,9 @@ DISTCLEANFILES = Recode.c if HAVE_CYTHON # TESTS_ENVIRONMENT_EXTRA can be set at configure time check-local: Recode@pyextext@ - export LD_LIBRARY_PATH=$(top_builddir)/src/@objdir@; \ - export DYLD_LIBRARY_PATH=$(top_builddir)/src/@objdir@; \ - if test "$(PYTHON_PLATFORM)" = win32; then export PATH="$(top_builddir)/src/@objdir@;$$PATH"; fi; \ + export SHARED_LIB_DIR=$(abs_top_builddir)/src/@objdir@; \ + export LD_LIBRARY_PATH=$$SHARED_LIB_DIR; \ + export DYLD_LIBRARY_PATH=$$SHARED_LIB_DIR; \ export LSAN_OPTIONS=$$LSAN_OPTIONS:fast_unwind_on_malloc=0:print_suppressions=0:suppressions=$(srcdir)/asan-suppressions.txt; \ RECODE=$(top_builddir)/src/recode$(EXEEXT) PYTHONPATH=.:$(srcdir) \ $(TESTS_ENVIRONMENT_EXTRA) $(PYTHON) $(srcdir)/pytest $(LIMIT) $(srcdir)/t*.py diff --git a/tests/pytest b/tests/pytest index f72fa56..15ddc7e 100755 --- a/tests/pytest +++ b/tests/pytest @@ -43,6 +43,9 @@ __metaclass__ = type import inspect, os, sys, time, traceback from io import StringIO +if os.name == 'nt': + os.add_dll_directory(os.environ['SHARED_LIB_DIR']) + # How many displayable characters in an output line. WIDTH = 79