Back to index

python3.2  3.2.2
Functions | Variables
ctypes.macholib.dyld Namespace Reference

Functions

def dyld_env
def dyld_image_suffix
def dyld_framework_path
def dyld_library_path
def dyld_fallback_framework_path
def dyld_fallback_library_path
def dyld_image_suffix_search
def dyld_override_search
def dyld_executable_path_search
def dyld_default_search
def dyld_find
def framework_find
def test_dyld_find

Variables

list __all__
list DEFAULT_FRAMEWORK_FALLBACK
list DEFAULT_LIBRARY_FALLBACK

Detailed Description

dyld emulation

Function Documentation

def ctypes.macholib.dyld.dyld_default_search (   name,
  env = None 
)

Definition at line 94 of file dyld.py.

00094 
00095 def dyld_default_search(name, env=None):
00096     yield name
00097 
00098     framework = framework_info(name)
00099 
00100     if framework is not None:
00101         fallback_framework_path = dyld_fallback_framework_path(env)
00102         for path in fallback_framework_path:
00103             yield os.path.join(path, framework['name'])
00104 
00105     fallback_library_path = dyld_fallback_library_path(env)
00106     for path in fallback_library_path:
00107         yield os.path.join(path, os.path.basename(name))
00108 
00109     if framework is not None and not fallback_framework_path:
00110         for path in DEFAULT_FRAMEWORK_FALLBACK:
00111             yield os.path.join(path, framework['name'])
00112 
00113     if not fallback_library_path:
00114         for path in DEFAULT_LIBRARY_FALLBACK:
00115             yield os.path.join(path, os.path.basename(name))

Here is the call graph for this function:

Here is the caller graph for this function:

def ctypes.macholib.dyld.dyld_env (   env,
  var 
)

Definition at line 31 of file dyld.py.

00031 
00032 def dyld_env(env, var):
00033     if env is None:
00034         env = os.environ
00035     rval = env.get(var)
00036     if rval is None:
00037         return []
00038     return rval.split(':')

Here is the caller graph for this function:

def ctypes.macholib.dyld.dyld_executable_path_search (   name,
  executable_path = None 
)

Definition at line 87 of file dyld.py.

00087 
00088 def dyld_executable_path_search(name, executable_path=None):
00089     # If we haven't done any searching and found a library and the
00090     # dylib_name starts with "@executable_path/" then construct the
00091     # library name.
00092     if name.startswith('@executable_path/') and executable_path is not None:
00093         yield os.path.join(executable_path, name[len('@executable_path/'):])

Here is the caller graph for this function:

Definition at line 50 of file dyld.py.

00050 
00051 def dyld_fallback_framework_path(env=None):
00052     return dyld_env(env, 'DYLD_FALLBACK_FRAMEWORK_PATH')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 53 of file dyld.py.

00053 
00054 def dyld_fallback_library_path(env=None):
00055     return dyld_env(env, 'DYLD_FALLBACK_LIBRARY_PATH')

Here is the call graph for this function:

Here is the caller graph for this function:

def ctypes.macholib.dyld.dyld_find (   name,
  executable_path = None,
  env = None 
)
Find a library or framework using dyld semantics

Definition at line 116 of file dyld.py.

00116 
00117 def dyld_find(name, executable_path=None, env=None):
00118     """
00119     Find a library or framework using dyld semantics
00120     """
00121     for path in dyld_image_suffix_search(chain(
00122                 dyld_override_search(name, env),
00123                 dyld_executable_path_search(name, executable_path),
00124                 dyld_default_search(name, env),
00125             ), env):
00126         if os.path.isfile(path):
00127             return path
00128     raise ValueError("dylib %s could not be found" % (name,))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 44 of file dyld.py.

00044 
00045 def dyld_framework_path(env=None):
00046     return dyld_env(env, 'DYLD_FRAMEWORK_PATH')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 39 of file dyld.py.

00039 
00040 def dyld_image_suffix(env=None):
00041     if env is None:
00042         env = os.environ
00043     return env.get('DYLD_IMAGE_SUFFIX')

