[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/vsajip/cefpython/master/src/cefpython3/__init__.py [Back]  [Original]

import ctypes
import importlib
import os
import platform
import sys

__all__ = ["cefpython"]
__author__ = "The CEF Python authors"

from ._version import __version__

package_dir = os.path.dirname(os.path.abspath(__file__))

# Let subprocess and the C extension find CEF DLLs / .so files next to this
# __init__.py regardless of the working directory.
os.environ["CEFPYTHON3_PATH"] = package_dir

if platform.system() == "Linux":
    # Force GDK to use X11/XWayland backend before libcef.so loads and
    # initialises GDK.  Without this, GDK picks the Wayland backend on
    # GNOME/Wayland sessions, making gdk_x11_window_get_xid() return 0.
    os.environ.setdefault("GDK_BACKEND", "x11")
    _ld = os.environ.get("LD_LIBRARY_PATH", "")
    os.environ["LD_LIBRARY_PATH"] = (
        package_dir + os.pathsep + _ld if _ld else package_dir
    )
    ctypes.CDLL(os.path.join(package_dir, "libcef.so"), ctypes.RTLD_GLOBAL)

_pyver = "{0}{1}".format(*sys.version_info[:2])
cefpython = importlib.import_module(".cefpython_py{}".format(_pyver), package=__name__)
cefpython.__version__ = __version__

Web Proxy Viewer  |  New URL  |  Original Page