Hello,
bindepend.py getImports3 (ldd-based) was not something to be proud of. It
was calling "ldd" redirecting its output to a temporary file, then wait 0.1
seconds (??) and then parsing the file. The code to parse the file was
pretty weak and probably written by someone who knew C more than Python.
Also, it broke down with files containing spaces.
I reworked it a little bit to use popen() and to parse ldd output with
regexp which should make it a little bit more solid. Committed as r247. I
tested it under Linux.
--
Giovanni Bajo
Index: bindepend.py
===================================================================
--- bindepend.py (revision 244)
+++ bindepend.py (working copy)
@@ -33,6 +33,7 @@
import time
import string
import sys
+import re
seen = {}
_bpath = None
@@ -278,19 +279,12 @@
"""Find the binary dependencies of PTH.
This implementation is for ldd platforms"""
- import tempfile
rslt = []
- tmpf = tempfile.mktemp()
- os.system('ldd "%s" >%s' %(pth, tmpf))
- time.sleep(0.1)
- txt = open(tmpf,'r').readlines()
- os.remove(tmpf)
- i = 0
- while i < len(txt):
- tokens = string.split(string.strip(txt[i]))
- if len(tokens) > 2 and tokens[1] == '=>':
- lib = string.strip(tokens[2])
- if string.strip(tokens[0])[:10] == 'linux-gate':
+ for line in os.popen('ldd "%s"' % pth).readlines():
+ m = re.search(r"\s+(.*?)\s+=>\s+(.*?)\s+\(.*\)", line)
+ if m:
+ name, lib = m.group(1), m.group(2)
+ if name[:10] == 'linux-gate':
# linux-gate is a fake library which does not exist and
# should be ignored. See also:
# http://www.trilithium.com/johan/2005/08/linux-gate/
@@ -298,8 +292,8 @@
if os.path.exists(lib):
rslt.append(lib)
else:
- print 'E: cannot find %s needed by %s' % (tokens[0], pth)
- i = i + 1
+ print 'E: cannot find %s in path %s (needed by %s)' % \
+ (name, lib, pth)
return rslt
def getImports(pth):
_______________________________________________
PyInstaller mailing list
[email protected]
http://lists.hpcf.upr.edu/mailman/listinfo/pyinstaller