Here is the caller graph for this function:

def ctypes.macholib.dyld.dyld_image_suffix_search (   iterator,
  env = None 
)
For a potential path iterator, add DYLD_IMAGE_SUFFIX semantics

Definition at line 56 of file dyld.py.

00056 
00057 def dyld_image_suffix_search(iterator, env=None):
00058     """For a potential path iterator, add DYLD_IMAGE_SUFFIX semantics"""
00059     suffix = dyld_image_suffix(env)
00060     if suffix is None:
00061         return iterator
00062     def _inject(iterator=iterator, suffix=suffix):
00063         for path in iterator:
00064             if path.endswith('.dylib'):
00065                 yield path[:-len('.dylib')] + suffix + '.dylib'
00066             else:
00067                 yield path + suffix
00068             yield path
00069     return _inject()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 47 of file dyld.py.

00047 
00048 def dyld_library_path(env=None):
00049     return dyld_env(env, 'DYLD_LIBRARY_PATH')

Here is the call graph for this function:

Here is the caller graph for this function:

def ctypes.macholib.dyld.dyld_override_search (   name,
  env = None 
)

Definition at line 70 of file dyld.py.

00070 
00071 def dyld_override_search(name, env=None):
00072     # If DYLD_FRAMEWORK_PATH is set and this dylib_name is a
00073     # framework name, use the first file that exists in the framework
00074     # path if any.  If there is none go on to search the DYLD_LIBRARY_PATH
00075     # if any.
00076 
00077     framework = framework_info(name)
00078 
00079     if framework is not None:
00080         for path in dyld_framework_path(env):
00081             yield os.path.join(path, framework['name'])
00082 
00083     # If DYLD_LIBRARY_PATH is set then use the first file that exists
00084     # in the path.  If none use the original name.
00085     for path in dyld_library_path(env):
00086         yield os.path.join(path, os.path.basename(name))

Here is the call graph for this function:

Here is the caller graph for this function:

def ctypes.macholib.dyld.framework_find (   fn,
  executable_path = None,
  env = None 
)
Find a framework using dyld semantics in a very loose manner.

Will take input such as:
    Python
    Python.framework
    Python.framework/Versions/Current

Definition at line 129 of file dyld.py.

00129 
00130 def framework_find(fn, executable_path=None, env=None):
00131     """
00132     Find a framework using dyld semantics in a very loose manner.
00133 
00134     Will take input such as:
00135         Python
00136         Python.framework
00137         Python.framework/Versions/Current
00138     """
00139     try:
00140         return dyld_find(fn, executable_path=executable_path, env=env)
00141     except ValueError as e:
00142         pass
00143     fmwk_index = fn.rfind('.framework')
00144     if fmwk_index == -1:
00145         fmwk_index = len(fn)
00146         fn += '.framework'
00147     fn = os.path.join(fn, os.path.basename(fn[:fmwk_index]))
00148     try:
00149         return dyld_find(fn, executable_path=executable_path, env=env)
00150     except ValueError:
00151         raise e

Here is the call graph for this function:

Definition at line 152 of file dyld.py.

00152 
00153 def test_dyld_find():
00154     env = {}
00155     assert dyld_find('libSystem.dylib') == '/usr/lib/libSystem.dylib'
00156     assert dyld_find('System.framework/System') == '/System/Library/Frameworks/System.framework/System'

Here is the call graph for this function:


Variable Documentation

Initial value:
00001 [
00002     'dyld_find', 'framework_find',
00003     'framework_info', 'dylib_info',
00004 ]

Definition at line 10 of file dyld.py.

Initial value:
00001 [
00002     os.path.expanduser("~/Library/Frameworks"),
00003     "/Library/Frameworks",
00004     "/Network/Library/Frameworks",
00005     "/System/Library/Frameworks",
00006 ]

Definition at line 17 of file dyld.py.

Initial value:
00001 [
00002     os.path.expanduser("~/lib"),
00003     "/usr/local/lib",
00004     "/lib",
00005     "/usr/lib",
00006 ]

Definition at line 24 of file dyld.py.