-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pipenv install --deploy --system doesn't respect PIP_IGNORE_INSTALLED=1 in 2020.8.13 #4453
Comments
I believe this defect is related: #4276 |
Happens to me as well. Here is the self-contained reproduction:
I.e. the |
Using And if you are curious, it used to work on 2020.6.2 because of a bug #4315 that is fixed on 2020.8.13. So it is not encouraged to depend on hidden features. You should submit a feature request if current (documented) behavior doesn't meet your requirement. |
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:
|
While I think it would be a useful feature of pipenv, to either support this natively, or to respect the env variable, I can think of an alternate approach:
As far as I can tell this will create the virtualenv, but not install anything, and then generate a |
@frostming I misread your comment earlier; that using |
@frostming I understand where you are coming from, but this approach was working since Pipenv inception and seems to be used quite a lot and not just by me: #3160. I understand the value of doing things right. But there is also a great value of deprecation and migration paths. Breaking something that was working for years without any notice and clear migration path is painful as both this and #4432 clearly show. And currently there is still no clear migration path to achieve the same:
What's your opinion on the above? |
Btw, with |
@frostming OK, sorry to keep beating at this, but for some reason I didn't see this in the documentation before, which directly contradicts your statement:
|
@haizaar You can redirect the virtual env to another location, using WORKON_HOME or delete .local/share/virtualenv* before you copy. This might still leave some extra stuff around, but is at least somewhat better. |
Thank you Andreas for digging that documentation piece. I had a feeling I'm
not completely crazy here.
Regarding WORKON_HOME override - how does it differ from "venv-in-project"
approach? Using venv (and copying but over to the final image) takes even
more space since it includes pip as well which another 10mb. Plus, I don't
want to have package installer in my production image.
…On Mon, 14 Sep 2020, 00:31 Andreas Axelsson, ***@***.***> wrote:
Btw, with pipenv lock -r approach, setuptools somehow still ends up as
part of the installed packages (+3.5mb)
@haizaar <https://github.com/haizaar> You can redirect the virtual env to
another location, using WORKON_HOME or delete .local/share/virtualenv*
before you copy. This might still leave some extra stuff around, but is at
least somewhat better.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4453 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAOGWNHMU5RHDWQRFFNPQLSFTJVHANCNFSM4QUJLAZA>
.
|
@haizaar It looks like when using But I tried one more workaround, where I instead use |
Here's a link to the Pipenv documentation where it uses |
I am hesitating to do this in Pipenv while it shouldn't be difficult to support. It's true pip's env var may work when Pipenv doesn't take in the charge because pip is used internally by Pipenv to install packages. But when Pipenv implements its own logic, things get different: if we are to support |
I believe we already recommend users to use pip options in some cases, so it’d be reasonable for pipenv to explicitly offer support a number of pip options. But IMO TBH I don’t understand why people feel so strongly about using virtual environments in a Docker container. Environments created by virtualenv 20 have no runtime penalty at all (and the build time delay is minimal if you disable auto update), and the end result is much more simple and deterministic. But maybe we can add a new flag to |
@uranusjr, there's a couple of reasons for not wanting to use a virtualenv, that I can think of, there might be others. The ultimate goal is to get the Docker image size down as much as possible, and since you're highly likely to need compilers and other tooling in the image where you run Having pip, setuptools and other base modules that come with a virtualenv in your production container is another thing people want to avoid for various reasons, e.g. size, and just to minimize potential misuse. My own image is large enough that I can see past that, but to @haizaar it apparently made a significant difference. A quick test for Python 3.7 shows there's around 8.5MiB of tooling in a fresh venv, using python:3.7-buster as the base image, none of which my app needs to run. Sure the base image with the OS layers is a lot bigger, but we're now trending more and more to distro-less and blank containers for running apps, so in the end everything counts. Installing to the user folder makes sense because in a fresh Docker image you wouldn't have anything else conflicting, so it's known to be clean, and thus suitable for a 1:1 copy. So besides the size/tooling issue, using a virtualenv is more complicated as you need to somehow pass on the location to the runtime image so you know where to copy from. I guess that can either be done by using I'm currently reasonably happy with my Should |
Maybe I am missing something, but I don't see |
I imagine pip programmatically matches PIP_ + UPPERCASE_OPTION_NAME_WITH_UNDERSCORE_FOR_DASHES for the environment, rather than spelling them all out in source, since I believe pretty much all options can be specified using the environment. |
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
Use
docker run --rm -ti test /bin/bash
and verify thatsix.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
(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.
The text was updated successfully, but these errors were encountered: