summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2022-04-09 12:20:10 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2022-04-09 12:20:10 +0200
commit0f3ba012512acfd74e5942ff6858c22611c4a79a (patch)
treeeb78c1163d6827012999fa0a780b2991d7c0cf15
parentc78ec7b4ea49d304050598aa411f9b60317cac86 (diff)
downloadgobject-introspection-0f3ba012512acfd74e5942ff6858c22611c4a79a.tar.gz
tests: Support CPython 3.8 on Windows
Python 3.8 no longer uses PATH for searching DLLs so we have to add them manually. Note that unlike PATH add_dll_directory() has no defined order, so if there are two same DLLs in PATH we might get a random one. This only makes sure that 'setup.py test' and 'pytest' continue working. If you include pygobject manually you have to call os.add_dll_directory() yourself with the location of the DLLs you ship.
-rw-r--r--tests/__init__.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 2bcb52e7..a7b7ff22 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -6,8 +6,24 @@ import atexit
import warnings
+def set_dll_search_path():
+ # Python 3.8 no longer searches for DLLs in PATH, so we have to add
+ # everything in PATH manually. Note that unlike PATH add_dll_directory
+ # has no defined order, so if there are two cairo DLLs in PATH we
+ # might get a random one.
+ if os.name != "nt" or not hasattr(os, "add_dll_directory"):
+ return
+ for p in os.environ.get("PATH", "").split(os.pathsep):
+ try:
+ os.add_dll_directory(p)
+ except OSError:
+ pass
+
+
def init_test_environ():
+ set_dll_search_path()
+
def dbus_launch_session():
if os.name == "nt" or sys.platform == "darwin":
return (-1, "")