pipenv: pipenv install --deploy --system doesn't respect PIP_IGNORE_INSTALLED=1 in 2020.8.13

Issue description

When requesting pip to install in user mode, and also to ignore any installed packages, (PIP_USER=1 PIP_IGNORE_INSTALLED=1) pipenv will still skip system installed packages if they meet the requirements. This worked fine in 2020.6.2.

While this use case might seem a bit obscure at first, it’s a great way to install and generate local wheels in a multi-step Dockerfile ensuring that everything is included in a single folder that can easily be copied over to a minimal python image.

Expected result

I expect all packages to be installed in the expected location, regardless of if they exist at the system level, when PIP_IGNORE_INSTALLED is set.

Actual result

Any system package meeting the requirements are skipped and not installed.

Steps to replicate

I’m using Docker here to avoid contaminating the local user installation, but the same happens outside of Docker.

In a new folder, run pipenv install six to create a Pipfile with six as the only dependency.

Using this Dockerfile in the same folder, run docker build . -t test

FROM python:3.7-buster
WORKDIR /build
# System install, which includes six
RUN pip install pipenv==2020.8.13

COPY Pipfile* ./
RUN env PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --deploy --system

Use docker run --rm -ti test /bin/bash and verify that six.py has not been installed into /root/.local in the container.

To verify that this is not something pip does, add the following line at the end of the Dockerfile, repeat the steps above, and notice that it correctly installs six in /root/.local

RUN env PIP_USER=1 PIP_IGNORE_INSTALLED=1 pip install six

(This is the equivalent of running pip install --user --ignore-installed six)

Workaround

Using the previous version 2020.6.2 of pipenv solves the problem form now.

RUN pip install pipenv==2020.6.2

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 5
  • Comments: 19 (4 by maintainers)

Commits related to this issue

Most upvoted comments

If so, it’s probably good to update the final part of this section of the documentation to be more clear what pip environment variables are supported and which aren’t.

https://pipenv.pypa.io/en/latest/advanced/#configuration-with-environment-variables

Excerpt:

Also note that pip itself supports environment variables, if you need additional customization.

For example:

$ PIP_INSTALL_OPTION="-- -DCMAKE_BUILD_TYPE=Release" pipenv install -e .