1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa: F401
print("Gtk import works")
from gi.repository import GObject # noqa: F401
print("GObject import works")
try:
gi.require_version("GtkSource", "4")
print("Using GtkSourceView 4")
except ValueError:
gi.require_version("GtkSource", "3.0")
print("Using GtkSourceView 3.0")
from gi.repository import GtkSource # noqa: F401
print("GtkSource import works")
# Copied from ctypes module.
def find_library(name):
import os
print("PATH:", os.environ["PATH"])
for directory in os.environ["PATH"].split(os.pathsep):
fname = os.path.join(directory, name)
print("Check directory", directory)
print("Check filename", fname, os.path.isfile(fname))
if os.path.isfile(fname):
return fname
if fname.lower().endswith(".dll"):
continue
fname = f"{fname}.dll"
print("Check filename", fname, os.path.isfile(fname))
if os.path.isfile(fname):
return fname
return None
find_library("libenchant")
import enchant
print("Languages:", enchant.list_languages())
print("Dictionaries:", enchant.list_dicts())
print("Enchant import works")
# Only require enchant dictionaries to work in PyInstaller bundle.
# In regular test runs, the system enchant might not be configured correctly.
import sys
if getattr(sys, "frozen", False):
# Running in PyInstaller bundle.
assert enchant.list_languages() and enchant.list_dicts()
print("Enchant finds languages and dictionaries")
else:
# Running in regular Python, enchant may not have dictionaries configured.
languages = enchant.list_languages()
dictionaries = enchant.list_dicts()
if languages and dictionaries:
print("Enchant finds languages and dictionaries")
else:
print("Enchant import works but no dictionaries configured (this is OK for regular tests)")
|