MCPcopy Create free account
hub / github.com/cztomczak/cefpython / get_cefpython3_datas

Function get_cefpython3_datas

examples/pyinstaller/hook-cefpython3.py:101–183  ·  view source on GitHub ↗

Returning almost all of cefpython binaries as DATAS (see exception below), because pyinstaller does strange things and fails if these are returned as BINARIES. It first updates manifest in .dll files: >> Updating manifest in chrome_elf.dll And then because of that it fails to load t

()

Source from the content-addressed store, hash-verified

99
100
101def get_cefpython3_datas():
102 """Returning almost all of cefpython binaries as DATAS (see exception
103 below), because pyinstaller does strange things and fails if these are
104 returned as BINARIES. It first updates manifest in .dll files:
105 >> Updating manifest in chrome_elf.dll
106
107 And then because of that it fails to load the library:
108 >> hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
109 >> pywintypes.error: (5, 'LoadLibraryEx', 'Access is denied.')
110
111 It is not required for pyinstaller to modify in any way
112 CEF binaries or to look for its dependencies. CEF binaries
113 does not have any external dependencies like MSVCR or similar.
114
115 The .pak .dat and .bin files cannot be marked as BINARIES
116 as pyinstaller would fail to find binary depdendencies on
117 these files.
118
119 One exception is subprocess (subprocess.exe on Windows) executable
120 file, which is passed to pyinstaller as BINARIES in order to collect
121 its dependecies.
122
123 DATAS are in format: tuple(full_path, dest_subdir).
124 """
125 ret = list()
126
127 if is_win:
128 cefdatadir = "."
129 elif is_darwin or is_linux:
130 cefdatadir = "."
131 else:
132 assert False, "Unsupported system {}".format(platform.system())
133
134 # Binaries, licenses and readmes in the cefpython3/ directory
135 for filename in os.listdir(CEFPYTHON3_DIR):
136 # Ignore Cython modules which are already handled by
137 # pyinstaller automatically.
138 if filename[:-len(CYTHON_MODULE_EXT)] in get_cefpython_modules():
139 continue
140
141 # CEF binaries and datas
142 extension = os.path.splitext(filename)[1]
143 if extension in \
144 [".exe", ".dll", ".pak", ".dat", ".bin", ".txt", ".so", ".plist"] \
145 or filename.lower().startswith("license"):
146 logger.info("Include cefpython3 data: {}".format(filename))
147 ret.append((os.path.join(CEFPYTHON3_DIR, filename), cefdatadir))
148
149 if is_darwin:
150 # "Chromium Embedded Framework.framework/Resources" with subdirectories
151 # is required. Contain .pak files and locales (each locale in separate
152 # subdirectory).
153 resources_subdir = \
154 os.path.join("Chromium Embedded Framework.framework", "Resources")
155 base_path = os.path.join(CEFPYTHON3_DIR, resources_subdir)
156 assert os.path.exists(base_path), \
157 "{} dir not found in cefpython3".format(resources_subdir)
158 for path, dirs, files in os.walk(base_path):

Callers 1

hook-cefpython3.pyFile · 0.85

Calls 1

get_cefpython_modulesFunction · 0.85

Tested by

no test coverage detected