0

I'm using a virutalenv with --system-site-packages so that my builds don't take forever (I'm actually using Docker, so installs to the container environment are cached).

Problem is that nose is also getting installed to system site-packages. So when I later run ./myenv/bin/pip install --upgrade nose, pip says "Requirement already up-to-date: nose in /usr/local/lib/python2.7/dist-packages." As a result, the nosetests binary never appears in myenv/bin.

It's important that I should be able to reference that binary regardless of whether the system environment happens to have node installed. I have minor moral qualms with virtualenv's activate.

I assumed that pip's --ignore-installed flag would force the virtualenv-local install, but apparently I was wrong. It seems to force the reinstall the system-level package, still in system site-packages.

brandones
  • 1,847
  • 2
  • 18
  • 36
  • How does `--system-site-packages` make your Docker build faster? – Ry- Nov 18 '16 at 17:06
  • Using more or less the last technique suggested in https://jpetazzo.github.io/2013/12/01/docker-python-pip-requirements/ . Docker image layer k is a system-level install of something that takes forever to build (e.g. scipy), k+1 is the step that copies my source into the container (which always invalidates the cache), step k+2 creates a virtualenv and installs to that virtualenv. The system-level installs get cached, so even though the virtualenv install step always happens, it can just use those system-level packages where possible. – brandones Nov 18 '16 at 17:11
  • A little more exactly: http://stackoverflow.com/a/25307587/1464495 – brandones Nov 18 '16 at 17:13
  • 1
    So create the virtualenv first, install scipy into it, add your requirements.txt, install those dependencies, and finally add the rest of your source. – Ry- Nov 18 '16 at 17:13
  • Oy, dunno how I didn't think of that. Yes, that's the right thing to do here. Would you, SO power-user, recommend that I close this question or leave it open in case someone does end up actually needing the answer? – brandones Nov 18 '16 at 18:32

0 Answers0