[NumPy-Tickets] [NumPy] #1857: Pip install into virtualenv doesn't work

NumPy Trac numpy-tickets@scipy....
Wed Aug 3 10:02:30 CDT 2011

#1857: Pip install into virtualenv doesn't work
 Reporter:  rgommers           |       Owner:  rgommers   
     Type:  defect             |      Status:  new        
 Priority:  normal             |   Milestone:  Unscheduled
Component:  numpy.distutils    |     Version:  1.6.0      
 Keywords:  pip, easy_install  |  

Comment(by embray):

 Really?  Using the last patch I posted `pip install -e .` does not work--
 the install crashes as the usual place, with "'build/py3k/numpy' is not a
 directory".  Relying on 'pip-egg-info' was the only way it could determine
 if it was being run by pip.

 The lines you asked about fix up the path for the pip-egg-info directory.
 By default the path passed to --egg-base is relative to the current
 working directory.  So when the setup.py changes directories to
 build/py3k/numpy, the pip-egg-info directory gets created at
 build/py3k/numpy/pip-egg-info.  But after the `setup.py egg_info` command
 is run, pip goes looking for that directory and doesn't find it.  So what
 those lines do is it just fixes the path for pip-egg-info so that it's
 absolute, and in the location where pip expects to find it.  Does that
 make sense?

 For what it's worth, this is what my setup.py looks like now:

 diff --git a/setup.py b/setup.py
 index 542ca7b..ec05e30 100755
 --- a/setup.py
 +++ b/setup.py
 @@ -166,6 +166,14 @@ def setup_package():
          site_cfg = os.path.join(local_path, 'site.cfg')
          if os.path.isfile(site_cfg):
              shutil.copy(site_cfg, src_path)
 +        # pip messes with __file__ which can cause problems when
 installing in
 +        # Python3; restore __file__ to what it would have been otherwise
 +        global __file__
 +        __file__ = os.path.join(os.curdir, os.path.basename(__file__))
 +        if '--egg-base' in sys.argv:
 +            idx = sys.argv.index('--egg-base')
 +            if sys.argv[idx + 1] == 'pip-egg-info':
 +                sys.argv[idx + 1] = os.path.join(local_path, 'pip-egg-

      old_path = os.getcwd()

 It now fixes `__file__` regardless of whether we're in pip--if we're not
 in pip then it makes no difference.  If `--egg-base pip-egg-info` is in
 sys.path then it makes that fix to the pip-egg-info path.

 Then there's just the one issue with pip choking on non-ascii output from
 the build.  I created a [https://github.com/pypa/pip/issues/325 bug
 report] for that, but it hasn't been noticed yet, so I might go poke them
 on the mailing list or something.

Ticket URL: <http://projects.scipy.org/numpy/ticket/1857#comment:17>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list