From: Yaroslav Halchenko <debian@onerussian.com>
Vendor: Debian
Subject: Prevent deadlock if process generates considerable amount of output

See warning in
http://docs.python.org/library/subprocess.html#convenience-functions

This patch resolves it via redirecting stderr into stdout and sucking all
stdout before waiting.  There could be alternative resolution (e.g. large
bufsize) but since stderr is dumped out anyways, this looked like the most
appropriate.  Also printing both stdout and stderr out provides better complete
picture for the failure

also it provides output of stderr easier to digest

--- a/setup.py
+++ b/setup.py
@@ -14,14 +14,14 @@ class build(_build):
             print "nrnivmodl found at", nrnivmodl
             import subprocess
             p = subprocess.Popen(nrnivmodl, shell=True, stdin=subprocess.PIPE,
-                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+                         stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                          close_fds=True, cwd=os.path.join(os.getcwd(), self.build_lib, 'pyNN/neuron/nmodl'))
+            stdout = p.stdout.readlines()
             result = p.wait()
             # test if nrnivmodl was successful
             if result != 0:
-                errorMsg = p.stderr.readlines()
-                print "Unable to compile NEURON extensions. Error message was:"
-                print errorMsg
+                print "Unable to compile NEURON extensions. Output was:"
+                print '  '.join([''] + stdout) # indent error msg for easy comprehension
             else:
                 print "Successfully compiled NEURON extensions."
         else:
