File: fix_qt5_rpath.py

package info (click to toggle)
openshot-qt 2.4.3%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 107,544 kB
  • sloc: python: 289,246; xml: 3,101; makefile: 214; sh: 69
file content (69 lines) | stat: -rw-r--r-- 3,463 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
68
69
"""Analyze the OS X app bundle for OpenShot, and find all external dependencies"""
import os
import subprocess
from subprocess import call

# # Symbolic Link Qt Frameworks into Python3/PyQt5 Framework
# # IMPORTANT to run after installing PyQt5
# PATH = "/usr/local/qt5/5.5/clang_64/lib"
#
# # Find files matching patterns
# for file in os.listdir(PATH):
#     if file.endswith(".framework"):
#         file_path = os.path.join(PATH, file)
#         file_parts = file_path.split("/")
#         print(os.path.join("/Library/Frameworks/Python.framework/Versions/3.5/lib", file_parts[-1]))
#         call(["ln", "-s", file_path, os.path.join("/Library/Frameworks/Python.framework/Versions/3.6/lib", file_parts[-1])])



# # 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 "framework" in file_path and file_parts[-2] == "5" and "_debug" not in file_path:
#             print ("\nFixing %s" % 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')
#             if not "is not an object file" in raw_output:
#                 for output in raw_output.split("\n")[1:-1]:
#                     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", PATH))
#                         print (command)
#                         #call(["install_name_tool", file_path, "-change", dependency_path, dependency_path.replace("@rpath", 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/"

# 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"))])