[Python-modules-team] Bug#793923: virtualenv: Hangs installing setuptools/pip when specific files exist in $PWD

Kenneth Pronovici pronovic at debian.org
Tue Jul 28 21:55:03 UTC 2015

Package: virtualenv
Version: 1.11.6+ds-1
Severity: normal

I have run into a strange scenario with virtualenv, which I can reliably
reproduce in both jessie and an up-to-date unstable chroot.

I was trying to create a Python 2.7 virtualenv from within the source
tree for cedar-backup2.  Every time I ran it, the virtualenv process
hung at "Installing setuptools, pip...".

I eventually discovered that this only happened when I was within the
source tree.  If went to some other directory but installed to the same
place, virtualenv completed as expected.  

This made me suspicious that there was something in my source tree 
causing the problem, so I started removing things until virtualenv
worked properly.  What I ended up with is a very minimal test case:

   wintermute:/home/pronovic/tmp/package/code> echo $PYTHONPATH

   wintermute:/home/pronovic/tmp/package/code> which virtualenv

   wintermute:/home/pronovic/tmp/package/code> ls -l             
   total 4
   drwxrwsr-x 2 pronovic pronovic 4096 Jul 28 16:33 util/

   wintermute:/home/pronovic/tmp/package/code> ls -l util/       
   total 8
   -rw-rw-r-- 1 pronovic pronovic 15 Jul 28 16:32 __init__.py
   -rw-rw-r-- 1 pronovic pronovic 33 Jul 28 16:32 whatever.py

   wintermute:/home/pronovic/tmp/package/code> cat util/__init__.py 
   __all__ = [ ]

   wintermute:/home/pronovic/tmp/package/code> cat util/whatever.py 
   import sys

   wintermute:/home/pronovic/tmp/package/code> rm -rf .python && virtualenv --python=python2.7 .python # hangs
   Running virtualenv with interpreter /usr/bin/python2.7
   New python executable in .python/bin/python2.7
   Not overwriting existing python script .python/bin/python (you must use .python/bin/python2.7)
   Installing setuptools, pip...

   wintermute:/home/pronovic/tmp/package/code> cd ..

   wintermute:/home/pronovic/tmp/package> rm -rf code/.python && virtualenv --python=python2.7 code/.python # works
   Running virtualenv with interpreter /usr/bin/python2.7
   New python executable in code/.python/bin/python2.7
   Not overwriting existing python script code/.python/bin/python (you must use code/.python/bin/python2.7)
   Installing setuptools, pip...done.

   wintermute:/home/pronovic/tmp/package> cd code

   wintermute:/home/pronovic/tmp/package/code> cat util/whatever.py  # note readlines() commented out
   import sys

   wintermute:/home/pronovic/tmp/package/code> rm -rf .python && virtualenv --python=python2.7 .python # works
   Running virtualenv with interpreter /usr/bin/python2.7
   New python executable in .python/bin/python2.7
   Also creating executable in .python/bin/python
   Installing setuptools, pip...done.

It actually kind of of makes sense that readlines() is involved, because
if I CTRL-C virtualenv when it's stuck, I get this stack trace:

   Installing setuptools, pip...^Cdone.
   Traceback (most recent call last):
     File "/usr/bin/virtualenv", line 9, in <module>
   Traceback (most recent call last):
     File "/usr/lib/python3/dist-packages/virtualenv.py", line 2378, in
       load_entry_point('virtualenv==1.11.6', 'console_scripts',
     File "/usr/lib/python3/dist-packages/virtualenv.py", line 790, in main
     File "/usr/lib/python3/dist-packages/virtualenv.py", line 830, in main
       raise SystemExit(popen.wait())
     File "/usr/lib/python3.4/subprocess.py", line 1566, in wait
     File "/usr/lib/python3/dist-packages/virtualenv.py", line 1032, in
       install_wheel(to_install, py_executable, search_dirs)
     File "/usr/lib/python3/dist-packages/virtualenv.py", line 975, in
       'PIP_NO_INDEX': '1'
     File "/usr/lib/python3/dist-packages/virtualenv.py", line 889, in
       line = stdout.readline()
       (pid, sts) = self._try_wait(0)
     File "/usr/lib/python3.4/subprocess.py", line 1514, in _try_wait
       (pid, sts) = _eintr_retry_call(os.waitpid, self.pid, wait_flags)
     File "/usr/lib/python3.4/subprocess.py", line 491, in
       return func(*args)

The behavior seems to be tied to a Python package named "util".  If I
remove util/__init__.py or rename the package to something else, that
also solves the problem.  

It does not seem to matter what the name of the source file is
(whatever.py is just an example), and it doesn't seem to matter which
version of Python I am trying to create a virtualenv for.  I've
reproduced the same behavior with 2.7 and 3.4.

Let me know if there's anything else I can help with,



-- System Information:
Debian Release: 8.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.16.0-4-686-pae (SMP w/1 CPU core)
Locale: LANG=en, LC_CTYPE=en_US (charmap=ISO-8859-1) (ignored: LC_ALL set to en_US)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages virtualenv depends on:
ii  python3             3.4.2-2
ii  python3-virtualenv  1.11.6+ds-1

virtualenv recommends no packages.

virtualenv suggests no packages.

-- no debconf information

Kenneth J. Pronovici <pronovic at debian.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/python-modules-team/attachments/20150728/f6f56f03/attachment.sig>

More information about the Python-modules-team mailing list