MCPcopy Create free account
hub / github.com/KLayout/klayout / Change_Python_LibPath_RelativeToAbsolute

Function Change_Python_LibPath_RelativeToAbsolute

macbuild/build4mac_util.py:662–773  ·  view source on GitHub ↗
( frameworkPath, debug_level=0 )

Source from the content-addressed store, hash-verified

660# @return 0 on success; non-zero on failure
661#----------------------------------------------------------------------------------------
662def Change_Python_LibPath_RelativeToAbsolute( frameworkPath, debug_level=0 ):
663 #----------------------------------------------------------------------
664 # [1] Populate a dependency dictionary
665 #----------------------------------------------------------------------
666 dependency_dict = dict()
667 filter_regex = r'\.(so|dylib)$'
668 patRel2 = r'(%s)(.+)' % HomebrewSearchPathFilter2 # = '\t+@loader_path/../../../../../../../../../../opt'
669 patRel3 = r'(%s)(.+)' % HomebrewSearchPathFilter3 # = '@loader_path/../../../../../../../../../../opt'
670 regRel3 = re.compile(patRel3)
671
672 #---------------------------------------------------------------------------------------------------
673 # (A) Collect *.[so|dylib] that the Python Frameworks depends on
674 #---------------------------------------------------------------------------------------------------
675 # Ref. https://formulae.brew.sh/formula/python@3.9
676 # as of 2023-09-22, python@3.9 depends on:
677 # gdbm 1.23 GNU database manager
678 # mpdecimal 2.5.1 Library for decimal floating point arithmetic
679 # openssl@3 3.1.2 Cryptography and SSL/TLS Toolkit
680 # readline 8.2.1 Library for command-line editing
681 # sqlite 3.43.1 Command-line interface for SQLite
682 # xz 5.4.4 General-purpose data compression with high compression ratio
683 #---------------------------------------------------------------------------------------------------
684 # https://formulae.brew.sh/formula/python@3.11
685 # as of 2023-10-24, python@3.11 depends on:
686 # mpdecimal 2.5.1 Library for decimal floating point arithmetic
687 # openssl@3 3.1.3 Cryptography and SSL/TLS Toolkit
688 # sqlite 3.43.2 Command-line interface for SQLite
689 # xz 5.4.4 General-purpose data compression with high compression ratio
690 #---------------------------------------------------------------------------------------------------
691 find_grep_results = os.popen( 'find %s -type f | grep -E "%s"' % (frameworkPath, filter_regex) ).read().split('\n')
692 framework_files = filter( lambda x: x != '', map(lambda x: x.strip(), find_grep_results) )
693
694 for idx, dylibPath in enumerate(framework_files):
695 otoolCm = 'otool -L %s | grep -E "%s"' % (dylibPath, patRel2)
696 otoolOut = os.popen( otoolCm ).read()
697 libdepdic = DecomposeLibraryDependency( dylibPath + ":\n" + otoolOut )
698 keys = libdepdic.keys()
699 deplibs = libdepdic[ list(keys)[0] ]
700
701 if len(deplibs) == 0:
702 continue
703
704 if debug_level > 0:
705 print( "In Change_Python_LibPath_RelativeToAbsolute()" )
706 print( " 1) dylibPath = %s" % dylibPath )
707 print( " 2) libdepdic = %s" % libdepdic )
708 print( " 3) key = %s" % list(keys)[0] )
709 print( " 4) deplibs = %s" % deplibs )
710
711 # @LOADER_PATH = @loader_path/../../../../../../../../../..
712 # dylibPath = /Abs/python3.9/lib-dynload/_hashlib.cpython-39-darwin.so
713 # libdepdic = {'/Abs/python3.9/lib-dynload/_hashlib.cpython-39-darwin.so':
714 # ['@LOADER_PATH/opt/openssl@3/lib/libssl.3.dylib',
715 # '@LOADER_PATH/opt/openssl@3/lib/libcrypto.3.dylib']}
716 # key = /Abs/python3.9/lib-dynload/_hashlib.cpython-39-darwin.so
717 # deplibs = ['@LOADER_PATH/opt/openssl@3/lib/libssl.3.dylib',
718 # '@LOADER_PATH/opt/openssl@3/lib/libcrypto.3.dylib']
719

Callers 2

Calls 11

compileMethod · 0.80
filterFunction · 0.50
mapFunction · 0.50
listClass · 0.50
splitMethod · 0.45
readMethod · 0.45
keysMethod · 0.45
matchMethod · 0.45
appendMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected