From a69f2a20e83fec53b148bcbd61e47fada655d617 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Wed, 24 Nov 2010 20:38:31 +0100
Subject: [PATCH] pycompile: `pycompile $DESTDIR/usr/lib/python*` will
 recognize public site-packages directories and use the right interpreter
 instead of raising KeyError

---
 debian/changelog | 3 +++
 pycompile        | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 67a2a3b..8436033 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ python-defaults (2.6.6-6) UNRELEASED; urgency=low
   * dh_python2: install files listed in debian/package.pyinstall file
     as public modules for all requested Python versions (use dh_install's
     package.install files for private modules)
+  * pycompile: `pycompile $DESTDIR/usr/lib/python*` will recognize public
+    site-packages directories and use the right interpreter instead of raising
+    KeyError
 
  -- Piotr Ożarowski <piotr@debian.org>  Sun, 21 Nov 2010 23:49:32 +0100
 
diff --git a/pycompile b/pycompile
index bcef097..2d0a37c 100755
--- a/pycompile
+++ b/pycompile
@@ -191,7 +191,13 @@ def compile(files, versions, e_patterns=None):
         if exists("%sc" % fn):
             continue
         for version in versions_to_compile:
-            pipe = STDINS[version]
+            try:
+                pipe = STDINS[version]
+            except KeyError:
+                # `pycompile /usr/lib/` invoked, add missing worker
+                pipe = py_compile(version, WORKERS)
+                pipe.next()
+                STDINS[version] = pipe
             pipe.send(fn)
 
 
-- 
GitLab