@@ -102,6 +102,8 @@ def main():
102102 create_empty_log_file (os .path .join (PKG_DIR , "debug.log" ))
103103 create_empty_log_file (os .path .join (PKG_DIR , "examples/debug.log" ))
104104
105+ copy_cpp_extension_dependencies_issue359 (PKG_DIR )
106+
105107 print ("[make_installer.py] Done. Installer package created: {setup_dir}"
106108 .format (setup_dir = SETUP_DIR ))
107109
@@ -184,7 +186,7 @@ def replace_template_vars(string, dictionary):
184186 string = string .replace ("{{" + key + "}}" , value )
185187 if string == orig_string :
186188 raise Exception ("Nothing to format" )
187- if re .search (r"\{\ {[a-zA-Z0-9_]+\}\ }" , string ):
189+ if re .search (r"{ {[a-zA-Z0-9_]+} }" , string ):
188190 raise Exception ("Not all strings were formatted" )
189191 return string
190192
@@ -334,6 +336,84 @@ def create_empty_log_file(log_file):
334336 subprocess .check_call (command , shell = True )
335337
336338
339+ def copy_cpp_extension_dependencies_issue359 (pkg_dir ):
340+ """CEF Python module is written in Cython and is a Python C++
341+ extension and depends on msvcpXX.dll. For Python 3.5 / 3.6 / 3.7
342+ msvcp140.dll is required. See Issue #359. For Python 2.7
343+ msvcp90.dll is required. Etc. These dependencies are not included
344+ with Python binaries from Python.org."""
345+ if not WINDOWS :
346+ return
347+
348+ windows_dir = os .environ ["SYSTEMROOT" ]
349+ if SYSTEM64 :
350+ system32 = os .path .join (windows_dir , "SysWOW64" )
351+ system64 = os .path .join (windows_dir , "System32" )
352+ else :
353+ system32 = os .path .join (windows_dir , "" )
354+ system64 = None
355+ if ARCH64 :
356+ system = system64
357+ else :
358+ system = system32
359+
360+ root_search_paths = []
361+
362+ # Need to check for .pyd files for all Python version, because
363+ # the builder/installer work in a way that previous cefpython
364+ # module builds for other Python versions are also included
365+ # in the package. Thus if included, msvcpxx.dll dependency is
366+ # required as well.
367+
368+ # Python 3.5 / 3.6 / 3.7
369+ if os .path .exists (os .path .join (pkg_dir , "cefpython_py35.pyd" )) \
370+ or os .path .exists (os .path .join (pkg_dir , "cefpython_py36.pyd" )) \
371+ or os .path .exists (os .path .join (pkg_dir , "cefpython_py37.pyd" )):
372+ search_paths = [
373+ # This is where Microsoft Visual C++ 2015 Update 3 installs
374+ # (14.00.24212).
375+ os .path .join (system , "msvcp140.dll" ),
376+ ]
377+ root_search_paths .append (search_paths )
378+
379+ # Python 3.4
380+ if os .path .exists (os .path .join (pkg_dir , "cefpython_py34.pyd" )):
381+ search_paths = [
382+ # 10.00.40219.325 installs here on my system.
383+ os .path .join (system , "msvcp100.dll" ),
384+ ]
385+ root_search_paths .append (search_paths )
386+
387+ # Python 2.7
388+ if os .path .exists (os .path .join (pkg_dir , "cefpython_py27.pyd" )):
389+ if ARCH32 :
390+ search_paths = [
391+ # This runtime version is shipped with Python 2.7.14
392+ r"c:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b"
393+ r"_9.0.30729.1_none_e163563597edeada\msvcp90.dll" ,
394+ ]
395+ else :
396+ search_paths = [
397+ # This runtime version is shipped with Python 2.7.14
398+ r"c:\Windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b"
399+ r"_9.0.30729.1_none_99b61f5e8371c1d4\msvcp90.dll" ,
400+ ]
401+ root_search_paths .append (search_paths )
402+
403+ assert len (root_search_paths )
404+
405+ for search_paths in root_search_paths :
406+ found = False
407+ for path in search_paths :
408+ if os .path .exists (path ):
409+ shutil .copy (path , pkg_dir )
410+ found = True
411+ if not found :
412+ raise Exception ("C++ extension dll dependency not found."
413+ " Search paths: {0}"
414+ .format (", " .join (search_paths )))
415+
416+
337417def short_src_path (path ):
338418 # Very long: \build\cef55_3.2883.1553.g80bd606_win32\
339419 find = os .path .basename (CEF_BINARIES_LIBRARIES )
0 commit comments