From e91acf68a81d6dddf63b89469a272eacf5fe77c2 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 21 Mar 2019 12:27:59 +0100 Subject: Amend the Embedding Patch for cx_Freeze cx_Freeze has the bug that it copies the "files.dir" folder of shiboken, but does not insert the Python files. As a quick fix, instead of testing only for existence of this directory, we now check for existence of the loader.py file. It can be assumed that all other Python files will be there as well. We could go even further and test-load all files. But then it becomes questionable if we should better always embed. Change-Id: Ib9553941c6a658fb20cb85d22f78431f99d88734 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit b84b5a2f35bea95545c19ee313be5ec5db19eca6) Reviewed-by: Alexandru Croitor --- sources/shiboken2/libshiboken/embed/signature_bootstrap.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py index 6ce5ab95a..eb182d8c4 100644 --- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py +++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py @@ -109,7 +109,7 @@ def bootstrap(): import shibokenmodule as root rp = os.path.realpath(os.path.dirname(root.__file__)) # This can be the shiboken2 directory or the binary module, so search. - look_for = "files.dir" + look_for = os.path.join("files.dir", "shibokensupport", "signature", "loader.py") while len(rp) > 3 and not os.path.exists(os.path.join(rp, look_for)): rp = os.path.abspath(os.path.join(rp, "..")) @@ -118,12 +118,14 @@ def bootstrap(): use_embedding = bool(getattr(sys, embedding_var, False)) # We keep the zip file for inspection if the sys variable has been set. keep_zipfile = hasattr(sys, embedding_var) - real_dir = os.path.join(rp, look_for) + loader_path = os.path.join(rp, look_for) + files_dir = os.path.abspath(os.path.join(loader_path, "..", "..", "..")) + assert files_dir.endswith("files.dir") # We report in sys what we used. We could put more here as well. - if not os.path.exists(real_dir): + if not os.path.exists(loader_path): use_embedding = True - support_path = prepare_zipfile() if use_embedding else real_dir + support_path = prepare_zipfile() if use_embedding else files_dir setattr(sys, embedding_var, use_embedding) try: -- cgit v1.2.3