setup_venv: Install pip.txt requirements with --force-reinstall.

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 <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2019-09-22 22:41:10 -07:00
committed by Tim Abbott
parent d368aaad10
commit 76492b25ae

View File

@@ -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):