From 7312232695dc4f6a0436e8401990d715c16cfe10 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 31 Jul 2020 15:01:13 -0500 Subject: [PATCH] More Mac freeze/build fixes for PyQt5.12 --- freeze.py | 17 +++++++---- installer/build-mac-dmg.sh | 1 - installer/fix_qt5_rpath.py | 59 ++++++++++++++++++++++++-------------- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/freeze.py b/freeze.py index bbdc0f6e87..c865ecfcb6 100644 --- a/freeze.py +++ b/freeze.py @@ -335,15 +335,20 @@ def find_files(directory, patterns): src_files.append((os.path.join(PATH, "xdg", iconFile), iconFile)) # Add QtWebEngineProcess (if found) - qt_install_path = "/usr/local/qt5.12.x/Qt5.12.9/5.12.9/clang_64/lib/QtWebEngineCore.framework/Versions/5/" - web_process_path = os.path.join(qt_install_path, "Helpers", "QtWebEngineProcess.app", "Contents", "MacOS", "QtWebEngineProcess") + qt_install_path = "/usr/local/qt5.12.x/Qt5.12.9/5.12.9/clang_64/" + qt_webengine_path = os.path.join(qt_install_path, "lib", "QtWebEngineCore.framework", "Versions", "5") + web_process_path = os.path.join(qt_webengine_path, "Helpers", "QtWebEngineProcess.app", "Contents", "MacOS", "QtWebEngineProcess") + web_core_path = os.path.join(qt_webengine_path, "QtWebEngineCore") external_so_files.append((web_process_path, os.path.basename(web_process_path))) + external_so_files.append((web_core_path, os.path.basename(web_core_path))) # Add QtWebEngineProcess Resources & Local - for filename in find_files(os.path.join(qt_install_path, "Resources"), ["*"]): - external_so_files.append((filename, os.path.relpath(filename, start=qt_install_path))) - for filename in find_files(os.path.join(qt_install_path, "Resources", "qtwebengine_locales"), ["*"]): - external_so_files.append((filename, os.path.relpath(filename, start=qt_install_path))) + for filename in find_files(os.path.join(qt_webengine_path, "Resources"), ["*"]): + external_so_files.append((filename, os.path.relpath(filename, start=qt_webengine_path))) + for filename in find_files(os.path.join(qt_webengine_path, "Resources", "qtwebengine_locales"), ["*"]): + external_so_files.append((filename, os.path.relpath(filename, start=qt_webengine_path))) + for filename in find_files(os.path.join(qt_install_path, "plugins", "platforms"), ["*"]): + external_so_files.append((filename, os.path.relpath(filename, start=os.path.join(qt_install_path, "plugins")))) # Append all source files src_files.append((os.path.join(PATH, "installer", "qt.conf"), "qt.conf")) diff --git a/installer/build-mac-dmg.sh b/installer/build-mac-dmg.sh index 7c29cfa5a5..521c3660ca 100644 --- a/installer/build-mac-dmg.sh +++ b/installer/build-mac-dmg.sh @@ -46,7 +46,6 @@ mv "$OS_PATH/MacOS/qt.conf" "$OS_PATH/Resources/qt.conf"; ln -s "../Resources/qt mv "$OS_PATH/MacOS/openshot.py" "$OS_PATH/Resources/openshot.py"; ln -s "../Resources/openshot.py" "$OS_PATH/MacOS/openshot.py"; mv "$OS_PATH/MacOS/openshot-qt.hqx" "$OS_PATH/Resources/openshot-qt.hqx"; ln -s "../Resources/openshot-qt.hqx" "$OS_PATH/MacOS/openshot-qt.hqx"; mv "$OS_PATH/MacOS/launch.py" "$OS_PATH/Resources/launch.py"; ln -s "../Resources/launch.py" "$OS_PATH/MacOS/launch.py"; -mv "$OS_PATH/MacOS/PyQt5.uic.widget-plugins" "$OS_PATH/Resources/PyQt5.uic.widget-plugins"; ln -s "../Resources/PyQt5.uic.widget-plugins" "$OS_PATH/MacOS/PyQt5.uic.widget-plugins"; if [ -d "$OS_PATH/MacOS/python3.6" ]; then echo "Symlink python36.zip and python3.6 folder" mv "$OS_PATH/MacOS/python3.6" "$OS_PATH/Resources/python3.6"; ln -s "../../Resources/python3.6" "$OS_PATH/MacOS/lib/python3.6"; diff --git a/installer/fix_qt5_rpath.py b/installer/fix_qt5_rpath.py index 570c993221..c3169b50fe 100644 --- a/installer/fix_qt5_rpath.py +++ b/installer/fix_qt5_rpath.py @@ -21,30 +21,47 @@ # Create new symlink to Qt frameworks call(["ln", "-s", file_path, new_path]) - -# FIX PyQt5 library paths -# This is NOT required anymore (leaving here as an example) -PATH = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/" +# Symbolic Link Qt Frameworks into Python3/PyQt5 Framework +# IMPORTANT to run after installing PyQt5 +PATH = "/usr/local/qt5.12.x/Qt5.12.9/5.12.9/clang_64/lib" # Find files matching patterns -for root, dirs, files in os.walk(PATH): - for basename in files: - file_path = os.path.join(root, basename) +for file in os.listdir(PATH): + if file.endswith(".framework"): + file_path = os.path.join(PATH, file) file_parts = file_path.split("/") + new_path = os.path.join("/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/lib", file_parts[-1]) + print(new_path) + if os.path.exists(new_path): + # Remove old sym links + os.unlink(new_path) - if ".dylib" in file_path or ".so" in file_path: - - #print (file_path) - print ("install_name_tool %s -id %s" % (file_path, file_path)) - call(["install_name_tool", file_path, "-id", file_path]) + # Create new symlink to Qt frameworks + call(["ln", "-s", file_path, new_path]) - raw_output = subprocess.Popen(["oTool", "-L", file_path], stdout=subprocess.PIPE).communicate()[0].decode('utf-8') - for output in raw_output.split("\n")[1:-1]: - if output and not "is not an object file" in output: - dependency_path = output.split('\t')[1].split(' ')[0] - dependency_version = output.split('\t')[1].split(' (')[1].replace(')','') +# FIX PyQt5 library paths +# This is NOT required anymore (leaving here as an example) +#PATH = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/" - if "@rpath" in dependency_path: - command = 'install_name_tool "%s" -change "%s" "%s"' % (file_path, dependency_path, dependency_path.replace("@rpath", os.path.join(PATH, "lib"))) - print (command) - call(["install_name_tool", file_path, "-change", dependency_path, dependency_path.replace("@rpath", os.path.join(PATH, "lib"))]) +# Find files matching patterns +#for root, dirs, files in os.walk(PATH): +# for basename in files: +# file_path = os.path.join(root, basename) +# file_parts = file_path.split("/") +# +# if ".dylib" in file_path or ".so" in file_path: +# +# #print (file_path) +# print ("install_name_tool %s -id %s" % (file_path, file_path)) +# call(["install_name_tool", file_path, "-id", file_path]) +# +# raw_output = subprocess.Popen(["oTool", "-L", file_path], stdout=subprocess.PIPE).communicate()[0].decode('utf-8') +# for output in raw_output.split("\n")[1:-1]: +# if output and not "is not an object file" in output: +# dependency_path = output.split('\t')[1].split(' ')[0] +# dependency_version = output.split('\t')[1].split(' (')[1].replace(')','') +# +# if "@rpath" in dependency_path: +# command = 'install_name_tool "%s" -change "%s" "%s"' % (file_path, dependency_path, dependency_path.replace("@rpath", os.path.join(PATH, "lib"))) +# print (command) +# call(["install_name_tool", file_path, "-change", dependency_path, dependency_path.replace("@rpath", os.path.join(PATH, "lib"))])