Repository navigation
Expand file tree
/
Copy pathcefpython3.__init__.py
More file actions
62 lines (52 loc) · 2.22 KB
/
Copy pathcefpython3.__init__.py
File metadata and controls
62 lines (52 loc) · 2.22 KB
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
# Copyright (c) 2017 The CEF Python authors. All rights reserved.
# Licensed under BSD 3-clause license.
# NOTE: Template variables like {{VERSION}} are replaced with actual
# values when make.py tool generates this package installer.
import os
import sys
import ctypes
import platform
__all__ = ["cefpython", "wx"]
__version__ = "{{VERSION}}"
__author__ = "The CEF Python authors"
# If package was installed using PIP or setup.py then package
# dir is here:
# /usr/local/lib/python2.7/dist-packages/cefpython3/
# If this is a debian package then package_dir returns:
# /usr/lib/pymodules/python2.7/cefpython3
# The above path consists of symbolic links to the real directory:
# /usr/share/pyshared/cefpython3
package_dir = os.path.dirname(os.path.abspath(__file__))
# This loads the libcef.so library for the subprocess executable.
# On Mac it works without setting library paths, but let's set it
# just to be sure.
os.environ["LD_LIBRARY_PATH"] = package_dir
os.environ["DYLD_LIBRARY_PATH"] = package_dir
# This env variable will be returned by cefpython.GetModuleDirectory().
os.environ["CEFPYTHON3_PATH"] = package_dir
# This loads the libcef library for the main python executable.
# This is required only on linux and Mac.
# The libffmpegsumo.so library does not need to be loaded here,
# it may cause issues to load it here in the browser process.
libcef = None
if platform.system() == "Darwin":
libcef = os.path.join(package_dir, "libcef.dylib")
elif platform.system() == "Linux":
libcef = os.path.join(package_dir, "libcef.so")
if libcef:
ctypes.CDLL(libcef, ctypes.RTLD_GLOBAL)
# Load the cefpython module for proper Python version
if (2, 7) <= sys.version_info < (2, 8):
# noinspection PyUnresolvedReferences
from . import cefpython_py27 as cefpython
elif (3, 4) <= sys.version_info < (3, 5):
# noinspection PyUnresolvedReferences
from . import cefpython_py34 as cefpython
elif (3, 5) <= sys.version_info < (3, 6):
# noinspection PyUnresolvedReferences
from . import cefpython_py35 as cefpython
elif (3, 6) <= sys.version_info < (3, 7):
# noinspection PyUnresolvedReferences
from . import cefpython_py36 as cefpython
else:
raise Exception("Python version not supported: " + sys.version)