gtk2/testsuite/introspection/api.py
Chun-wei Fan 65a7df47f2 Introspection test: Reverse os.add_dll_directory() order
It looks like os.add_dll_directory() works in a LIFO order, so we call
os.add_dll_directory() from the end of the list of directories in %PATH%
so that the directories are searched in the correct order.
2022-04-26 11:52:31 +08:00

24 lines
749 B
Python
Executable File

#! /usr/bin/env python3
import os
import sys
# Python 3.8.x or later on Windows require os.add_dll_directory()
# to be called on every directory that contains the required
# non-bundled, non-system DLLs of a module so that the module can
# be loaded successfully by Python. Make things easiler for people
# by calling os.add_dll_directory() on the valid paths in %PATH%.
if hasattr(os, 'add_dll_directory'):
paths = reversed(os.environ['PATH'].split(os.pathsep))
for path in paths:
if path != '' and os.path.isdir(path):
os.add_dll_directory(path)
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk
assert isinstance(Gtk.INVALID_LIST_POSITION, int), 'Gtk.INVALID_LIST_POSITION is not an int'