From 76492b25ae10c911352d52b7e5f446e69b680f98 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 22 Sep 2019 22:41:10 -0700 Subject: [PATCH] setup_venv: Install pip.txt requirements with --force-reinstall. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit virtualenv on Ubuntu 16.04, when creating a new environment, downloads the current version of setuptools, then replaces its pkg_resources with an old copy from /usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl. This causes problems, a simple example of which is reproducible from the ubuntu:16.04 Docker base image as follows: apt-get update apt-get -y install python3-virtualenv python3 -m virtualenv -p python3 /ve /ve/bin/pip install sockjs-tornado /ve/bin/pip download sockjs-tornado → `AttributeError: '_NamespacePath' object has no attribute 'sort'` More relevantly, it breaks pip-compile in the same way. To fix this, we need to force setuptools to be reinstalled, even if we’re asking for the same version. Signed-off-by: Anders Kaseorg --- scripts/lib/setup_venv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/setup_venv.py b/scripts/lib/setup_venv.py index a4bbf72f28..2a277ecccc 100644 --- a/scripts/lib/setup_venv.py +++ b/scripts/lib/setup_venv.py @@ -93,7 +93,7 @@ YUM_THUMBOR_VENV_DEPENDENCIES = [ def install_venv_deps(pip, requirements_file): # type: (str, str) -> None pip_requirements = os.path.join(ZULIP_PATH, "requirements", "pip.txt") - run([pip, "install", "-U", "--requirement", pip_requirements]) + run([pip, "install", "--force-reinstall", "--requirement", pip_requirements]) run([pip, "install", "--no-deps", "--requirement", requirements_file]) def get_index_filename(venv_path):