ATLAS Offline Software
Public Member Functions | Public Attributes | Private Member Functions | List of all members
dlldep.SharedLib Class Reference
Collaboration diagram for dlldep.SharedLib:

Public Member Functions

def __init__ (self, distance, lib)
 

Public Attributes

 lib
 
 distance
 
 deplibs
 

Private Member Functions

def _getLibs (self, lib)
 

Detailed Description

Represent a shared library with name, dependencies and other stats

Definition at line 54 of file dlldep.py.

Constructor & Destructor Documentation

◆ __init__()

def dlldep.SharedLib.__init__ (   self,
  distance,
  lib 
)

Definition at line 57 of file dlldep.py.

57  def __init__(self, distance, lib):
58  import os.path as osp
59  lib = osp.expanduser(osp.expandvars(lib))
60  if not osp.exists(lib):
61  l = Dso.find_library(lib)
62  if l:
63  lib = l
64  assert osp.exists(lib), "no such path [%s]" % (lib,)
65  self.lib = lib # path of library
66  self.distance = distance # distance from root lib
67  self.deplibs = self._getLibs(lib) # direct dependencies
68 

Member Function Documentation

◆ _getLibs()

def dlldep.SharedLib._getLibs (   self,
  lib 
)
private
Get direct dependencies of shared library

Definition at line 69 of file dlldep.py.

69  def _getLibs(self, lib):
70  """Get direct dependencies of shared library"""
71 
72  # First check if already in global cache
73  cachedlib = Cache.files.get(lib)
74  if cachedlib: return cachedlib.deplibs
75 
76  # Run readelf to find direct dependencies
77  # Note: ldd itself does recursions so we cannot use it here
78  encargs = {'encoding' : 'utf-8'}
79  p = sp.Popen(["readelf","-d",lib], stdout=sp.PIPE, **encargs)
80  output = p.communicate()[0]
81  if p.returncode != 0:
82  print ("Cannot run 'readelf' on",lib)
83  return []
84 
85  libs = []
86  for l in output.split("\n"):
87  if l.find("NEEDED")==-1: continue
88  libs += [l.split()[-1].strip("[]")]
89 
90  # Run ldd to find full path of libraries
91  p = sp.Popen(["ldd",lib], stdout=sp.PIPE, **encargs)
92  output = p.communicate()[0]
93  if p.returncode != 0:
94  print ("Cannot run 'ldd' on",lib)
95  return []
96 
97  libpaths = []
98  for l in output.split("\n"):
99  fields = l.strip().split()
100  if len(fields)!=4: continue
101  path = fields[2]
102  if (fields[0] in libs) and len(path)>0:
103  libpaths += [path]
104 
105  return libpaths
106 
107 

Member Data Documentation

◆ deplibs

dlldep.SharedLib.deplibs

Definition at line 67 of file dlldep.py.

◆ distance

dlldep.SharedLib.distance

Definition at line 66 of file dlldep.py.

◆ lib

dlldep.SharedLib.lib

Definition at line 65 of file dlldep.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::split
@ split
Definition: LayerMaterialProperties.h:38