[jhbuild/desrt/master: 6/22] systeminstall: speed up pkg-config



commit 91ca35bdae4b523b5221ec102eff11885d0fa3fe
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Jan 10 21:38:08 2015 -0500

    systeminstall: speed up pkg-config
    
    The code for building the list of all installed packages is very slow,
    particularly when lots of packages are installed.
    
    This "slow and steady" approach was implemented in bug 683832 because of
    the potential for broken pkg-config files to break the old approach.
    
    Broken pkg-config files are not normally installed, so we may as well
    try to do things the fast way first, falling back on the other approach
    if it fails.
    
    This improves 'jhbuild list glib' from ~5.6 to ~0.4 seconds on my fairly
    typical system (with 482 .pc files installed).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740866

 jhbuild/utils/systeminstall.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 3651326..c5ebd0c 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -39,6 +39,16 @@ def get_installed_pkgconfigs(config):
         for line in StringIO(stdout):
             pkg, rest = line.split(None, 1)
             pkgs.append(pkg)
+
+        # see if we can get the versions "the easy way"
+        try:
+            stdout = subprocess.check_output(['pkg-config', '--modversion'] + pkgs)
+            versions = stdout.splitlines()
+            if len(versions) == len(pkgs):
+                return dict(zip(pkgs, versions))
+        except OSError:
+            pass
+
         # We have to rather inefficiently repeatedly fork to work around
         # broken pkg-config installations - if any package has a missing
         # dependency pkg-config will fail entirely.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]