mirror of https://github.com/KLayout/klayout.git
full python embed with dependencies. includes ssl
This commit is contained in:
parent
73772cc6f8
commit
896f7347f0
|
|
@ -797,23 +797,41 @@ def DeployBinariesForBundle():
|
|||
os.chmod( targetDirM + "/klayout_console", 0o0755 )
|
||||
|
||||
print(" [2] Relinking dylib dependencies inside Python.framework")
|
||||
print(" [2.1] Patching Python Framework")
|
||||
depdict = WalkFrameworkPaths(pythonFrameworkPath)
|
||||
appPythonFrameworkPath = '@executable_path/../Frameworks/Python.framework/'
|
||||
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath)], bundleExecPathAbs)
|
||||
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath, False)], bundleExecPathAbs)
|
||||
|
||||
print(" [2.2] Patching /usr/local/opt/ libs")
|
||||
usrLocalPath = '/usr/local/opt/'
|
||||
appUsrLocalPath = '@executable_path/../Frameworks/'
|
||||
depdict = WalkFrameworkPaths(pythonFrameworkPath)
|
||||
PerformChanges(depdict, [(usrLocalPath, appUsrLocalPath)], bundleExecPathAbs, libdir=True)
|
||||
replacePairs = [(usrLocalPath, appUsrLocalPath, True)]
|
||||
depdict = WalkFrameworkPaths(pythonFrameworkPath, search_path_filter=r'\t+/usr/local/(opt|Cellar)')
|
||||
PerformChanges(depdict, replacePairs, bundleExecPathAbs)
|
||||
|
||||
print(" [2.3] Patching openssl, gdbm, readline, sqlite, tcl-tk, xz")
|
||||
usrLocalPath = '/usr/local/opt'
|
||||
appUsrLocalPath = '@executable_path/../Frameworks/'
|
||||
replacePairs = [(usrLocalPath, appUsrLocalPath, True)]
|
||||
replacePairs.extend([(openssl_version, '@executable_path/../Frameworks/openssl', True)
|
||||
for openssl_version in list(Path('/usr/local/Cellar/openssl').glob('*'))])
|
||||
depdict = WalkFrameworkPaths([pythonFrameworkPath + '/../openssl',
|
||||
pythonFrameworkPath + '/../gdbm',
|
||||
pythonFrameworkPath + '/../readline',
|
||||
pythonFrameworkPath + '/../sqlite',
|
||||
pythonFrameworkPath + '/../tcl-tk',
|
||||
pythonFrameworkPath + '/../xz'], search_path_filter=r'\t+/usr/local/(opt|Cellar)')
|
||||
|
||||
PerformChanges(depdict, replacePairs, bundleExecPathAbs)
|
||||
|
||||
print(" [3] Relinking dylib dependencies for klayout")
|
||||
klayoutPath = bundleExecPathAbs
|
||||
depdict = WalkFrameworkPaths(klayoutPath, filter_regex=r'klayout$')
|
||||
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath)], bundleExecPathAbs)
|
||||
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath, False)], bundleExecPathAbs)
|
||||
|
||||
libKlayoutPath = bundleExecPathAbs + '../Frameworks'
|
||||
depdict = WalkFrameworkPaths(libKlayoutPath, filter_regex=r'libklayout')
|
||||
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath)], bundleExecPathAbs)
|
||||
PerformChanges(depdict, [(pythonOriginalFrameworkPath, appPythonFrameworkPath, False)], bundleExecPathAbs)
|
||||
|
||||
print(" [4] Patching site.py, pip/, and distutils/")
|
||||
site_module = f"{pythonFrameworkPath}/Versions/3.6/lib/python3.6/site.py"
|
||||
|
|
|
|||
|
|
@ -206,10 +206,12 @@ if CAN_DEPLOY_PYTHON:
|
|||
else:
|
||||
raise RuntimeError("Exceeded maximum recursion depth.")
|
||||
|
||||
def WalkFrameworkPaths(frameworkPaths, filter_regex=r'\.(so|dylib)$'):
|
||||
def WalkFrameworkPaths(frameworkPaths, filter_regex=r'\.(so|dylib)$', search_path_filter=r'\t+/usr/local/opt'):
|
||||
|
||||
if isinstance(frameworkPaths, str):
|
||||
frameworkPathsIter = [frameworkPaths]
|
||||
else:
|
||||
frameworkPathsIter = frameworkPaths
|
||||
|
||||
dependency_dict = dict()
|
||||
|
||||
|
|
@ -223,7 +225,7 @@ if CAN_DEPLOY_PYTHON:
|
|||
|
||||
dependency_dict[frameworkPath] = list()
|
||||
for idx, file in enumerate(framework_files):
|
||||
dict_file = {file: WalkLibDependencyTree(file)}
|
||||
dict_file = {file: WalkLibDependencyTree(file, filter_regex=search_path_filter)}
|
||||
dependency_dict[frameworkPath].append(dict_file)
|
||||
return dependency_dict
|
||||
|
||||
|
|
@ -277,7 +279,7 @@ if CAN_DEPLOY_PYTHON:
|
|||
|
||||
return libNameChanges
|
||||
|
||||
def PerformChanges(frameworkDependencyDict, replaceFromToPairs=None, executable_path="/tmp/klayout", libdir=False):
|
||||
def PerformChanges(frameworkDependencyDict, replaceFromToPairs=None, executable_path="/tmp/klayout"):
|
||||
libNameChanges = DetectChanges(frameworkDependencyDict)
|
||||
cmdNameId = XcodeToolChain['nameID']
|
||||
cmdNameChg = XcodeToolChain['nameCH']
|
||||
|
|
@ -290,11 +292,15 @@ if CAN_DEPLOY_PYTHON:
|
|||
dependencies = next(libNameChangeIterator)
|
||||
except StopIteration:
|
||||
dependencies = list()
|
||||
for replaceFrom, replaceTo in replaceFromToPairs:
|
||||
for replaceFrom, replaceTo, libdir in replaceFromToPairs:
|
||||
replaceFrom = str(Path(replaceFrom))
|
||||
replaceTo = str(Path(replaceTo))
|
||||
|
||||
fileName = ResolveExecutablePath(lib.replace(replaceFrom, replaceTo), executable_path)
|
||||
if str(fileName).startswith('/usr'):
|
||||
# print(f'skipping fileName: {fileName}')
|
||||
continue
|
||||
|
||||
if lib.find(replaceFrom) >= 0:
|
||||
if libdir:
|
||||
frameworkPath = FindFramework(lib, replaceFrom)
|
||||
|
|
@ -320,7 +326,7 @@ if CAN_DEPLOY_PYTHON:
|
|||
|
||||
for dependency in dependencies:
|
||||
if dependency.find(replaceFrom) >= 0:
|
||||
print("In:", fileName)
|
||||
print("\tIn:", fileName)
|
||||
print("\tRENAME", dependency, " -> ", dependency.replace(replaceFrom, replaceTo))
|
||||
|
||||
# Try changing id first
|
||||
|
|
|
|||
Loading…
Reference in New Issue