Skip to content
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

major version bump of virtualenv (updated 2019-02-10) breaks multistage docker builds using pipenv #4128

Closed
ianlofs opened this issue Feb 10, 2020 · 11 comments
Labels

Comments

@ianlofs
Copy link

ianlofs commented Feb 10, 2020

Issue description

Pipenv installs new version of virtualenv (20.0.1) when updated or installed for the first time.
The new version of virtualenv, which is a complete rewrite and does not have the same virtualenv directory structure as previous major release, appears to break python apps deployed using a multistage docker build process, ie.

FROM python:3.6 as build
# install any build dependencies using package manager
RUN pip install pipenv
RUN pipenv install
RUN python setup.py install
FROM python:3.6
COPY --from build <path_to_virtualenv_location> <path_to_location_in_final_step>
ENTRYPOINT ['<path_to_location_in_final_step/bin/<executable_name>'

Expected result

Running container should result in the executable running successfully.

Actual result

Executable fails with ModuleNotFoundError: No module named 'pkg_resources'

@ianlofs ianlofs changed the title major version bump of virtualenv (updated 2019-02-10) breaks multistage docker builds using pipenv major version bump of virtualenv (updated 2019-02-10) breaks multistage docker builds using pipenv Feb 10, 2020
@ianlofs
Copy link
Author

ianlofs commented Feb 10, 2020

I also created an issue in the virtualenv project, #1560

@ghost
Copy link

ghost commented Feb 11, 2020

What is the short term workaround? Is it possible to set the virtualenv version? Or add --seeder pip to some Pipfile property?

@frostming
Copy link
Contributor

@dms-cat Sure, you can install as pip install "virtualenv<20.0.0" pipenv

@NMFR
Copy link

NMFR commented Feb 11, 2020

I also suffered from this, in my case i have the .venv folder in my project folder (via PIPENV_VENV_IN_PROJECT=1).

The virtual environment now depends on the ./.venv folder and the ./.local folder (./.venv symlinks some folder from ./.local).

If you copy the .local folder it should fix your problem.

@NMFR
Copy link

NMFR commented Feb 11, 2020

Sadly pipenv does not allow to version lock pip :(

@ianlofs
Copy link
Author

ianlofs commented Feb 11, 2020

What is the short term workaround? Is it possible to set the virtualenv version? Or add --seeder pip to some Pipfile property?

I got through it with the following in my Dockerfile

pip install pipenv
# override the virtualenv version that gets installed alongside pipenv
pip install -U virtualenv==16.7.9

@ntrepid8
Copy link

ntrepid8 commented Feb 11, 2020

It seems like adding an environment variable to the Dockerfile like this reverts the new symlink behavior:

ENV VIRTUALENV_SEEDER=pip

When I use that it produced a virtual environment without any symlinks back to ~/.local.

@ntrepid8
Copy link

Looks like virtualenv 20.0.2 was just released and reverted the app-data behavior so using the pip seeder may not be required anymore:

@saikill
Copy link

saikill commented Feb 11, 2020

We are still getting error with the latest version of virtualenv

Building wheels for collected packages: distlib
Building wheel for distlib (setup.py): started
Building wheel for distlib (setup.py): finished with status 'done'
Created wheel for distlib: filename=distlib-0.3.0-py3-none-any.whl size=340427 sha256=06ab30a179b43cbf2e3a63c7d92ab467e6d664bc7d142b889dad313cb875875f
Stored in directory: /tmp/.cache/pip/wheels/3d/85/00/c5766a5c95cf8683c50f1c142e3be944b6ffa7d4c9d86ac96d
Successfully built distlib
Installing collected packages: zipp, importlib-metadata, filelock, distlib, importlib-resources, appdirs, six, virtualenv, virtualenv-clone, certifi, pipenv
Successfully installed appdirs-1.4.3 certifi-2019.11.28 distlib-0.3.0 filelock-3.0.12 importlib-metadata-1.5.0 importlib-resources-1.0.2 pipenv-2018.11.26 six-1.14.0 virtualenv-20.0.2 virtualenv-clone-0.5.3 zipp-2.2.0
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--discovery {builtin}] [-p py] [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_separated_list] [--clear]
[--system-site-packages] [--symlinks | --copies] [--download | --no-download] [--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel]
[--clear-app-data] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: unrecognized arguments: --relocatable
Build step 'Execute shell' marked build as failure

@ianlofs
Copy link
Author

ianlofs commented Apr 16, 2020

This appears to be fixed with the latest version of virtualenv

@ianlofs ianlofs closed this as completed Apr 16, 2020
@JeffinBao
Copy link

We are still getting error with the latest version of virtualenv

Building wheels for collected packages: distlib
Building wheel for distlib (setup.py): started
Building wheel for distlib (setup.py): finished with status 'done'
Created wheel for distlib: filename=distlib-0.3.0-py3-none-any.whl size=340427 sha256=06ab30a179b43cbf2e3a63c7d92ab467e6d664bc7d142b889dad313cb875875f
Stored in directory: /tmp/.cache/pip/wheels/3d/85/00/c5766a5c95cf8683c50f1c142e3be944b6ffa7d4c9d86ac96d
Successfully built distlib
Installing collected packages: zipp, importlib-metadata, filelock, distlib, importlib-resources, appdirs, six, virtualenv, virtualenv-clone, certifi, pipenv
Successfully installed appdirs-1.4.3 certifi-2019.11.28 distlib-0.3.0 filelock-3.0.12 importlib-metadata-1.5.0 importlib-resources-1.0.2 pipenv-2018.11.26 six-1.14.0 virtualenv-20.0.2 virtualenv-clone-0.5.3 zipp-2.2.0
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--discovery {builtin}] [-p py] [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_separated_list] [--clear]
[--system-site-packages] [--symlinks | --copies] [--download | --no-download] [--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel]
[--clear-app-data] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: unrecognized arguments: --relocatable
Build step 'Execute shell' marked build as failure

I experience the same issue. I roll back virtualenv version to pip install -U virtualenv==16.7.9 as mentioned by @ianlofs . My question is does latest virtualenv removed relocatable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants